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)


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(opts = {}) {|c| ... } ⇒ Object

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

Yields:

  • (c)


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

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)


28
29
30
31
32
# File 'lib/bitcoin/builder.rb', line 28

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