-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implements raw() and hex() descriptor specified by BIP-385
- Loading branch information
Showing
11 changed files
with
162 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
module Bitcoin | ||
module Descriptor | ||
class Addr < Expression | ||
include Bitcoin::Util | ||
|
||
attr_reader :addr | ||
|
||
def initialize(addr) | ||
raise ArgumentError, "Address must be string." unless addr.is_a?(String) | ||
raise ArgumentError, "Address is not valid." unless valid_address?(addr) | ||
@addr = addr | ||
end | ||
|
||
def type | ||
:addr | ||
end | ||
|
||
def to_script | ||
Bitcoin::Script.parse_from_addr(addr) | ||
end | ||
|
||
def top_level? | ||
true | ||
end | ||
|
||
def args | ||
addr | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
module Bitcoin | ||
module Descriptor | ||
class Raw < Expression | ||
|
||
attr_reader :hex | ||
|
||
# Constructor | ||
# @param [String] hex | ||
def initialize(hex) | ||
raise ArgumentError, "Raw script must be string." unless hex.is_a?(String) | ||
raise ArgumentError, "Raw script is not hex." unless hex.valid_hex? | ||
@hex = hex | ||
end | ||
|
||
def type | ||
:raw | ||
end | ||
|
||
def to_script | ||
Bitcoin::Script.parse_from_payload(hex.htb) | ||
end | ||
|
||
def args | ||
hex | ||
end | ||
|
||
def top_level? | ||
true | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,6 +11,10 @@ def to_script | |
script.to_script.to_p2sh | ||
end | ||
|
||
def top_level? | ||
true | ||
end | ||
|
||
private | ||
|
||
def validate!(script) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters