Class: Counterparty::TxDecode
- Inherits:
-
Object
- Object
- Counterparty::TxDecode
- Defined in:
- lib/counterparty/tx_decode.rb
Defined Under Namespace
Classes: InvalidOpReturn, InvalidOutput, MultisigUnsupported, UndefinedBehavior
Constant Summary collapse
- DEFAULT_PREFIX =
'CNTRPRTY'
- OP_RETURN_PARTS =
/^OP_RETURN ([a-z0-9]+)$/
- P2PKH_PARTS =
/^OP_DUP OP_HASH160 ([a-z0-9]+) OP_EQUALVERIFY OP_CHECKSIG$/
- OP_MULTISIG_PARTS =
/^[12] ([a-z0-9 ]+) ([23]) OP_CHECKMULTISIG$/
Instance Attribute Summary collapse
-
#data ⇒ Object
Returns the value of attribute data.
-
#decrypt_key ⇒ Object
Returns the value of attribute decrypt_key.
-
#prefix ⇒ Object
Returns the value of attribute prefix.
-
#receiver_addr ⇒ Object
Returns the value of attribute receiver_addr.
-
#sender_addr ⇒ Object
Returns the value of attribute sender_addr.
Instance Method Summary collapse
- #decrypt(chunk) ⇒ Object
-
#initialize(tx, options = {}) ⇒ TxDecode
constructor
A new instance of TxDecode.
Constructor Details
#initialize(tx, options = {}) ⇒ TxDecode
Returns a new instance of TxDecode.
20 21 22 23 24 25 26 |
# File 'lib/counterparty/tx_decode.rb', line 20 def initialize(tx, = {}) @prefix = [:prefix] || DEFAULT_PREFIX @decrypt_key = [:decrypt_key] || [tx.inputs[0].prev_out.reverse_hth].pack('H*') parse! (tx.respond_to? :outputs) ? tx.outputs.collect{|out| out.parsed_script.to_string } : tx end |
Instance Attribute Details
#data ⇒ Object
Returns the value of attribute data.
18 19 20 |
# File 'lib/counterparty/tx_decode.rb', line 18 def data @data end |
#decrypt_key ⇒ Object
Returns the value of attribute decrypt_key.
18 19 20 |
# File 'lib/counterparty/tx_decode.rb', line 18 def decrypt_key @decrypt_key end |
#prefix ⇒ Object
Returns the value of attribute prefix.
18 19 20 |
# File 'lib/counterparty/tx_decode.rb', line 18 def prefix @prefix end |
#receiver_addr ⇒ Object
Returns the value of attribute receiver_addr.
18 19 20 |
# File 'lib/counterparty/tx_decode.rb', line 18 def receiver_addr @receiver_addr end |
#sender_addr ⇒ Object
Returns the value of attribute sender_addr.
18 19 20 |
# File 'lib/counterparty/tx_decode.rb', line 18 def sender_addr @sender_addr end |
Instance Method Details
#decrypt(chunk) ⇒ Object
28 29 30 |
# File 'lib/counterparty/tx_decode.rb', line 28 def decrypt(chunk) RC4.new(decrypt_key).decrypt chunk end |