openreceive-rails 0.4.31 → 0.4.33

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: 7ed29e7ec502193127f157c03582d68ba4bf77b0bb48a891ce8c65b0aa77b3bf
4
- data.tar.gz: c357a325d594f4cc95ed767c6c1fd0f8a887791c4133227bceb381c02ba42247
3
+ metadata.gz: 61419896fdbdc8e75fa7d6a8789637843d65d4072ac7d9c8ac4181214492fdb2
4
+ data.tar.gz: a51b4f85de7fff98e6e02cb3fafd8813187d2988b317cbed9905ab1d569fbaf8
5
5
  SHA512:
6
- metadata.gz: f728ad2516e05b48ac5e16f840c4a9b338fb4514eb4c5a9246c13f1f911092fbe69a204b1a1dfe30ca733ad5c78a067c922d698d4bc398678c7d739f0551a707
7
- data.tar.gz: 5136db0bf7ba725697dfd092455c97ce9c86c9f6ac85ae6c27aa9a41483f16350b3f435955c50ff36d90f47a2f1bcba28e42ee5ce24fb021ce784257123df5f2
6
+ metadata.gz: f916c9564e3d1276829a540e9ee4106b2dbd679f6d6d0096789e8faf7f846767c0cd7eac2e6ebd585af89784c2f3cdac034a3d8cd3b80f08204c3c9967b2e2e4
7
+ data.tar.gz: fb966cea81362060894f1b0d5b4c89da8c01c322abe5261ee218621e6ace301e1557457d4c64fadb4b5742c46245a832fd7ed11f720db9703413eb07a84ee1fa
data/CHANGELOG.md CHANGED
@@ -1,5 +1,30 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.4.33 - 2026-11-09
4
+
5
+ - Changed: requires `nwc-ruby ~> 0.5`. Each connection's encryption key is
6
+ derived in OpenSSL instead of pure Ruby, about 58x faster, and the `ecdsa` gem
7
+ is no longer installed. A Ruby whose OpenSSL cannot use secp256k1, as in FIPS
8
+ mode, cannot use 0.5.
9
+ - Fixed: `bin/rails openreceive:doctor` fails when the wallet will not accept
10
+ the code, and names a refused or silent wallet.
11
+ - Fixed: a production boot with the wallet's relay down now completes. Checkouts
12
+ answer a retryable 503 and try the wallet again after a short wait.
13
+ - Fixed: a wallet-reported `failed` or `expired` invoice no longer closes while
14
+ a wallet scan is still running. Only a settled payment is committed as found.
15
+ - Fixed: an unexpected error inside OpenReceive's routes leaves a line in the
16
+ Rails log even when `Rails.error` is present.
17
+ - Fixed: the paid-reference and swap-provider answers described in
18
+ `openreceive-server` 0.4.33, and the 12 s wallet budget in `openreceive` 0.4.33.
19
+
20
+ ## 0.4.32 - 2026-11-07
21
+
22
+ Release with the complete 0.4.32 package family. No Ruby runtime changes
23
+ from 0.4.31. The checkout fixes of 0.4.32 (a Try again button on a failed
24
+ Bitcoin invoice, one plain sentence when the wallet did not answer, a
25
+ "Total" row with the order's own amount) come with
26
+ `@openreceive/elements` and `@openreceive/react` 0.4.32 on the page.
27
+
3
28
  ## 0.4.31 - 2026-10-20
4
29
 
5
30
  Release with the complete 0.4.31 package family. A reconcile pass now stops
@@ -288,6 +288,18 @@ module OpenReceive
288
288
  # own rows and never wait for the host's price hook.
289
289
  def engine_resolve_checkout
290
290
  lambda do |action:, request:, reference:, input:, pay_in_asset: nil|
291
+ # Before the host is asked for a price: a host may well answer nil for an
292
+ # order it already knows is paid, and "unknown order" is the wrong thing
293
+ # to tell the payer who paid it.
294
+ if %w[checkout.prepare checkout.create swap.create].include?(action)
295
+ paid = OpenReceivePayment.where(reference: reference, status: "settled").order(:created_at).first
296
+ if paid
297
+ raise OpenReceive::Server::ConflictError, "This reference is already paid." unless action == "checkout.prepare"
298
+
299
+ next({ payment_hash: paid.payment_hash, checkout: paid.checkout_data, paid: true,
300
+ paid_at: paid.paid_at&.to_i, swap: !paid.swap_data.nil? }.compact)
301
+ end
302
+ end
291
303
  pricing = %w[checkout.prepare swap.quote checkout.create swap.create].include?(action)
292
304
  price = pricing ? @amount_for.call(reference) : nil
293
305
  raise OpenReceive::Server::NotFoundError, "Unknown reference." if pricing && price.nil?
@@ -407,9 +419,7 @@ module OpenReceive
407
419
  rescue OpenReceive::NwcUriParseError => e
408
420
  raise ConfigurationError, invalid_nwc_message(e.message)
409
421
  end
410
- OpenReceive::NwcRubyReceiveClient.new(
411
- client: build_nwc_ruby_client(connection), connection_uri: connection
412
- )
422
+ build_nwc_ruby_client(connection)
413
423
  end
414
424
 
415
425
  # Mirrors the JS core formatMissingNwcMessage: what is missing, the
@@ -434,9 +444,11 @@ module OpenReceive
434
444
  ].join("\n")
435
445
  end
436
446
 
447
+ # The adapter's from_uri sets nwc-ruby's per-call budget
448
+ # (NwcRubyReceiveClient::REQUEST_TIMEOUT_SECONDS, 12 s) instead of the
449
+ # gem's 30 s, so a relay that never answers costs a checkout 12 s.
437
450
  def build_nwc_ruby_client(connection)
438
- require "nwc_ruby"
439
- ::NwcRuby::Client.from_uri(connection)
451
+ OpenReceive::NwcRubyReceiveClient.from_uri(connection)
440
452
  rescue LoadError
441
453
  raise ConfigurationError,
442
454
  "Install nwc-ruby (add `gem \"nwc-ruby\"` to the Gemfile) or configure " \
@@ -477,20 +489,56 @@ module OpenReceive
477
489
  #
478
490
  # It builds the service, which is the same eager preflight the engine runs
479
491
  # at production boot — a missing NWC_URI, a dead relay, or a SPEND-CAPABLE
480
- # connection all answer here rather than on a payer's first checkout. The
481
- # failure is reported, never raised: an operator running a doctor wants
482
- # every other line too, and a doctor that dies at line six tells them less
483
- # than one that finishes. Sanitized for the same reason the reconcile logs
484
- # are — a connect failure can quote the NWC URI, secret and all.
492
+ # connection all answer here rather than on a payer's first checkout. A
493
+ # dead relay does not stop the boot (the service checks again on a later
494
+ # checkout), but the doctor still reports it. The failure is reported,
495
+ # never raised: an operator running a doctor wants every other line too,
496
+ # and a doctor that dies at line six tells them less than one that
497
+ # finishes. Sanitized for the same reason the reconcile logs are — a
498
+ # connect failure can quote the NWC URI, secret and all.
485
499
  def doctor_wallet_report
486
500
  return "skipped — OpenReceive.configure has not run" unless configured?
487
501
 
488
- config.service
502
+ service = config.service
503
+ pending = service.respond_to?(:wallet_pending) ? service.wallet_pending : nil
504
+ return "FAILED — the wallet check has not passed (#{pending})" unless pending.nil?
505
+
506
+ refusal = doctor_wallet_refusal
507
+ return "FAILED — #{refusal}" unless refusal.nil?
508
+
489
509
  "ok — the wallet answered and is receive-only"
490
510
  rescue StandardError => error
491
511
  "FAILED — #{sanitize_failure_message(error)}"
492
512
  end
493
513
 
514
+ DOCTOR_PROOF_SECONDS = 10
515
+
516
+ # A wallet publishes its methods for anyone to read, so a wrong secret can
517
+ # pass the wallet check. Only a signed request proves the wallet accepts
518
+ # this code, and reading a history row changes nothing. nil when accepted.
519
+ def doctor_wallet_refusal
520
+ deadline = Process.clock_gettime(Process::CLOCK_MONOTONIC) + DOCTOR_PROOF_SECONDS
521
+ config.send(:resolved_nwc_client).list_transactions("limit" => 1, "_deadline" => deadline)
522
+ nil
523
+ rescue Timeout::Error
524
+ doctor_wallet_silent_message
525
+ rescue StandardError => error
526
+ case OpenReceive::Nwc.normalize_wallet_error(error)["code"]
527
+ when "UNAUTHORIZED"
528
+ "the wallet refused this code (UNAUTHORIZED). The secret in NWC_URI is wrong, or the " \
529
+ "connection was removed from the wallet. Get a fresh receive-only code: " \
530
+ "#{OpenReceive::NWC_CODE_HELP_URL}"
531
+ when "TIMEOUT" then doctor_wallet_silent_message
532
+ else sanitize_failure_message(error)
533
+ end
534
+ end
535
+
536
+ def doctor_wallet_silent_message
537
+ "the wallet published its details but did not answer a signed request within " \
538
+ "#{DOCTOR_PROOF_SECONDS}s. The secret in NWC_URI may be wrong, or the wallet may be " \
539
+ "offline. Copy the code from your wallet again and rerun."
540
+ end
541
+
494
542
  # nil when the boot preflight should run; otherwise the short reason the
495
543
  # engine logs, so an operator who expected a fail-closed boot and did not
496
544
  # get one can see why in the same log line.
@@ -19,10 +19,13 @@ module OpenReceive
19
19
  end
20
20
 
21
21
  # Boot fails closed for real: in production the service — and its wallet
22
- # preflight — is built eagerly, so a missing NWC_URI, a dead relay, or a
23
- # spend-capable wallet stops the deploy instead of surfacing as
24
- # customer-facing 500s on the first checkout. Skipped when the host never
25
- # ran OpenReceive.configure (gem installed, installer not run yet), and
22
+ # preflight — is built eagerly, so a missing NWC_URI or a wallet that
23
+ # cannot receive or can spend stops the deploy instead of surfacing as
24
+ # customer-facing errors on the first checkout. A relay that does not
25
+ # answer does not stop it: the app boots, logs one line, checkouts answer
26
+ # 503 WALLET_UNAVAILABLE, and the first checkout after a short wait (1 s,
27
+ # doubling to 60 s) checks again. Skipped when the host never ran
28
+ # OpenReceive.configure (gem installed, installer not run yet), and
26
29
  # outside production so tests and consoles boot without a live wallet.
27
30
  #
28
31
  # `rails assets:precompile` is the one production boot that must NOT be
@@ -5,6 +5,6 @@ module OpenReceive
5
5
  # top-level `::Rails` framework constant — engine code always references the framework as
6
6
  # `::Rails` to avoid shadowing.
7
7
  module Rails
8
- VERSION = "0.4.31"
8
+ VERSION = "0.4.33"
9
9
  end
10
10
  end
@@ -205,6 +205,12 @@ module OpenReceive
205
205
  "keep polling with OpenReceive::ReconcileJob or " \
206
206
  "`bin/rails openreceive:reconcile`."
207
207
  end
208
+ # A worker started while the wallet's relay was down subscribes only once
209
+ # the wallet check passes; until then this raises the retryable
210
+ # WalletFailureError, which the worker's loop backs off from like a
211
+ # dropped subscription.
212
+ service = config.service
213
+ service.ensure_wallet! if service.respond_to?(:ensure_wallet!)
208
214
 
209
215
  client.subscribe_notifications do |notification|
210
216
  next unless payment_received_notification?(notification)
@@ -88,7 +88,9 @@ module OpenReceive
88
88
  status = OpenReceive::Settlement.status(row)
89
89
  if %w[settled expired failed].include?(status)
90
90
  results[hash] = service.send(:payment_result, hash, row)
91
- on_finality&.call(results[hash]) if Process.clock_gettime(Process::CLOCK_MONOTONIC) < deadline
91
+ # Only a payment commits as found: a wallet-reported failure or
92
+ # expiry closes nothing until this scan completes.
93
+ on_finality&.call(results[hash]) if status == "settled" && Process.clock_gettime(Process::CLOCK_MONOTONIC) < deadline
92
94
  end
93
95
  window.fetch("observations")[hash] = { "status" => status, "transaction_state" => row["transaction_state"] }
94
96
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: openreceive-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.31
4
+ version: 0.4.33
5
5
  platform: ruby
6
6
  authors:
7
7
  - OpenReceive
@@ -15,28 +15,28 @@ dependencies:
15
15
  requirements:
16
16
  - - '='
17
17
  - !ruby/object:Gem::Version
18
- version: 0.4.31
18
+ version: 0.4.33
19
19
  type: :runtime
20
20
  prerelease: false
21
21
  version_requirements: !ruby/object:Gem::Requirement
22
22
  requirements:
23
23
  - - '='
24
24
  - !ruby/object:Gem::Version
25
- version: 0.4.31
25
+ version: 0.4.33
26
26
  - !ruby/object:Gem::Dependency
27
27
  name: openreceive-server
28
28
  requirement: !ruby/object:Gem::Requirement
29
29
  requirements:
30
30
  - - '='
31
31
  - !ruby/object:Gem::Version
32
- version: 0.4.31
32
+ version: 0.4.33
33
33
  type: :runtime
34
34
  prerelease: false
35
35
  version_requirements: !ruby/object:Gem::Requirement
36
36
  requirements:
37
37
  - - '='
38
38
  - !ruby/object:Gem::Version
39
- version: 0.4.31
39
+ version: 0.4.33
40
40
  - !ruby/object:Gem::Dependency
41
41
  name: rails
42
42
  requirement: !ruby/object:Gem::Requirement
@@ -57,14 +57,14 @@ dependencies:
57
57
  requirements:
58
58
  - - "~>"
59
59
  - !ruby/object:Gem::Version
60
- version: '0.4'
60
+ version: '0.5'
61
61
  type: :runtime
62
62
  prerelease: false
63
63
  version_requirements: !ruby/object:Gem::Requirement
64
64
  requirements:
65
65
  - - "~>"
66
66
  - !ruby/object:Gem::Version
67
- version: '0.4'
67
+ version: '0.5'
68
68
  - !ruby/object:Gem::Dependency
69
69
  name: sqlite3
70
70
  requirement: !ruby/object:Gem::Requirement