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.



494
495
496
497
# File 'lib/bitcoin/builder.rb', line 494

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

Instance Attribute Details

#redeem_scriptObject (readonly)

Returns the value of attribute redeem_script.



492
493
494
# File 'lib/bitcoin/builder.rb', line 492

def redeem_script
  @redeem_script
end

#scriptObject (readonly)

Returns the value of attribute script.



492
493
494
# File 'lib/bitcoin/builder.rb', line 492

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.



508
509
510
# File 'lib/bitcoin/builder.rb', line 508

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.



501
502
503
# File 'lib/bitcoin/builder.rb', line 501

def type(type)
  @type = type.to_sym
end