pub struct Multisig {
pub threshold: u8,
}Expand description
Multisig (M-of-N) script template.
Creates scripts that require M signatures from a set of N public keys. The threshold M is stored in the template; the public keys are provided when creating the locking script.
§Signature Order
Signatures in the unlocking script must appear in the same order as their corresponding public keys in the locking script. The OP_CHECKMULTISIG opcode walks through keys and signatures in order, matching each signature to the next available key.
Fields§
§threshold: u8M — the number of required signatures.
Implementations§
Source§impl Multisig
impl Multisig
Sourcepub fn new(threshold: u8) -> Self
pub fn new(threshold: u8) -> Self
Creates a new Multisig template with the given threshold.
§Arguments
threshold- The number of signatures required (M). Must be 1-16.
Sourcepub fn lock_from_keys(&self, pubkeys: &[PublicKey]) -> Result<LockingScript>
pub fn lock_from_keys(&self, pubkeys: &[PublicKey]) -> Result<LockingScript>
Creates a multisig locking script from public keys.
This is the recommended API. Keys are encoded in compressed form (33 bytes).
§Arguments
pubkeys- The N public keys. Must have 1-16 keys, and threshold <= N.
Sourcepub fn unlock(
signers: &[PrivateKey],
sign_outputs: SignOutputs,
anyone_can_pay: bool,
) -> ScriptTemplateUnlock
pub fn unlock( signers: &[PrivateKey], sign_outputs: SignOutputs, anyone_can_pay: bool, ) -> ScriptTemplateUnlock
Creates an unlock template for spending a multisig output.
§Arguments
signers- The M private keys to sign with. Must be in the same order as their corresponding public keys appear in the locking script.sign_outputs- Which outputs to sign.anyone_can_pay- Whether to allow other inputs to be added.
Sourcepub fn sign_with_sighash(
signers: &[PrivateKey],
sighash: &[u8; 32],
sign_outputs: SignOutputs,
anyone_can_pay: bool,
) -> Result<UnlockingScript>
pub fn sign_with_sighash( signers: &[PrivateKey], sighash: &[u8; 32], sign_outputs: SignOutputs, anyone_can_pay: bool, ) -> Result<UnlockingScript>
Signs with a precomputed sighash.
§Arguments
signers- The M private keys to sign with (in pubkey order).sighash- The precomputed sighash to sign.sign_outputs- Which outputs to sign (for the scope byte).anyone_can_pay- Whether to allow other inputs to be added.