Class: Bitcoin::SilentPayment::Output
- Inherits:
-
Object
- Object
- Bitcoin::SilentPayment::Output
- Defined in:
- lib/bitcoin/silent_payment/output.rb
Overview
Represents a detected silent payment output.
Instance Attribute Summary collapse
-
#label ⇒ Integer?
readonly
The label used for this output, or nil if no label was used.
-
#tweak ⇒ String
readonly
The tweak value (t_k) used to derive the output key (32 bytes binary).
-
#tx_out ⇒ Bitcoin::TxOut
readonly
The detected transaction output.
Instance Method Summary collapse
-
#initialize(tx_out, tweak, label = nil) ⇒ Output
constructor
A new instance of Output.
-
#labeled? ⇒ Boolean
Returns whether this output was detected using a label.
-
#pubkey ⇒ String
Returns the x-only public key of the output.
-
#tweak_hex ⇒ String
Returns the tweak as hex string.
Constructor Details
#initialize(tx_out, tweak, label = nil) ⇒ Output
Returns a new instance of Output.
18 19 20 21 22 23 24 25 |
# File 'lib/bitcoin/silent_payment/output.rb', line 18 def initialize(tx_out, tweak, label = nil) raise ArgumentError, "tx_out must be a Bitcoin::TxOut." unless tx_out.is_a?(Bitcoin::TxOut) raise ArgumentError, "tweak must be a 32-byte String." unless tweak.is_a?(String) && tweak.bytesize == 32 raise ArgumentError, "label must be an Integer or nil." unless label.nil? || label.is_a?(Integer) @tx_out = tx_out @tweak = tweak @label = label end |
Instance Attribute Details
#label ⇒ Integer? (readonly)
Returns The label used for this output, or nil if no label was used.
12 13 14 |
# File 'lib/bitcoin/silent_payment/output.rb', line 12 def label @label end |
#tweak ⇒ String (readonly)
Returns The tweak value (t_k) used to derive the output key (32 bytes binary).
9 10 11 |
# File 'lib/bitcoin/silent_payment/output.rb', line 9 def tweak @tweak end |
#tx_out ⇒ Bitcoin::TxOut (readonly)
Returns The detected transaction output.
6 7 8 |
# File 'lib/bitcoin/silent_payment/output.rb', line 6 def tx_out @tx_out end |
Instance Method Details
#labeled? ⇒ Boolean
Returns whether this output was detected using a label.
41 42 43 |
# File 'lib/bitcoin/silent_payment/output.rb', line 41 def labeled? !label.nil? end |
#pubkey ⇒ String
Returns the x-only public key of the output.
29 30 31 |
# File 'lib/bitcoin/silent_payment/output.rb', line 29 def pubkey tx_out.script_pubkey.witness_data[1].bth end |
#tweak_hex ⇒ String
Returns the tweak as hex string.
35 36 37 |
# File 'lib/bitcoin/silent_payment/output.rb', line 35 def tweak_hex tweak.bth end |