Class: BSV::Transaction::UnlockingScriptTemplate Abstract

Inherits:
Object
  • Object
show all
Defined in:
lib/bsv/transaction/unlocking_script_template.rb

Overview

This class is abstract.

Subclass and override #sign and #estimated_length.

Abstract base class for unlocking script templates.

Templates provide deferred signing — an input can hold a template that generates the unlocking script at sign time, when the full transaction is available for sighash computation. Subclass and implement #sign and #estimated_length.

See Also:

Direct Known Subclasses

P2PKH

Instance Method Summary collapse

Instance Method Details

#estimated_length(_tx, _input_index) ⇒ Integer

Estimate the unlocking script length in bytes (for fee estimation).

Parameters:

  • _tx (Transaction)

    the transaction

  • _input_index (Integer)

    the input index

Returns:

  • (Integer)

    estimated script length in bytes

Raises:

  • (NotImplementedError)

    if not overridden by a subclass



31
32
33
# File 'lib/bsv/transaction/unlocking_script_template.rb', line 31

def estimated_length(_tx, _input_index)
  raise NotImplementedError, "#{self.class}#estimated_length must be implemented"
end

#sign(_tx, _input_index) ⇒ Script::Script

Generate the unlocking script for a transaction input.

Parameters:

  • _tx (Transaction)

    the transaction being signed

  • _input_index (Integer)

    the input index to sign

Returns:

Raises:

  • (NotImplementedError)

    if not overridden by a subclass



21
22
23
# File 'lib/bsv/transaction/unlocking_script_template.rb', line 21

def sign(_tx, _input_index)
  raise NotImplementedError, "#{self.class}#sign must be implemented"
end