bitcoinrb 1.10.0 → 1.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/bitcoin/constants.rb +1 -0
- data/lib/bitcoin/script/script.rb +17 -1
- data/lib/bitcoin/script/script_error.rb +2 -0
- data/lib/bitcoin/script/script_interpreter.rb +3 -1
- data/lib/bitcoin/tx.rb +1 -0
- data/lib/bitcoin/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: a617f4bbc9d3523c7de3740050880c5bdaeafb8513eaa04686e39ea70f25673a
|
|
4
|
+
data.tar.gz: 1ddcfa267f592c563bf8db07774ff1805dea53d382f9a330e9b1d4f76c5d9eaa
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: f984c05b61a1f67cd5374b559730c7f7cae9f2bf1024d00e352bb98237d3258bef72cbf0660c579a0e900e0c3c5bc0d298299cbe7c347e2c8d48009fcc076a91
|
|
7
|
+
data.tar.gz: 19195672bcd808e9554558f83d8e7e13513d814e511892d01ddf8c1084cc4e853e8386825c50fea89a44317d36715148848402324070ee56dbd69d13a11fa20f
|
data/lib/bitcoin/constants.rb
CHANGED
|
@@ -205,6 +205,7 @@ module Bitcoin
|
|
|
205
205
|
SCRIPT_ERR_TAPSCRIPT_VALIDATION_WEIGHT = 94
|
|
206
206
|
SCRIPT_ERR_TAPSCRIPT_CHECKMULTISIG = 95
|
|
207
207
|
SCRIPT_ERR_TAPSCRIPT_MINIMALIF = 96
|
|
208
|
+
SCRIPT_ERR_TAPSCRIPT_EMPTY_PUBKEY = 97
|
|
208
209
|
|
|
209
210
|
ERRCODES_MAP = Hash[*constants.grep(/^SCRIPT_ERR_/).map { |c| [const_get(c), c.to_s] }.flatten]
|
|
210
211
|
NAME_MAP = Hash[*constants.grep(/^SCRIPT_ERR_/).map { |c| [c.to_s, const_get(c)] }.flatten]
|
|
@@ -8,6 +8,8 @@ module Bitcoin
|
|
|
8
8
|
include Bitcoin::Opcodes
|
|
9
9
|
include Bitcoin::HexConverter
|
|
10
10
|
|
|
11
|
+
P2A_PROGRAM = '4e73'.htb
|
|
12
|
+
|
|
11
13
|
attr_accessor :chunks
|
|
12
14
|
|
|
13
15
|
def initialize
|
|
@@ -37,6 +39,12 @@ module Bitcoin
|
|
|
37
39
|
new << OP_1 << xonly_pubkey
|
|
38
40
|
end
|
|
39
41
|
|
|
42
|
+
# Generate P2TR script
|
|
43
|
+
# @return [Bitcoin::Script]
|
|
44
|
+
def self.to_p2a
|
|
45
|
+
new << OP_1 << P2A_PROGRAM
|
|
46
|
+
end
|
|
47
|
+
|
|
40
48
|
# generate m of n multisig p2sh script
|
|
41
49
|
# @param [String] m the number of signatures required for multisig
|
|
42
50
|
# @param [Array] pubkeys array of public keys that compose multisig
|
|
@@ -198,7 +206,7 @@ module Bitcoin
|
|
|
198
206
|
|
|
199
207
|
# check whether standard script.
|
|
200
208
|
def standard?
|
|
201
|
-
p2pkh? | p2sh? | p2wpkh? | p2wsh? | p2tr? | multisig? | standard_op_return?
|
|
209
|
+
p2pkh? | p2sh? | p2wpkh? | p2wsh? | p2tr? | multisig? | standard_op_return? || p2a?
|
|
202
210
|
end
|
|
203
211
|
|
|
204
212
|
# Check whether this script is a P2PKH format script.
|
|
@@ -230,6 +238,13 @@ module Bitcoin
|
|
|
230
238
|
chunks[0].ord == WITNESS_VERSION_V1 && chunks[1].bytesize == 33
|
|
231
239
|
end
|
|
232
240
|
|
|
241
|
+
# Check whether this script is a Pay to Anchor format script.
|
|
242
|
+
# @return [Boolean] if P2A return true, otherwise false
|
|
243
|
+
def p2a?
|
|
244
|
+
return false unless chunks.size == 2
|
|
245
|
+
chunks[0].ord == WITNESS_VERSION_V1 && chunks[1].pushed_data == P2A_PROGRAM
|
|
246
|
+
end
|
|
247
|
+
|
|
233
248
|
# Check whether this script is a P2SH format script.
|
|
234
249
|
# @return [Boolean] if P2SH return true, otherwise false
|
|
235
250
|
def p2sh?
|
|
@@ -560,6 +575,7 @@ module Bitcoin
|
|
|
560
575
|
return 'witness_v0_keyhash' if p2wpkh?
|
|
561
576
|
return 'witness_v0_scripthash' if p2wsh?
|
|
562
577
|
return 'witness_v1_taproot' if p2tr?
|
|
578
|
+
return 'anchor' if p2a?
|
|
563
579
|
'nonstandard'
|
|
564
580
|
end
|
|
565
581
|
|
|
@@ -114,6 +114,8 @@ module Bitcoin
|
|
|
114
114
|
'OP_CHECKMULTISIG(VERIFY) is not available in tapscript'
|
|
115
115
|
when SCRIPT_ERR_TAPSCRIPT_MINIMALIF
|
|
116
116
|
'OP_IF/NOTIF argument must be minimal in tapscript'
|
|
117
|
+
when SCRIPT_ERR_TAPSCRIPT_EMPTY_PUBKEY
|
|
118
|
+
'Empty public key in tapscript'
|
|
117
119
|
when SCRIPT_ERR_OP_CODESEPARATOR
|
|
118
120
|
'Using OP_CODESEPARATOR in non-witness script'
|
|
119
121
|
when SCRIPT_ERR_SIG_FINDANDDELETE
|
|
@@ -167,6 +167,8 @@ module Bitcoin
|
|
|
167
167
|
end
|
|
168
168
|
return true unless need_evaluate
|
|
169
169
|
end
|
|
170
|
+
elsif version == 1 && program == Script::P2A_PROGRAM
|
|
171
|
+
return true
|
|
170
172
|
elsif flag?(SCRIPT_VERIFY_DISCOURAGE_UPGRADABLE_WITNESS_PROGRAM)
|
|
171
173
|
return set_error(SCRIPT_ERR_DISCOURAGE_UPGRADABLE_WITNESS_PROGRAM)
|
|
172
174
|
else
|
|
@@ -740,7 +742,7 @@ module Bitcoin
|
|
|
740
742
|
|
|
741
743
|
pubkey_size = pubkey.htb.bytesize
|
|
742
744
|
if pubkey_size == 0
|
|
743
|
-
return set_error(
|
|
745
|
+
return set_error(SCRIPT_ERR_TAPSCRIPT_EMPTY_PUBKEY)
|
|
744
746
|
elsif pubkey_size == X_ONLY_PUBKEY_SIZE
|
|
745
747
|
if success
|
|
746
748
|
result = checker.check_schnorr_sig(sig, pubkey, :tapscript, opts)
|
data/lib/bitcoin/tx.rb
CHANGED
|
@@ -234,6 +234,7 @@ module Bitcoin
|
|
|
234
234
|
def verify_input_sig(input_index, script_pubkey, amount: nil, flags: STANDARD_SCRIPT_VERIFY_FLAGS, prevouts: [])
|
|
235
235
|
script_sig = inputs[input_index].script_sig
|
|
236
236
|
has_witness = inputs[input_index].has_witness?
|
|
237
|
+
has_witness = true if script_pubkey.witness_program?
|
|
237
238
|
|
|
238
239
|
if script_pubkey.p2sh?
|
|
239
240
|
flags << SCRIPT_VERIFY_P2SH
|
data/lib/bitcoin/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: bitcoinrb
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.
|
|
4
|
+
version: 1.11.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- azuchi
|
|
8
8
|
bindir: exe
|
|
9
9
|
cert_chain: []
|
|
10
|
-
date:
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
11
11
|
dependencies:
|
|
12
12
|
- !ruby/object:Gem::Dependency
|
|
13
13
|
name: ecdsa_ext
|
|
@@ -447,7 +447,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
447
447
|
- !ruby/object:Gem::Version
|
|
448
448
|
version: '0'
|
|
449
449
|
requirements: []
|
|
450
|
-
rubygems_version: 3.6.
|
|
450
|
+
rubygems_version: 3.6.9
|
|
451
451
|
specification_version: 4
|
|
452
452
|
summary: The implementation of Bitcoin Protocol for Ruby.
|
|
453
453
|
test_files: []
|