bsv-wallet 0.2.0 → 0.2.1
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
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 640f3d2d34c8ef7a9acbaa3680904bae8507d091b251213fcb1fd7d3dd4e1796
|
|
4
|
+
data.tar.gz: f0fdf19e4128bace6be1dd7a09c0c9bf0c63a5a9bb4699e1c3736b8263d5ffc1
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: e46a2a8781c325707ec1bfa6de79bb7f1c84ea8a5b904237ad1080d9cf2d22a3ac80d31111304bd9ed3138bd9418ba0efe2d77f0c0554476a011ef7308f68ccb
|
|
7
|
+
data.tar.gz: a238543de60ded0e911eb564c34fb47f4b5367c0570fd4d0fabefa02327caa2141ff9ba6d09308e6478692541446ae367934d095d321421c7ae13e02ac48fd39
|
|
@@ -91,6 +91,7 @@ module BSV
|
|
|
91
91
|
|
|
92
92
|
def filter_outputs(query)
|
|
93
93
|
results = @outputs
|
|
94
|
+
results = results.select { |o| o[:outpoint] == query[:outpoint] } if query[:outpoint]
|
|
94
95
|
results = results.select { |o| o[:basket] == query[:basket] } if query[:basket]
|
|
95
96
|
if query[:tags]
|
|
96
97
|
mode = query[:tag_query_mode] || 'any'
|
|
@@ -45,7 +45,7 @@ module BSV
|
|
|
45
45
|
# @option args [Boolean] :for_self derive from own identity
|
|
46
46
|
# @param originator [String, nil] FQDN of the originating application
|
|
47
47
|
# @return [Hash] { public_key: String } hex-encoded compressed public key
|
|
48
|
-
def get_public_key(args,
|
|
48
|
+
def get_public_key(args, originator: nil)
|
|
49
49
|
if args[:identity_key]
|
|
50
50
|
{ public_key: @key_deriver.identity_key }
|
|
51
51
|
else
|
|
@@ -69,7 +69,7 @@ module BSV
|
|
|
69
69
|
# @option args [String] :counterparty public key hex, 'self', or 'anyone'
|
|
70
70
|
# @param originator [String, nil] FQDN of the originating application
|
|
71
71
|
# @return [Hash] { ciphertext: Array<Integer> }
|
|
72
|
-
def encrypt(args,
|
|
72
|
+
def encrypt(args, originator: nil)
|
|
73
73
|
sym_key = derive_sym_key(args)
|
|
74
74
|
ciphertext = sym_key.encrypt(bytes_to_string(args[:plaintext]))
|
|
75
75
|
{ ciphertext: string_to_bytes(ciphertext) }
|
|
@@ -84,7 +84,7 @@ module BSV
|
|
|
84
84
|
# @option args [String] :counterparty public key hex, 'self', or 'anyone'
|
|
85
85
|
# @param originator [String, nil] FQDN of the originating application
|
|
86
86
|
# @return [Hash] { plaintext: Array<Integer> }
|
|
87
|
-
def decrypt(args,
|
|
87
|
+
def decrypt(args, originator: nil)
|
|
88
88
|
sym_key = derive_sym_key(args)
|
|
89
89
|
plaintext = sym_key.decrypt(bytes_to_string(args[:ciphertext]))
|
|
90
90
|
{ plaintext: string_to_bytes(plaintext) }
|
|
@@ -99,7 +99,7 @@ module BSV
|
|
|
99
99
|
# @option args [String] :counterparty public key hex, 'self', or 'anyone'
|
|
100
100
|
# @param originator [String, nil] FQDN of the originating application
|
|
101
101
|
# @return [Hash] { hmac: Array<Integer> }
|
|
102
|
-
def create_hmac(args,
|
|
102
|
+
def create_hmac(args, originator: nil)
|
|
103
103
|
sym_key = derive_sym_key(args)
|
|
104
104
|
hmac = BSV::Primitives::Digest.hmac_sha256(sym_key.to_bytes, bytes_to_string(args[:data]))
|
|
105
105
|
{ hmac: string_to_bytes(hmac) }
|
|
@@ -116,7 +116,7 @@ module BSV
|
|
|
116
116
|
# @param originator [String, nil] FQDN of the originating application
|
|
117
117
|
# @return [Hash] { valid: true }
|
|
118
118
|
# @raise [InvalidHmacError] if the HMAC does not match
|
|
119
|
-
def verify_hmac(args,
|
|
119
|
+
def verify_hmac(args, originator: nil)
|
|
120
120
|
sym_key = derive_sym_key(args)
|
|
121
121
|
expected = BSV::Primitives::Digest.hmac_sha256(sym_key.to_bytes, bytes_to_string(args[:data]))
|
|
122
122
|
provided = bytes_to_string(args[:hmac])
|
|
@@ -140,7 +140,7 @@ module BSV
|
|
|
140
140
|
# @option args [String] :counterparty public key hex, 'self', or 'anyone'
|
|
141
141
|
# @param originator [String, nil] FQDN of the originating application
|
|
142
142
|
# @return [Hash] { signature: Array<Integer> } DER-encoded signature as byte array
|
|
143
|
-
def create_signature(args,
|
|
143
|
+
def create_signature(args, originator: nil)
|
|
144
144
|
counterparty = args[:counterparty] || 'self'
|
|
145
145
|
priv_key = @key_deriver.derive_private_key(args[:protocol_id], args[:key_id], counterparty)
|
|
146
146
|
|
|
@@ -170,7 +170,7 @@ module BSV
|
|
|
170
170
|
# @param originator [String, nil] FQDN of the originating application
|
|
171
171
|
# @return [Hash] { valid: true }
|
|
172
172
|
# @raise [InvalidSignatureError] if the signature does not verify
|
|
173
|
-
def verify_signature(args,
|
|
173
|
+
def verify_signature(args, originator: nil)
|
|
174
174
|
counterparty = args[:counterparty] || 'self'
|
|
175
175
|
for_self = args[:for_self] || false
|
|
176
176
|
|
|
@@ -208,7 +208,7 @@ module BSV
|
|
|
208
208
|
# @param originator [String, nil] FQDN of the originating application
|
|
209
209
|
# @return [Hash] with :prover, :verifier, :counterparty, :revelation_time,
|
|
210
210
|
# :encrypted_linkage, :encrypted_linkage_proof
|
|
211
|
-
def reveal_counterparty_key_linkage(args,
|
|
211
|
+
def reveal_counterparty_key_linkage(args, originator: nil)
|
|
212
212
|
counterparty = args[:counterparty]
|
|
213
213
|
verifier = args[:verifier]
|
|
214
214
|
|
|
@@ -270,7 +270,7 @@ module BSV
|
|
|
270
270
|
# @param originator [String, nil] FQDN of the originating application
|
|
271
271
|
# @return [Hash] with :prover, :verifier, :counterparty, :protocol_id, :key_id,
|
|
272
272
|
# :encrypted_linkage, :encrypted_linkage_proof, :proof_type
|
|
273
|
-
def reveal_specific_key_linkage(args,
|
|
273
|
+
def reveal_specific_key_linkage(args, originator: nil)
|
|
274
274
|
counterparty = args[:counterparty]
|
|
275
275
|
verifier = args[:verifier]
|
|
276
276
|
protocol_id = args[:protocol_id]
|
|
@@ -483,8 +483,17 @@ module BSV
|
|
|
483
483
|
)
|
|
484
484
|
|
|
485
485
|
wire_source(input, txid_hex, output_index, beef) if beef
|
|
486
|
-
|
|
487
|
-
|
|
486
|
+
wire_source_from_storage(input, spec[:outpoint]) if input.source_satoshis.nil? || input.source_locking_script.nil?
|
|
487
|
+
|
|
488
|
+
case spec[:unlocking_script]
|
|
489
|
+
when BSV::Transaction::UnlockingScriptTemplate
|
|
490
|
+
input.unlocking_script_template = spec[:unlocking_script]
|
|
491
|
+
when String
|
|
492
|
+
input.unlocking_script = BSV::Script::Script.from_hex(spec[:unlocking_script])
|
|
493
|
+
when nil then nil
|
|
494
|
+
else
|
|
495
|
+
raise InvalidParameterError.new('unlocking_script', 'a hex String or UnlockingScriptTemplate')
|
|
496
|
+
end
|
|
488
497
|
|
|
489
498
|
tx.add_input(input)
|
|
490
499
|
end
|
|
@@ -504,6 +513,15 @@ module BSV
|
|
|
504
513
|
input.source_locking_script = source_tx.outputs[output_index].locking_script
|
|
505
514
|
end
|
|
506
515
|
|
|
516
|
+
def wire_source_from_storage(input, outpoint)
|
|
517
|
+
results = @storage.find_outputs({ outpoint: outpoint, limit: 1 })
|
|
518
|
+
stored = results.first
|
|
519
|
+
return unless stored
|
|
520
|
+
|
|
521
|
+
input.source_satoshis = stored[:satoshis]
|
|
522
|
+
input.source_locking_script = BSV::Script::Script.from_hex(stored[:locking_script])
|
|
523
|
+
end
|
|
524
|
+
|
|
507
525
|
def build_outputs(tx, outputs)
|
|
508
526
|
outputs.each do |spec|
|
|
509
527
|
output = BSV::Transaction::TransactionOutput.new(
|
|
@@ -540,6 +558,7 @@ module BSV
|
|
|
540
558
|
end
|
|
541
559
|
|
|
542
560
|
def finalize_action(tx, args)
|
|
561
|
+
tx.sign_all if tx.inputs.any?(&:unlocking_script_template)
|
|
543
562
|
txid = tx.txid_hex
|
|
544
563
|
status = args.dig(:options, :no_send) ? 'nosend' : 'completed'
|
|
545
564
|
|
metadata
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: bsv-wallet
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.2.
|
|
4
|
+
version: 0.2.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Simon Bettison
|
|
8
8
|
bindir: bin
|
|
9
9
|
cert_chain: []
|
|
10
|
-
date: 2026-04-
|
|
10
|
+
date: 2026-04-05 00:00:00.000000000 Z
|
|
11
11
|
dependencies:
|
|
12
12
|
- !ruby/object:Gem::Dependency
|
|
13
13
|
name: base64
|