Module: Bitcoin::Builder

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

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

Yields:

  • (c)


10
11
12
13
14
# File 'lib/bitcoin/builder.rb', line 10

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

#build_tx(opts = {}) {|c| ... } ⇒ Object

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

Yields:

  • (c)


18
19
20
21
22
# File 'lib/bitcoin/builder.rb', line 18

def build_tx(opts = {})
  c = TxBuilder.new
  yield c
  c.tx opts
end

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

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

Yields:

  • (c)


26
27
28
29
30
# File 'lib/bitcoin/builder.rb', line 26

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