Module: Bitcoin::Builder

Included in:
Wallet::Wallet
Defined in:
lib/bitcoin/builder.rb

Overview

Optional DSL to help create blocks and transactions.

see also BlockBuilder, TxBuilder, TxInBuilder, TxOutBuilder, ScriptBuilder

Defined Under Namespace

Classes: BlockBuilder, ScriptBuilder, TxBuilder, TxInBuilder, TxOutBuilder

Instance Method Summary collapse

Instance Method Details

#build_block(target = "00".ljust(64, 'f')) {|c| ... } ⇒ Object Also known as: blk

build a Bitcoin::Protocol::Block matching the given target. see BlockBuilder for details.

Yields:

  • (c)


12
13
14
15
16
# File 'lib/bitcoin/builder.rb', line 12

def build_block(target = "00".ljust(64, 'f'))
  c = BlockBuilder.new
  yield c
  c.block(target)
end

#build_tx {|c| ... } ⇒ Object Also known as: tx

build a Bitcoin::Protocol::Tx. see TxBuilder for details.

Yields:

  • (c)


21
22
23
24
25
# File 'lib/bitcoin/builder.rb', line 21

def build_tx
  c = TxBuilder.new
  yield c
  c.tx
end

#script {|c| ... } ⇒ Object

build a Bitcoin::Script. see ScriptBuilder for details.

Yields:

  • (c)


30
31
32
33
34
# File 'lib/bitcoin/builder.rb', line 30

def script
  c = ScriptBuilder.new
  yield c
  c.script
end