miniscript – How do I write a script such that my funds are locked in a 2-of-2 multisig that converts into a 1-of-2 multisig after 365 days?


To construct the script you could use Pieter Wuille’s Miniscript site.

If you go to the Policy to Miniscript compiler section there is an example in Policy for a 2-of-2 multisig that turns into a 1-of-2 multisig after 90 days.

and(pk(key_user),or(99@pk(key_service),older(12960)))

You would need to adjust it for your desired example. A Policy that fits your needs would be:

and(pk(key_1),or(99@pk(key_2),older(52560)))

Once you have the Policy you can copy and paste this into the Policy to Miniscript compiler section and get the Miniscript equivalent of this Policy. The Miniscript output is:

and_v(v:pk(key_1),or_d(pk(key_2),older(52560)))

Further down you can copy and paste this Miniscript in, press Analyze and you will get the size of the resulting Script (78 bytes) as well as the actual Script:

<key_1> OP_CHECKSIGVERIFY <key_2> OP_CHECKSIG OP_IFDUP OP_NOTIF
    <50cd00> OP_CHECKSEQUENCEVERIFY
OP_ENDIF

It is worth noting that this example assumes you are more concerned with losing one particular key (key_2 in this example) and you assume will still have access to key 1. If you are just as likely to lose either key (key_1 or key_2) you would want a different script.

I recommend you try this on testnet or Signet first where coins aren’t worth anything. Alternatively with a small amount of funds on mainnet that you can afford to lose. You don’t want to be losing all your funds due to a mistake or a misunderstanding.