Time-Locked Bitcoin Multisig Transactions: A Comprehensive Guide

Time-Locked Bitcoin Multisig Transactions: A Comprehensive Guide

In the world of Bitcoin, security and flexibility go hand-in-hand. One of Bitcoin's advanced scripting features is the ability to create time-locked transactions combined with multisig requirements. This guide will delve into how this works and provide practical examples for clarity.

Time Locked Bitcoin Transactions Bitcoin transactions can be time locked, meaning they are only valid after a certain time. Time locks can also be used as part of the locking scripts to change the spending requirements of a bitcoin. For example, a script could require 3 signatures to spend the bitcoin before a certain time, after which only 1 signature is required. This makes fallback options possible, ideally preventing a loss of funds.

What is a Time-Locked Transaction?

A time-locked transaction restricts the spending of certain bitcoins until a specified point in time or block height. Bitcoin provides two primary operations for time-locking:

Timelock
  • CheckLockTimeVerify (CLTV): Locks bitcoins until a specific block height or Unix timestamp.
  • CheckSequenceVerify (CSV): Locks bitcoins for a relative amount of time from when the transaction was mined.

What is Multisig?

Multisig, short for multi-signature, requires multiple private keys to authorize a Bitcoin transaction. A common setup is a 2-of-3 multisig, where 2 out of 3 private keys are required to spend the bitcoins.

Combining Time-Lock with Multisig

Imagine a scenario where two parties agree to lock up funds, requiring both of their signatures for withdrawal. However, they also agree that if a specific date passes, either party can access the funds with just their signature. This provides a fallback and ensures funds aren't locked up indefinitely if one party becomes unresponsive.

Scripting a Time-Locked Multisig

Using our previous example of a 2-of-2 multisig transitioning to a 1-of-2 after 1/1/2025:

IF
    2 [pubkey1] [pubkey2] 2 CHECKMULTISIG
ELSE
    1735689600 CHECKLOCKTIMEVERIFY DROP
    1 [pubkey1] [pubkey2] 2 CHECKMULTISIG
ENDIF

Example with fictional public keys:

Assuming:

  • pubkey1 is 03a1c287...
  • pubkey2 is 02bb45a9...

The script becomes:

IF
    2 03a1c287e5... 02bb45a922... 2 CHECKMULTISIG
ELSE
    1735689600 CHECKLOCKTIMEVERIFY DROP
    1 03a1c287e5... 02bb45a922... 2 CHECKMULTISIG
ENDIF

Spending from the Script

  1. Before 1/1/2025: Provide signatures corresponding to both pubkey1 and pubkey2. Push TRUE to the stack to activate the IF branch.
  2. After 1/1/2025: Provide a signature corresponding to either pubkey1 or pubkey2. Push FALSE to the stack to activate the ELSE branch.

Conclusion

Time-locked multisig transactions offer a blend of security and flexibility. Whether you're engaging in a trust-minimized agreement or ensuring a fallback for your funds, Bitcoin's scripting capabilities have you covered. Always test scripts with small amounts and seek expert advice before locking up significant funds.