Class: Cryptos::Output
- Inherits:
-
Struct
- Object
- Struct
- Cryptos::Output
- Includes:
- Utils::Hexas
- Defined in:
- lib/cryptos/output.rb
Instance Attribute Summary collapse
-
#script_pubkey ⇒ Object
Returns the value of attribute script_pubkey.
-
#value ⇒ Object
Returns the value of attribute value.
Class Method Summary collapse
- .atomic_swap(secret_hash, to_address, locktime, from_address, amount) ⇒ Object
- .multisig(a1, a2, amount) ⇒ Object
- .p2pkh(address, amount) ⇒ Object
- .p2pkh_change(address, input, output, fee = 10_000) ⇒ Object
Instance Method Summary collapse
Methods included from Utils::Hexas
#bignum_to_hex, #bin_to_hex, #byte_to_hex, #bytes_to_hex, #hex_size, #hex_to_little, #int_to_hex, #long_to_hex
Methods included from Utils::Bytes
#bignum_to_bytes, #bytes_to_bignum
Instance Attribute Details
#script_pubkey ⇒ Object
Returns the value of attribute script_pubkey
2 3 4 |
# File 'lib/cryptos/output.rb', line 2 def script_pubkey @script_pubkey end |
#value ⇒ Object
Returns the value of attribute value
2 3 4 |
# File 'lib/cryptos/output.rb', line 2 def value @value end |
Class Method Details
.atomic_swap(secret_hash, to_address, locktime, from_address, amount) ⇒ Object
20 21 22 23 |
# File 'lib/cryptos/output.rb', line 20 def self.atomic_swap(secret_hash, to_address, locktime, from_address, amount) swap_script = Cryptos::Script.swap secret_hash, to_address, locktime, from_address Output.new amount, Cryptos::Script.p2sh(swap_script) end |
.multisig(a1, a2, amount) ⇒ Object
10 11 12 13 |
# File 'lib/cryptos/output.rb', line 10 def self.multisig(a1, a2, amount) redeem_script = Cryptos::Script.multisig a1, a2 Output.new amount, Cryptos::Script.p2sh(redeem_script) end |
Instance Method Details
#serialize ⇒ Object
25 26 27 28 |
# File 'lib/cryptos/output.rb', line 25 def serialize script_hex = script_pubkey.to_hex long_to_hex(value) + byte_to_hex(hex_size(script_hex)) + script_hex end |