bsv-sdk 0.23.1 → 0.25.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/CHANGELOG.md +79 -0
- data/README.md +1 -1
- data/lib/bsv/auth/auth_payload.rb +5 -0
- data/lib/bsv/identity/client.rb +9 -5
- data/lib/bsv/kv_store/entry.rb +15 -0
- data/lib/bsv/kv_store/global.rb +210 -0
- data/lib/bsv/kv_store/interpreter.rb +109 -0
- data/lib/bsv/kv_store/token.rb +10 -0
- data/lib/bsv/kv_store.rb +10 -0
- data/lib/bsv/mcp/tools/broadcast_p2pkh.rb +5 -2
- data/lib/bsv/mcp/tools/decode_tx.rb +1 -1
- data/lib/bsv/mcp/tools/fetch_tx.rb +1 -1
- data/lib/bsv/mcp/tools/helpers.rb +3 -3
- data/lib/bsv/network/protocol.rb +12 -1
- data/lib/bsv/network/util.rb +13 -5
- data/lib/bsv/overlay/admin_token_template.rb +2 -2
- data/lib/bsv/overlay/historian.rb +118 -0
- data/lib/bsv/overlay/topic_broadcaster.rb +1 -1
- data/lib/bsv/overlay/types.rb +37 -0
- data/lib/bsv/overlay.rb +1 -0
- data/lib/bsv/primitives/ecies.rb +12 -3
- data/lib/bsv/registry/client.rb +54 -7
- data/lib/bsv/script/bip276.rb +143 -0
- data/lib/bsv/script/interpreter/interpreter.rb +1 -1
- data/lib/bsv/script/push_drop_template.rb +2 -2
- data/lib/bsv/script.rb +1 -0
- data/lib/bsv/storage/downloader.rb +174 -0
- data/lib/bsv/storage/errors.rb +8 -0
- data/lib/bsv/storage/utils.rb +90 -0
- data/lib/bsv/storage.rb +16 -0
- data/lib/bsv/transaction/beef.rb +173 -19
- data/lib/bsv/transaction/beef_party.rb +119 -0
- data/lib/bsv/transaction/chain_tracker.rb +2 -2
- data/lib/bsv/transaction/fee_model.rb +1 -1
- data/lib/bsv/transaction/fee_models/live_policy.rb +1 -1
- data/lib/bsv/transaction/fee_models/satoshis_per_kilobyte.rb +1 -1
- data/lib/bsv/transaction/merkle_path.rb +2 -2
- data/lib/bsv/transaction/p2pkh.rb +1 -1
- data/lib/bsv/transaction/transaction_input.rb +1 -1
- data/lib/bsv/transaction/{transaction.rb → tx.rb} +18 -18
- data/lib/bsv/transaction/unlocking_script_template.rb +2 -2
- data/lib/bsv/transaction.rb +3 -2
- data/lib/bsv/version.rb +1 -1
- data/lib/bsv/wallet/proto_wallet/key_deriver.rb +13 -0
- data/lib/bsv/wallet/proto_wallet.rb +12 -2
- data/lib/bsv/wallet/serializer/create_signature.rb +7 -0
- data/lib/bsv/wallet/serializer/get_public_key.rb +5 -1
- data/lib/bsv/wallet/serializer/reveal_counterparty_key_linkage.rb +6 -3
- data/lib/bsv/wallet/serializer/reveal_specific_key_linkage.rb +6 -3
- data/lib/bsv/wallet/serializer/verify_signature.rb +7 -0
- data/lib/bsv-sdk.rb +2 -0
- metadata +14 -2
|
@@ -10,12 +10,12 @@ module BSV
|
|
|
10
10
|
# estimation.
|
|
11
11
|
#
|
|
12
12
|
# @example Build, sign, and serialise a transaction
|
|
13
|
-
# tx = BSV::Transaction::
|
|
13
|
+
# tx = BSV::Transaction::Tx.new
|
|
14
14
|
# tx.add_input(input)
|
|
15
15
|
# tx.add_output(output)
|
|
16
16
|
# tx.sign(0, private_key)
|
|
17
17
|
# tx.to_hex #=> "0100000001..."
|
|
18
|
-
class
|
|
18
|
+
class Tx
|
|
19
19
|
# Estimated size of an unsigned P2PKH input in bytes.
|
|
20
20
|
UNSIGNED_P2PKH_INPUT_SIZE = 148
|
|
21
21
|
|
|
@@ -59,7 +59,7 @@ module BSV
|
|
|
59
59
|
|
|
60
60
|
# Append a transaction input.
|
|
61
61
|
#
|
|
62
|
-
# @param input [TransactionInput] the input to add
|
|
62
|
+
# @param input [Transaction::TransactionInput] the input to add
|
|
63
63
|
# @return [self] for chaining
|
|
64
64
|
def add_input(input)
|
|
65
65
|
@inputs << input
|
|
@@ -68,7 +68,7 @@ module BSV
|
|
|
68
68
|
|
|
69
69
|
# Append a transaction output.
|
|
70
70
|
#
|
|
71
|
-
# @param output [TransactionOutput] the output to add
|
|
71
|
+
# @param output [Transaction::TransactionOutput] the output to add
|
|
72
72
|
# @return [self] for chaining
|
|
73
73
|
def add_output(output)
|
|
74
74
|
@outputs << output
|
|
@@ -144,7 +144,7 @@ module BSV
|
|
|
144
144
|
# Deserialise a transaction from binary data.
|
|
145
145
|
#
|
|
146
146
|
# @param data [String] raw binary transaction
|
|
147
|
-
# @return [Transaction] the parsed transaction
|
|
147
|
+
# @return [Transaction::Tx] the parsed transaction
|
|
148
148
|
def self.from_binary(data)
|
|
149
149
|
raise ArgumentError, "truncated transaction: need at least 10 bytes, got #{data.bytesize}" if data.bytesize < 10
|
|
150
150
|
|
|
@@ -182,7 +182,7 @@ module BSV
|
|
|
182
182
|
# Deserialise a transaction from a hex string.
|
|
183
183
|
#
|
|
184
184
|
# @param hex [String] hex-encoded transaction
|
|
185
|
-
# @return [Transaction] the parsed transaction
|
|
185
|
+
# @return [Transaction::Tx] the parsed transaction
|
|
186
186
|
def self.from_hex(hex)
|
|
187
187
|
from_binary(BSV::Primitives::Hex.decode(hex, name: 'transaction hex'))
|
|
188
188
|
end
|
|
@@ -190,7 +190,7 @@ module BSV
|
|
|
190
190
|
# Deserialise a transaction from Extended Format (BRC-30) binary data.
|
|
191
191
|
#
|
|
192
192
|
# @param data [String] raw EF binary
|
|
193
|
-
# @return [Transaction] the parsed transaction with source data on inputs
|
|
193
|
+
# @return [Transaction::Tx] the parsed transaction with source data on inputs
|
|
194
194
|
# @raise [ArgumentError] if the EF marker is invalid
|
|
195
195
|
def self.from_ef(data)
|
|
196
196
|
raise ArgumentError, "truncated EF transaction: need at least 10 bytes, got #{data.bytesize}" if data.bytesize < 10
|
|
@@ -250,7 +250,7 @@ module BSV
|
|
|
250
250
|
# Deserialise a transaction from an Extended Format hex string.
|
|
251
251
|
#
|
|
252
252
|
# @param hex [String] hex-encoded EF transaction
|
|
253
|
-
# @return [Transaction] the parsed transaction with source data on inputs
|
|
253
|
+
# @return [Transaction::Tx] the parsed transaction with source data on inputs
|
|
254
254
|
def self.from_ef_hex(hex)
|
|
255
255
|
from_ef(BSV::Primitives::Hex.decode(hex, name: 'EF transaction hex'))
|
|
256
256
|
end
|
|
@@ -260,7 +260,7 @@ module BSV
|
|
|
260
260
|
#
|
|
261
261
|
# @param data [String] binary data containing the transaction
|
|
262
262
|
# @param offset [Integer] byte offset to start reading from
|
|
263
|
-
# @return [Array(Transaction, Integer)] the transaction and bytes consumed
|
|
263
|
+
# @return [Array(Transaction::Tx, Integer)] the transaction and bytes consumed
|
|
264
264
|
def self.from_binary_with_offset(data, offset = 0)
|
|
265
265
|
if data.bytesize < offset + 10
|
|
266
266
|
raise ArgumentError, "truncated transaction: need at least 10 bytes at offset #{offset}, got #{data.bytesize - offset}"
|
|
@@ -331,7 +331,7 @@ module BSV
|
|
|
331
331
|
bump_index_by_height = build_beef_bumps(beef, ancestors)
|
|
332
332
|
BSV.logger&.debug do
|
|
333
333
|
proven = ancestors.count(&:merkle_path)
|
|
334
|
-
"[
|
|
334
|
+
"[Tx] BEEF: #{ancestors.length} ancestors, #{proven} proven " \
|
|
335
335
|
"across #{bump_index_by_height.length} block heights"
|
|
336
336
|
end
|
|
337
337
|
|
|
@@ -370,7 +370,7 @@ module BSV
|
|
|
370
370
|
# +wire_source_transactions+ pass in +Beef.from_binary+.
|
|
371
371
|
#
|
|
372
372
|
# @param data [String] raw BEEF binary
|
|
373
|
-
# @return [Transaction, nil] the subject transaction with ancestry wired,
|
|
373
|
+
# @return [Transaction::Tx, nil] the subject transaction with ancestry wired,
|
|
374
374
|
# or nil if the BEEF is empty or contains no raw transaction entries
|
|
375
375
|
def self.from_beef(data)
|
|
376
376
|
beef = Beef.from_binary(data)
|
|
@@ -384,7 +384,7 @@ module BSV
|
|
|
384
384
|
# Parse a BEEF hex string and return the subject transaction.
|
|
385
385
|
#
|
|
386
386
|
# @param hex [String] hex-encoded BEEF
|
|
387
|
-
# @return [Transaction, nil] the subject transaction with ancestry wired,
|
|
387
|
+
# @return [Transaction::Tx, nil] the subject transaction with ancestry wired,
|
|
388
388
|
# or nil if the BEEF is empty or contains no raw transaction entries
|
|
389
389
|
def self.from_beef_hex(hex)
|
|
390
390
|
from_beef(BSV::Primitives::Hex.decode(hex, name: 'BEEF hex'))
|
|
@@ -400,7 +400,7 @@ module BSV
|
|
|
400
400
|
# @return [String] 32-byte transaction ID in wire byte order
|
|
401
401
|
def wtxid
|
|
402
402
|
id = BSV::Primitives::Digest.sha256d(to_binary)
|
|
403
|
-
BSV.logger&.debug { "[
|
|
403
|
+
BSV.logger&.debug { "[Tx] wtxid computed (dtxid=#{id.reverse.unpack1('H*')})" }
|
|
404
404
|
id
|
|
405
405
|
end
|
|
406
406
|
|
|
@@ -622,7 +622,7 @@ module BSV
|
|
|
622
622
|
# - +:script_failure+ — Ruby raises; TS/Python return +false+; Go also propagates errors
|
|
623
623
|
# - +:missing_source+ — Ruby raises; consistent with TS/Go/Python (all raise/error)
|
|
624
624
|
#
|
|
625
|
-
# @param chain_tracker [ChainTracker] chain tracker for merkle root validation
|
|
625
|
+
# @param chain_tracker [Transaction::ChainTracker] chain tracker for merkle root validation
|
|
626
626
|
# @param fee_model [FeeModel, nil] optional fee model to validate the root transaction's fee
|
|
627
627
|
# @return [true] on successful verification
|
|
628
628
|
# @raise [VerificationError] with code +:invalid_merkle_proof+ if a merkle proof is invalid
|
|
@@ -729,7 +729,7 @@ module BSV
|
|
|
729
729
|
# @return [Integer] estimated fee in satoshis (rounded up)
|
|
730
730
|
def estimated_fee(satoshis_per_byte: 0.1)
|
|
731
731
|
unless self.class.instance_variable_get(:@_estimated_fee_warned)
|
|
732
|
-
warn '[DEPRECATION] BSV::Transaction::
|
|
732
|
+
warn '[DEPRECATION] BSV::Transaction::Tx#estimated_fee is deprecated. ' \
|
|
733
733
|
'Use BSV::Transaction::FeeModels::SatoshisPerKilobyte.new.compute_fee(tx) instead.', uplevel: 1
|
|
734
734
|
self.class.instance_variable_set(:@_estimated_fee_warned, true)
|
|
735
735
|
end
|
|
@@ -806,7 +806,7 @@ module BSV
|
|
|
806
806
|
# is required. Otherwise, requires a wired +source_transaction+ and a
|
|
807
807
|
# valid output at +prev_tx_out_index+.
|
|
808
808
|
#
|
|
809
|
-
# @param input [TransactionInput]
|
|
809
|
+
# @param input [Transaction::TransactionInput]
|
|
810
810
|
# @param idx [Integer] input index, used in error messages
|
|
811
811
|
# @return [TransactionOutput, nil]
|
|
812
812
|
def ef_source_output(input, idx)
|
|
@@ -913,12 +913,12 @@ module BSV
|
|
|
913
913
|
|
|
914
914
|
if tx.merkle_path
|
|
915
915
|
BSV.logger&.debug do
|
|
916
|
-
"[
|
|
916
|
+
"[Tx] ancestor: #{tx.dtxid_hex} proven at height #{tx.merkle_path.block_height} (leaf stop)"
|
|
917
917
|
end
|
|
918
918
|
else
|
|
919
919
|
tx.inputs.each_with_index do |input, idx|
|
|
920
920
|
unless input.source_transaction
|
|
921
|
-
BSV.logger&.debug { "[
|
|
921
|
+
BSV.logger&.debug { "[Tx] ancestor: #{tx.dtxid_hex} input #{idx} has no source_transaction (skipped)" }
|
|
922
922
|
next
|
|
923
923
|
end
|
|
924
924
|
|
|
@@ -14,7 +14,7 @@ module BSV
|
|
|
14
14
|
class UnlockingScriptTemplate
|
|
15
15
|
# Generate the unlocking script for a transaction input.
|
|
16
16
|
#
|
|
17
|
-
# @param _tx [Transaction] the transaction being signed
|
|
17
|
+
# @param _tx [Transaction::Tx] the transaction being signed
|
|
18
18
|
# @param _input_index [Integer] the input index to sign
|
|
19
19
|
# @return [Script::Script] the generated unlocking script
|
|
20
20
|
# @raise [NotImplementedError] if not overridden by a subclass
|
|
@@ -24,7 +24,7 @@ module BSV
|
|
|
24
24
|
|
|
25
25
|
# Estimate the unlocking script length in bytes (for fee estimation).
|
|
26
26
|
#
|
|
27
|
-
# @param _tx [Transaction] the transaction
|
|
27
|
+
# @param _tx [Transaction::Tx] the transaction
|
|
28
28
|
# @param _input_index [Integer] the input index
|
|
29
29
|
# @return [Integer] estimated script length in bytes
|
|
30
30
|
# @raise [NotImplementedError] if not overridden by a subclass
|
data/lib/bsv/transaction.rb
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
module BSV
|
|
4
4
|
# Transaction building, signing, serialisation, and verification.
|
|
5
5
|
#
|
|
6
|
-
# Provides the {Transaction::
|
|
6
|
+
# Provides the {Transaction::Tx} class for constructing and signing
|
|
7
7
|
# transactions, {Transaction::Beef} for BEEF (BRC-62/95/96) serialisation,
|
|
8
8
|
# {Transaction::MerklePath} for BRC-74 merkle proofs, and
|
|
9
9
|
# {Transaction::Sighash} constants for BIP-143 sighash computation.
|
|
@@ -19,8 +19,9 @@ module BSV
|
|
|
19
19
|
autoload :ChainTracker, 'bsv/transaction/chain_tracker'
|
|
20
20
|
autoload :ChainTrackers, 'bsv/transaction/chain_trackers'
|
|
21
21
|
autoload :Beef, 'bsv/transaction/beef'
|
|
22
|
+
autoload :BeefParty, 'bsv/transaction/beef_party'
|
|
22
23
|
autoload :UnlockingScriptTemplate, 'bsv/transaction/unlocking_script_template'
|
|
23
24
|
autoload :P2PKH, 'bsv/transaction/p2pkh'
|
|
24
|
-
autoload :
|
|
25
|
+
autoload :Tx, 'bsv/transaction/tx'
|
|
25
26
|
end
|
|
26
27
|
end
|
data/lib/bsv/version.rb
CHANGED
|
@@ -34,6 +34,19 @@ module BSV
|
|
|
34
34
|
@identity_key ||= @root_key.public_key.to_hex
|
|
35
35
|
end
|
|
36
36
|
|
|
37
|
+
# Returns the identity public key as a 33-byte compressed binary string.
|
|
38
|
+
#
|
|
39
|
+
# Pubkeys are hex-canonical in this SDK (see ADR-001 — the documented
|
|
40
|
+
# exception to binary-internal), so {#identity_key} (hex) is the
|
|
41
|
+
# default. This binary accessor exists for the rare sites that need
|
|
42
|
+
# raw bytes (e.g. feeding +BSV::Primitives::Hash#hash160+) without
|
|
43
|
+
# round-tripping hex → binary at each call.
|
|
44
|
+
#
|
|
45
|
+
# @return [String] 33-byte compressed public key binary
|
|
46
|
+
def identity_key_bytes
|
|
47
|
+
@identity_key_bytes ||= @root_key.public_key.compressed
|
|
48
|
+
end
|
|
49
|
+
|
|
37
50
|
# Derives a public key using BRC-42 key derivation.
|
|
38
51
|
#
|
|
39
52
|
# @param protocol_id [Array] [security_level, protocol_name]
|
|
@@ -167,7 +167,7 @@ module BSV
|
|
|
167
167
|
priv_key = @key_deriver.derive_private_key(protocol_id, key_id, counterparty)
|
|
168
168
|
|
|
169
169
|
hash = if hash_to_directly_sign
|
|
170
|
-
|
|
170
|
+
validate_hash_32!(hash_to_directly_sign, 'hash_to_directly_sign')
|
|
171
171
|
else
|
|
172
172
|
BSV::Primitives::Digest.sha256(bytes_to_string(data))
|
|
173
173
|
end
|
|
@@ -203,7 +203,7 @@ module BSV
|
|
|
203
203
|
)
|
|
204
204
|
|
|
205
205
|
hash = if hash_to_directly_verify
|
|
206
|
-
|
|
206
|
+
validate_hash_32!(hash_to_directly_verify, 'hash_to_directly_verify')
|
|
207
207
|
else
|
|
208
208
|
BSV::Primitives::Digest.sha256(bytes_to_string(data))
|
|
209
209
|
end
|
|
@@ -347,6 +347,16 @@ module BSV
|
|
|
347
347
|
bytes.is_a?(String) ? bytes.b : bytes.pack('C*')
|
|
348
348
|
end
|
|
349
349
|
|
|
350
|
+
# Coerce a hash parameter to a 32-byte binary string, raising
|
|
351
|
+
# InvalidParameterError if the input has the wrong length. Accepts
|
|
352
|
+
# either a binary String or an Array<Integer> per BRC-100 convention.
|
|
353
|
+
def validate_hash_32!(value, name)
|
|
354
|
+
bytes = bytes_to_string(value)
|
|
355
|
+
raise InvalidParameterError.new(name, "exactly 32 bytes, got #{bytes.bytesize}") unless bytes.bytesize == 32
|
|
356
|
+
|
|
357
|
+
bytes
|
|
358
|
+
end
|
|
359
|
+
|
|
350
360
|
# Normalise a public key argument to a 66-character compressed hex string.
|
|
351
361
|
# Accepts either a 33-byte binary string or a 66-character hex string.
|
|
352
362
|
def normalise_pubkey_hex(value)
|
|
@@ -30,6 +30,13 @@ module BSV
|
|
|
30
30
|
end
|
|
31
31
|
raise BSV::Wallet::InvalidParameterError.new('data or hash_to_directly_sign', 'present') unless data || hash
|
|
32
32
|
|
|
33
|
+
if hash && hash.bytesize != HASH_SIZE
|
|
34
|
+
raise BSV::Wallet::InvalidParameterError.new(
|
|
35
|
+
'hash_to_directly_sign',
|
|
36
|
+
"exactly #{HASH_SIZE} bytes, got #{hash.bytesize}"
|
|
37
|
+
)
|
|
38
|
+
end
|
|
39
|
+
|
|
33
40
|
w = BSV::Wallet::Wire::Writer.new
|
|
34
41
|
Common.write_key_related_params(
|
|
35
42
|
w,
|
|
@@ -66,6 +66,10 @@ module BSV
|
|
|
66
66
|
|
|
67
67
|
# Result wire layout:
|
|
68
68
|
# [33 bytes: compressed public key]
|
|
69
|
+
#
|
|
70
|
+
# The wire bytes are 33-byte compressed binary by the BRC-103 protocol,
|
|
71
|
+
# but the Ruby return shape is hex per the BRC-100 PubKeyHex contract
|
|
72
|
+
# (ADR-001 — pubkeys are the documented hex exception to binary-internal).
|
|
69
73
|
module Result
|
|
70
74
|
module_function
|
|
71
75
|
|
|
@@ -77,7 +81,7 @@ module BSV
|
|
|
77
81
|
def deserialize(bytes)
|
|
78
82
|
raise ArgumentError, "public key too short: #{bytes.bytesize}" if bytes.bytesize < PUBKEY_SIZE
|
|
79
83
|
|
|
80
|
-
{ public_key: bytes.byteslice(0, PUBKEY_SIZE) }
|
|
84
|
+
{ public_key: bytes.byteslice(0, PUBKEY_SIZE).unpack1('H*') }
|
|
81
85
|
end
|
|
82
86
|
end
|
|
83
87
|
end
|
|
@@ -75,11 +75,14 @@ module BSV
|
|
|
75
75
|
w.buf
|
|
76
76
|
end
|
|
77
77
|
|
|
78
|
+
# Pubkey fields are returned as 66-char hex per the BRC-100 PubKeyHex
|
|
79
|
+
# contract (ADR-001 — pubkeys are the documented hex exception to
|
|
80
|
+
# binary-internal). Wire bytes stay 33-byte compressed binary.
|
|
78
81
|
def deserialize(bytes)
|
|
79
82
|
r = BSV::Wallet::Wire::Reader.new(bytes)
|
|
80
|
-
prover = r.read_bytes(PUBKEY_SIZE)
|
|
81
|
-
verifier = r.read_bytes(PUBKEY_SIZE)
|
|
82
|
-
counterparty = r.read_bytes(PUBKEY_SIZE)
|
|
83
|
+
prover = r.read_bytes(PUBKEY_SIZE).unpack1('H*')
|
|
84
|
+
verifier = r.read_bytes(PUBKEY_SIZE).unpack1('H*')
|
|
85
|
+
counterparty = r.read_bytes(PUBKEY_SIZE).unpack1('H*')
|
|
83
86
|
revelation_time = r.read_str_with_varint_len
|
|
84
87
|
el_len = r.read_varint
|
|
85
88
|
encrypted_linkage = r.read_bytes(el_len)
|
|
@@ -78,11 +78,14 @@ module BSV
|
|
|
78
78
|
w.buf
|
|
79
79
|
end
|
|
80
80
|
|
|
81
|
+
# Pubkey fields are returned as 66-char hex per the BRC-100 PubKeyHex
|
|
82
|
+
# contract (ADR-001 — pubkeys are the documented hex exception to
|
|
83
|
+
# binary-internal). Wire bytes stay 33-byte compressed binary.
|
|
81
84
|
def deserialize(bytes)
|
|
82
85
|
r = BSV::Wallet::Wire::Reader.new(bytes)
|
|
83
|
-
prover = r.read_bytes(PUBKEY_SIZE)
|
|
84
|
-
verifier = r.read_bytes(PUBKEY_SIZE)
|
|
85
|
-
counterparty = r.read_bytes(PUBKEY_SIZE)
|
|
86
|
+
prover = r.read_bytes(PUBKEY_SIZE).unpack1('H*')
|
|
87
|
+
verifier = r.read_bytes(PUBKEY_SIZE).unpack1('H*')
|
|
88
|
+
counterparty = r.read_bytes(PUBKEY_SIZE).unpack1('H*')
|
|
86
89
|
protocol_id = Common.read_protocol(r)
|
|
87
90
|
key_id_len = r.read_varint
|
|
88
91
|
key_id = r.read_bytes(key_id_len).force_encoding('UTF-8')
|
|
@@ -34,6 +34,13 @@ module BSV
|
|
|
34
34
|
raise BSV::Wallet::InvalidParameterError.new('data or hash_to_directly_verify', 'present') unless data || hash
|
|
35
35
|
raise BSV::Wallet::InvalidParameterError.new('signature', 'present') unless sig
|
|
36
36
|
|
|
37
|
+
if hash && hash.bytesize != HASH_SIZE
|
|
38
|
+
raise BSV::Wallet::InvalidParameterError.new(
|
|
39
|
+
'hash_to_directly_verify',
|
|
40
|
+
"exactly #{HASH_SIZE} bytes, got #{hash.bytesize}"
|
|
41
|
+
)
|
|
42
|
+
end
|
|
43
|
+
|
|
37
44
|
w = BSV::Wallet::Wire::Writer.new
|
|
38
45
|
Common.write_key_related_params(
|
|
39
46
|
w,
|
data/lib/bsv-sdk.rb
CHANGED
|
@@ -26,6 +26,8 @@ module BSV
|
|
|
26
26
|
autoload :Identity, 'bsv/identity'
|
|
27
27
|
autoload :Registry, 'bsv/registry'
|
|
28
28
|
autoload :MCP, 'bsv/mcp'
|
|
29
|
+
autoload :Storage, 'bsv/storage'
|
|
30
|
+
autoload :KVStore, 'bsv/kv_store'
|
|
29
31
|
|
|
30
32
|
# Wallet is loaded eagerly to avoid load-path shadowing when bsv-wallet is
|
|
31
33
|
# also in the bundle (bsv-wallet/lib/bsv/wallet.rb would otherwise win).
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: bsv-sdk
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.25.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Simon Bettison
|
|
@@ -85,6 +85,11 @@ files:
|
|
|
85
85
|
- lib/bsv/identity/constants.rb
|
|
86
86
|
- lib/bsv/identity/identity_parser.rb
|
|
87
87
|
- lib/bsv/identity/types.rb
|
|
88
|
+
- lib/bsv/kv_store.rb
|
|
89
|
+
- lib/bsv/kv_store/entry.rb
|
|
90
|
+
- lib/bsv/kv_store/global.rb
|
|
91
|
+
- lib/bsv/kv_store/interpreter.rb
|
|
92
|
+
- lib/bsv/kv_store/token.rb
|
|
88
93
|
- lib/bsv/mcp.rb
|
|
89
94
|
- lib/bsv/mcp/config.rb
|
|
90
95
|
- lib/bsv/mcp/server.rb
|
|
@@ -118,6 +123,7 @@ files:
|
|
|
118
123
|
- lib/bsv/overlay/broadcast_facilitator.rb
|
|
119
124
|
- lib/bsv/overlay/constants.rb
|
|
120
125
|
- lib/bsv/overlay/errors.rb
|
|
126
|
+
- lib/bsv/overlay/historian.rb
|
|
121
127
|
- lib/bsv/overlay/host_reputation_tracker.rb
|
|
122
128
|
- lib/bsv/overlay/lookup_facilitator.rb
|
|
123
129
|
- lib/bsv/overlay/lookup_resolver.rb
|
|
@@ -152,6 +158,7 @@ files:
|
|
|
152
158
|
- lib/bsv/registry/constants.rb
|
|
153
159
|
- lib/bsv/registry/types.rb
|
|
154
160
|
- lib/bsv/script.rb
|
|
161
|
+
- lib/bsv/script/bip276.rb
|
|
155
162
|
- lib/bsv/script/builder.rb
|
|
156
163
|
- lib/bsv/script/chunk.rb
|
|
157
164
|
- lib/bsv/script/interpreter/error.rb
|
|
@@ -169,8 +176,13 @@ files:
|
|
|
169
176
|
- lib/bsv/script/push_drop_template.rb
|
|
170
177
|
- lib/bsv/script/script.rb
|
|
171
178
|
- lib/bsv/secp256k1_native.bundle
|
|
179
|
+
- lib/bsv/storage.rb
|
|
180
|
+
- lib/bsv/storage/downloader.rb
|
|
181
|
+
- lib/bsv/storage/errors.rb
|
|
182
|
+
- lib/bsv/storage/utils.rb
|
|
172
183
|
- lib/bsv/transaction.rb
|
|
173
184
|
- lib/bsv/transaction/beef.rb
|
|
185
|
+
- lib/bsv/transaction/beef_party.rb
|
|
174
186
|
- lib/bsv/transaction/chain_tracker.rb
|
|
175
187
|
- lib/bsv/transaction/chain_trackers.rb
|
|
176
188
|
- lib/bsv/transaction/chain_trackers/whats_on_chain.rb
|
|
@@ -181,9 +193,9 @@ files:
|
|
|
181
193
|
- lib/bsv/transaction/merkle_path.rb
|
|
182
194
|
- lib/bsv/transaction/p2pkh.rb
|
|
183
195
|
- lib/bsv/transaction/sighash.rb
|
|
184
|
-
- lib/bsv/transaction/transaction.rb
|
|
185
196
|
- lib/bsv/transaction/transaction_input.rb
|
|
186
197
|
- lib/bsv/transaction/transaction_output.rb
|
|
198
|
+
- lib/bsv/transaction/tx.rb
|
|
187
199
|
- lib/bsv/transaction/unlocking_script_template.rb
|
|
188
200
|
- lib/bsv/transaction/var_int.rb
|
|
189
201
|
- lib/bsv/transaction/verification_error.rb
|