Class: Bitcoin::Descriptor::Multi
- Inherits:
-
Expression
- Object
- Expression
- Bitcoin::Descriptor::Multi
- Defined in:
- lib/bitcoin/descriptor/multi.rb
Overview
multi() expression
Direct Known Subclasses
Instance Attribute Summary collapse
-
#keys ⇒ Object
readonly
Returns the value of attribute keys.
-
#threshold ⇒ Object
readonly
Returns the value of attribute threshold.
Instance Method Summary collapse
- #args ⇒ Object
-
#initialize(threshold, keys) ⇒ Multi
constructor
A new instance of Multi.
- #to_hex ⇒ Object
- #to_script ⇒ Object
- #top_level? ⇒ Boolean
- #type ⇒ Object
Methods inherited from Expression
#==, #compressed_key?, #derive_path, #extract_pubkey, #to_s
Constructor Details
permalink #initialize(threshold, keys) ⇒ Multi
Returns a new instance of Multi.
9 10 11 12 13 |
# File 'lib/bitcoin/descriptor/multi.rb', line 9 def initialize(threshold, keys) validate!(threshold, keys) @threshold = threshold @keys = keys end |
Instance Attribute Details
permalink #keys ⇒ Object (readonly)
Returns the value of attribute keys.
7 8 9 |
# File 'lib/bitcoin/descriptor/multi.rb', line 7 def keys @keys end |
permalink #threshold ⇒ Object (readonly)
Returns the value of attribute threshold.
6 7 8 |
# File 'lib/bitcoin/descriptor/multi.rb', line 6 def threshold @threshold end |
Instance Method Details
permalink #args ⇒ Object
[View source]
30 31 32 |
# File 'lib/bitcoin/descriptor/multi.rb', line 30 def args "#{threshold},#{keys.join(',')}" end |
permalink #to_hex ⇒ Object
23 24 25 26 27 28 |
# File 'lib/bitcoin/descriptor/multi.rb', line 23 def to_hex result = to_script pubkey_count = result.get_pubkeys.length raise RuntimeError, "Cannot have #{pubkey_count} pubkeys in bare multisig; only at most 3 pubkeys." if pubkey_count > 3 result.to_hex end |
permalink #to_script ⇒ Object
[View source]
19 20 21 |
# File 'lib/bitcoin/descriptor/multi.rb', line 19 def to_script Script.to_multisig_script(threshold, keys.map{|key| extract_pubkey(key).pubkey }, sort: false) end |
permalink #top_level? ⇒ Boolean
34 35 36 |
# File 'lib/bitcoin/descriptor/multi.rb', line 34 def top_level? false end |
permalink #type ⇒ Object
[View source]
15 16 17 |
# File 'lib/bitcoin/descriptor/multi.rb', line 15 def type :multi end |