Skip to content

Class BSV::Script::PushDropTemplate::Unlocker

Inherits: Object

Unlocking template returned by {#unlock}.

Satisfies the P2PKH condition embedded in a PushDrop locking script by computing the BIP-143 sighash and signing it with the wallet's derived key.

Constants

ESTIMATED_LENGTH

Estimated unlocking script length in bytes.

P2PKH unlock is 1 + ~72 (DER sig + hashtype) + 1 + 33 (pubkey) = 107 bytes. In PushDrop context the unlock wraps P2PKH, so the estimate is the same.

Public Instance Methods

estimated_length(_tx, _input_index)

Estimated byte length of the unlocking script. - @param _tx [BSV::Transaction::Transaction] unused - @param _input_index [Integer] unused - @return [Integer]

initialize(wallet, protocol_id, key_id, counterparty, originator)

  • @param wallet [#create_signature, #get_public_key] BRC-100 wallet interface
  • @param protocol_id [Array] two-element [security_level, protocol_name]
  • @param key_id [String] key identifier
  • @param counterparty [String] 'self', 'anyone', or a hex public key
  • @param originator [String, nil] optional originator domain
  • @return [Unlocker] a new instance of Unlocker

sign(tx, input_index)

Generate the unlocking script for the given input.

Computes the BIP-143 sighash (SIGHASH_ALL|FORK_ID), signs it with the wallet's derived key, then returns a P2PKH unlock wrapped in a PushDrop unlock (which is a pass-through). - @param tx [BSV::Transaction::Transaction] the spending transaction - @param input_index [Integer] which input to sign - @return [BSV::Script::Script] the unlocking script