bsv-wallet-postgres 0.4.0 → 0.6.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 69980501d8a03bd6552190800aba40a65f3c34d2b6633a3a59d58030a11d54e3
4
- data.tar.gz: 7ee7f4c26fc294d9f227cdae83e3c9d9dcc7cce64592dda289db8c223c6b34ec
3
+ metadata.gz: 8c61ec2b4c48854fcba55eeb47bb1d7b3e87129fbf01769e07fc6c30661d1a26
4
+ data.tar.gz: 58f953f0a5d5fb10fb20259d821dc604ba842f8210f53d6f55be12e760ed927c
5
5
  SHA512:
6
- metadata.gz: 5fa70d4686c6f55d782578f9f7c2b6bb290c113ebdd2a8e05a11d8062e56ba21337a2ce3bf8d96af32a13ac60d05d8328f6608d560f6b2dce3b1514045f6b1ef
7
- data.tar.gz: 371d0d3ccc53cf8c247aed4fa449a232b0a9f3ce46e8c7ebfbc311f5f23eae7043a186e0678c14fe5f3693ced12e3458965d3a93e471fcdbc2f46a1661961eac
6
+ metadata.gz: 5b51ceb9562b914012b2a86ee1c236501f9f714583a55d46a977e6418f0cf490497d7a42349210a0e0ee1436179617d45ded1afca815f0770d563aad8bf4051a
7
+ data.tar.gz: 6f219ead476cf621c654e9692f955962f96f55d02b900bb03f2adfe1549b331abd714036e4af7ef32f1c322e72c452a64ebebdcda46cedc9fc239e601cc0bf5f
data/CHANGELOG.md CHANGED
@@ -5,6 +5,28 @@ All notable changes to the `bsv-wallet-postgres` gem are documented here.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/)
6
6
  and this gem adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## 0.6.0 — 2026-04-21
9
+
10
+ ### Added
11
+ - `update_output_basket` implementation on `PostgresStore`, matching the new Store interface method
12
+
13
+ ### Changed
14
+ - Updated for bsv-wallet 0.10.0 namespace changes (`Interface`, `Client`, `Store`)
15
+
16
+ ## 0.5.0 — 2026-04-16
17
+
18
+ ### Changed — **Breaking**
19
+
20
+ - `SolidQueueAdapter` now sets the wallet action status to `'unproven'` instead of `'completed'` on successful broadcast. Aligns with the status taxonomy change in bsv-wallet 0.9.0 (HLR #455). The `wallet_broadcast_jobs` row status is unchanged (job queue lifecycle is a separate domain).
21
+
22
+ ### Added
23
+
24
+ - `BroadcastQueue#broadcast_enabled?` interface method; `SolidQueueAdapter` returns `true` (broadcaster required at construction time). Enables `WalletClient#broadcast_enabled?` to detect a queue-embedded broadcaster.
25
+
26
+ ### Changed
27
+
28
+ - Minimum `bsv-wallet` version raised from `>= 0.6.0` to `>= 0.9.0`. Required for the new status taxonomy and `broadcast_enabled?` interface.
29
+
8
30
  ## 0.4.0 — 2026-04-12
9
31
 
10
32
  ### Added
@@ -2,7 +2,7 @@
2
2
 
3
3
  # Initial wallet schema for BSV::Wallet::PostgresStore.
4
4
  #
5
- # Five tables, all indexed for the query patterns the StorageAdapter
5
+ # Five tables, all indexed for the query patterns the Store
6
6
  # interface exposes. JSONB blobs hold the full hash the SDK stored so
7
7
  # adding fields to bsv-wallet's output/action/certificate records does
8
8
  # not require a schema change — only the fields we actively filter on
@@ -8,7 +8,7 @@ module BSV
8
8
  module Wallet
9
9
  # PostgreSQL-backed storage adapter for +BSV::Wallet+.
10
10
  #
11
- # Implements the full {StorageAdapter} interface against a Sequel
11
+ # Implements the full {Store} interface against a Sequel
12
12
  # +Database+ object. Survives process restarts, scales to multiple
13
13
  # instances, and is thread-safe via Sequel's connection pool.
14
14
  #
@@ -19,7 +19,7 @@ module BSV
19
19
  # BSV::Wallet::PostgresStore.migrate!(db)
20
20
  #
21
21
  # store = BSV::Wallet::PostgresStore.new(db)
22
- # wallet = BSV::Wallet::WalletClient.new(key, storage: store)
22
+ # wallet = BSV::Wallet::Client.new(key, storage: store)
23
23
  #
24
24
  # @example Bringing your own migration runner
25
25
  # # Copy lib/bsv/wallet_postgres/migrations/001_create_wallet_tables.rb
@@ -44,7 +44,7 @@ module BSV
44
44
  # * This class is thread-safe because Sequel is — the adapter itself
45
45
  # holds no mutable state beyond the injected database handle.
46
46
  class PostgresStore
47
- include StorageAdapter
47
+ include Interface::Store
48
48
 
49
49
  MIGRATIONS_DIR = File.expand_path('migrations', __dir__)
50
50
 
@@ -236,6 +236,26 @@ module BSV
236
236
  symbolise_keys(row[:data])
237
237
  end
238
238
 
239
+ # Moves an output from one basket to another (metadata-only).
240
+ #
241
+ # Updates both the +basket+ column and the JSONB +data+ blob.
242
+ # Does not affect the output's state or pending metadata.
243
+ #
244
+ # @param outpoint [String] the outpoint identifier
245
+ # @param new_basket [String] the destination basket name
246
+ # @raise [BSV::Wallet::WalletError] if the outpoint is not found
247
+ # @return [Hash] the updated output hash
248
+ def update_output_basket(outpoint, new_basket)
249
+ ds = @db[:wallet_outputs].where(outpoint: outpoint)
250
+ rows_updated = ds.update(
251
+ basket: new_basket,
252
+ data: Sequel.lit("data || jsonb_build_object('basket', ?)", new_basket)
253
+ )
254
+ raise WalletError, "Output not found: #{outpoint}" if rows_updated.zero?
255
+
256
+ symbolise_keys(ds.first[:data])
257
+ end
258
+
239
259
  # Atomically marks a set of outpoints as +:pending+.
240
260
  #
241
261
  # Uses +UPDATE ... WHERE state = 'spendable' ... RETURNING outpoint+ so that
@@ -38,7 +38,7 @@ module BSV
38
38
  # +@running = false+ but before the worker thread exits will remain
39
39
  # +unsent+ until the next +start+.
40
40
  class SolidQueueAdapter
41
- include BSV::Wallet::BroadcastQueue
41
+ include BSV::Wallet::Interface::BroadcastQueue
42
42
 
43
43
  # Default number of seconds between poll cycles.
44
44
  DEFAULT_POLL_INTERVAL = 8
@@ -52,14 +52,14 @@ module BSV
52
52
  MAX_ATTEMPTS = 5
53
53
 
54
54
  # @param db [Sequel::Database] a Sequel database handle (shared with PostgresStore)
55
- # @param storage [StorageAdapter] wallet storage adapter (must not be MemoryStore)
55
+ # @param storage [Store] wallet storage adapter (must not be MemoryStore)
56
56
  # @param broadcaster [#broadcast] broadcaster object
57
57
  # @param poll_interval [Integer] seconds between worker poll cycles
58
58
  # @param stale_threshold [Integer] seconds before a +sending+ job is retried
59
- # @raise [ArgumentError] if +storage+ is a +BSV::Wallet::MemoryStore+
59
+ # @raise [ArgumentError] if +storage+ is a +BSV::Wallet::Store::Memory+
60
60
  # @raise [ArgumentError] if +broadcaster+ is +nil+
61
61
  def initialize(db:, storage:, broadcaster:, poll_interval: DEFAULT_POLL_INTERVAL, stale_threshold: STALE_THRESHOLD)
62
- if storage.is_a?(BSV::Wallet::MemoryStore)
62
+ if storage.is_a?(BSV::Wallet::Store::Memory)
63
63
  raise ArgumentError, 'SolidQueueAdapter requires a persistent storage adapter — MemoryStore is not supported'
64
64
  end
65
65
  raise ArgumentError, 'SolidQueueAdapter requires a broadcaster' if broadcaster.nil?
@@ -82,6 +82,15 @@ module BSV
82
82
  true
83
83
  end
84
84
 
85
+ # Returns +true+ — +SolidQueueAdapter+ requires a broadcaster at
86
+ # construction time (+ArgumentError+ is raised if +nil+ is passed), so
87
+ # broadcast is always available.
88
+ #
89
+ # @return [Boolean]
90
+ def broadcast_enabled?
91
+ !@broadcaster.nil?
92
+ end
93
+
85
94
  # Persists a transaction to the broadcast job queue and returns immediately.
86
95
  #
87
96
  # Inserts a row into +wallet_broadcast_jobs+ with status +unsent+. If a row
@@ -280,8 +289,10 @@ module BSV
280
289
  # Promotes UTXO state after a successful broadcast.
281
290
  #
282
291
  # Marks inputs as +:spent+, change as +:spendable+, and updates the action
283
- # status to +completed+. When outpoints are +nil+ (finalize path), UTXO
284
- # transitions are skipped.
292
+ # status to +unproven+. The transaction has been accepted by the network but
293
+ # is not yet proven on-chain — status advances to +completed+ once a merkle
294
+ # proof arrives. When outpoints are +nil+ (finalize path), UTXO transitions
295
+ # are skipped.
285
296
  #
286
297
  # @param input_outpoints [Array<String>, nil]
287
298
  # @param change_outpoints [Array<String>, nil]
@@ -289,7 +300,7 @@ module BSV
289
300
  def promote(input_outpoints, change_outpoints, txid)
290
301
  Array(input_outpoints).each { |op| @storage.update_output_state(op, :spent) }
291
302
  Array(change_outpoints).each { |op| @storage.update_output_state(op, :spendable) }
292
- @storage.update_action_status(txid, 'completed') if txid
303
+ @storage.update_action_status(txid, 'unproven') if txid
293
304
  end
294
305
 
295
306
  # Rolls back wallet state after a failed broadcast.
@@ -2,6 +2,6 @@
2
2
 
3
3
  module BSV
4
4
  module WalletPostgres
5
- VERSION = '0.4.0'
5
+ VERSION = '0.6.0'
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bsv-wallet-postgres
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Simon Bettison
@@ -15,7 +15,7 @@ dependencies:
15
15
  requirements:
16
16
  - - ">="
17
17
  - !ruby/object:Gem::Version
18
- version: 0.6.0
18
+ version: 0.9.0
19
19
  - - "<"
20
20
  - !ruby/object:Gem::Version
21
21
  version: '1.0'
@@ -25,7 +25,7 @@ dependencies:
25
25
  requirements:
26
26
  - - ">="
27
27
  - !ruby/object:Gem::Version
28
- version: 0.6.0
28
+ version: 0.9.0
29
29
  - - "<"
30
30
  - !ruby/object:Gem::Version
31
31
  version: '1.0'