Class: Bitcoin::Builder::TxOutBuilder
- Inherits:
-
Object
- Object
- Bitcoin::Builder::TxOutBuilder
- Defined in:
- lib/bitcoin/builder.rb
Overview
Create a Bitcoin::Protocol::TxOut used by TxBuilder#output.
t.output {|o| o.value 12345; o.to address }
t.output do |o|
o.value 12345
o.script {|s| s.recipient address }
end
Instance Attribute Summary collapse
-
#txout ⇒ Object
readonly
Returns the value of attribute txout.
Instance Method Summary collapse
-
#initialize ⇒ TxOutBuilder
constructor
A new instance of TxOutBuilder.
-
#script {|c| ... } ⇒ Object
Add a script to the output (see ScriptBuilder).
-
#to(recipient, type = :address) ⇒ Object
Set recipient address and script type (defaults to :address).
-
#value(value) ⇒ Object
Set output value (in base units / “satoshis”).
Constructor Details
#initialize ⇒ TxOutBuilder
Returns a new instance of TxOutBuilder.
438 439 440 |
# File 'lib/bitcoin/builder.rb', line 438 def initialize @txout = P::TxOut.new end |
Instance Attribute Details
#txout ⇒ Object (readonly)
Returns the value of attribute txout.
436 437 438 |
# File 'lib/bitcoin/builder.rb', line 436 def txout @txout end |
Instance Method Details
#script {|c| ... } ⇒ Object
Add a script to the output (see ScriptBuilder).
453 454 455 456 457 |
# File 'lib/bitcoin/builder.rb', line 453 def script &block c = ScriptBuilder.new yield c @txout.pk_script, @txout.redeem_script = c.script, c.redeem_script end |
#to(recipient, type = :address) ⇒ Object
Set recipient address and script type (defaults to :address).
448 449 450 |
# File 'lib/bitcoin/builder.rb', line 448 def to recipient, type = :address @txout.pk_script, @txout.redeem_script = *Bitcoin::Script.send("to_#{type}_script", *recipient) end |
#value(value) ⇒ Object
Set output value (in base units / “satoshis”)
443 444 445 |
# File 'lib/bitcoin/builder.rb', line 443 def value value @txout.value = value end |