Class: Bitcoin::Builder::ScriptBuilder

Inherits:
Object
  • Object
show all
Defined in:
lib/bitcoin/builder.rb

Overview

Create a Bitcoin::Script used by TxOutBuilder#script.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeScriptBuilder

Returns a new instance of ScriptBuilder.



435
436
437
438
# File 'lib/bitcoin/builder.rb', line 435

def initialize
  @type = :address
  @script = nil
end

Instance Attribute Details

#redeem_scriptObject (readonly)

Returns the value of attribute redeem_script.



433
434
435
# File 'lib/bitcoin/builder.rb', line 433

def redeem_script
  @redeem_script
end

#scriptObject (readonly)

Returns the value of attribute script.



433
434
435
# File 'lib/bitcoin/builder.rb', line 433

def script
  @script
end

Instance Method Details

#recipient(*data) ⇒ Object

Recipient(s) of the script. Depending on the #type, this should be an address, a hash160 pubkey, or an array of multisig pubkeys.



449
450
451
# File 'lib/bitcoin/builder.rb', line 449

def recipient *data
  @script, @redeem_script = *Script.send("to_#{@type}_script", *data)
end

#type(type) ⇒ Object

Script type (:pubkey, :address/hash160, :multisig). Defaults to :address.



442
443
444
# File 'lib/bitcoin/builder.rb', line 442

def type type
  @type = type.to_sym
end