openreceive-rails 0.4.3 → 0.4.4

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: 3728f2af46867cb69f88ae8a5d0a9d594ec15fc144c61095b116e6a18c40c26f
4
- data.tar.gz: c761ba6cc843d76ab40f6bff5a0219be46d3afa8c85f93ecc74f2858bf46d91f
3
+ metadata.gz: b0e01e9b76a2a924c07b7403a1a103e5db904147fcd8a44f385cf42ba616b97c
4
+ data.tar.gz: 59c7558cd8a72dc905517c8812750c1ed53f56495797ccc40b4eca5924eb2cb5
5
5
  SHA512:
6
- metadata.gz: 194fedae9e48bd925b89e0aaf6b0aea5b902aa202d64d163dee5d4f3547b551363e83406fe8e939f43d130bcffba6ba6b5f9a2f6079964f64fc583d6aa9511ad
7
- data.tar.gz: fa6b0b156598591ac4575f081031f4ff8dbd0f808a7b40c88134ae4c4f51c3545dc9290f3cec2c9fbdb63c42952d50344a12809f984ca257d144fde05b615720
6
+ metadata.gz: 636b758e07b9bdce4155984fc29629b2ac7b90aee6302605836513595900f837933fba80df7b3ec06e0f40537dc6c8f223b0ffcdeeb5dd5eef25111e390006fd
7
+ data.tar.gz: c591cacae9e9e4adedd2aa633fdaa6b2e375829d11f3746c94a01dd56abb930a5c135c7f7d0a304d3a38dd5542d9a5e7ce480dc50d013e2752721cb00ba924e8
data/CHANGELOG.md CHANGED
@@ -1,5 +1,20 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.4.4 - 2026-09-07
4
+
5
+ Version lockstep with the 0.4.4 npm release (every checkout image now ships
6
+ inside the JavaScript; a Rails host no longer copies `dist/assets` or sets
7
+ `asset-base-url`, and the quickstart no longer says to). Ruby changes in this
8
+ gem:
9
+
10
+ - `OpenReceive::ApplicationController`'s header comment is corrected: the
11
+ engine inherits `config.parent_controller` for forgery protection only and
12
+ reads nothing else from it. The quickstart documents what that inheritance
13
+ also brings (every global `before_action`, including redirect-to-login
14
+ filters) and the two remedies.
15
+ - The bundled agent skill gains references for Django, FastAPI, Fastify,
16
+ Laravel and Next.js beside Node, Rails and BTCPay Server.
17
+
3
18
  ## 0.4.3 - 2026-09-03
4
19
 
5
20
  Version lockstep with the 0.4.3 npm release (container-query checkout
@@ -2,8 +2,20 @@
2
2
 
3
3
  module OpenReceive
4
4
  # Base controller for the engine. It inherits DYNAMICALLY from the configured
5
- # `config.parent_controller` (default "ActionController::Base"; a host sets "ApplicationController")
6
- # so the engine automatically gets the host's authentication and current_user.
5
+ # `config.parent_controller` (default "ActionController::Base"; the generated
6
+ # initializer sets "ApplicationController"). What that inheritance is FOR is the
7
+ # host's forgery protection: apps that never adopted `load_defaults 5.2` have
8
+ # `protect_from_forgery` only on their own ApplicationController, so pointing the
9
+ # engine at the bare base class would silently drop CSRF on cookie-authenticated
10
+ # checkout routes. The engine reads nothing else from the parent — no
11
+ # `current_user`, no helpers; `config.authorize` receives the raw request and
12
+ # the host's policy reads its own session from it.
13
+ #
14
+ # Everything else the parent declares is inherited too, including every global
15
+ # `before_action`. A filter that redirects to a login page will redirect these
16
+ # JSON routes as well. Hosts with such filters point `config.parent_controller`
17
+ # at a slimmer controller, or `skip_before_action` on this class in a
18
+ # `config.to_prepare` block. The Rails quickstart documents both.
7
19
  #
8
20
  # Set `parent_controller` in a normal initializer — not `after_initialize`. Production
9
21
  # eager-loads this class before after_initialize runs, so a late parent_controller change
@@ -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.3"
8
+ VERSION = "0.4.4"
9
9
  end
10
10
  end
@@ -5,7 +5,8 @@ description: >
5
5
  Use when adding Bitcoin, Lightning, or crypto checkout to a Node.js, Express,
6
6
  Fastify, Next.js, Rails, React, Vue, Svelte, Angular, or plain-HTML
7
7
  application with OpenReceive (the @openreceive/* npm packages or the
8
- openreceive-rails gem).
8
+ openreceive-rails gem), or when connecting a BTCPay Server store to a
9
+ receive-only NWC wallet with the OpenReceive plugin.
9
10
  license: MIT
10
11
  ---
11
12
 
@@ -23,15 +24,24 @@ code** (`NWC_URI`).
23
24
  1. Identify the server stack of the application you are in.
24
25
  2. Open the matching reference — it is complete (quickstart inlined) and needs
25
26
  no network access:
26
- - Node (Express / Fastify / Next.js): [references/node.md](references/node.md)
27
+ - Node, Express: [references/node.md](references/node.md)
28
+ - Node, Fastify: [references/fastify.md](references/fastify.md)
29
+ - Node, Next.js App Router: [references/next.md](references/next.md)
27
30
  - Rails: [references/rails.md](references/rails.md)
31
+ - Django: [references/django.md](references/django.md)
32
+ - Laravel: [references/laravel.md](references/laravel.md)
33
+ - BTCPay Server: [references/btcpay.md](references/btcpay.md) — a plugin,
34
+ configured in BTCPay's store UI or Greenfield API; no application code,
35
+ no npm packages, no gem. The rest of this file is about the library.
28
36
  3. Follow its **Step 0** first: confirm `NWC_URI` is set in the server
29
37
  environment before writing code. Never print the value; never invent a
30
38
  placeholder.
31
39
 
32
- Install (Node): `npm install @openreceive/express @openreceive/react` — swap
33
- the adapter (`fastify`, `next`) and UI package (`vue`, `svelte`, `angular`,
34
- `elements`) for the stack. Install (Rails): `bundle add openreceive-rails`.
40
+ Install, per adapter — Express: `npm install @openreceive/express @openreceive/react`;
41
+ Fastify: `npm install @openreceive/fastify @openreceive/react`; Next.js:
42
+ `npm install @openreceive/next @openreceive/react`. Swap the UI package (`vue`,
43
+ `svelte`, `angular`, `elements`) for the frontend the app already has. Install
44
+ (Rails): `bundle add openreceive-rails`.
35
45
 
36
46
  ## The three server objects
37
47
 
@@ -0,0 +1,193 @@
1
+ # OpenReceive agent directions (BTCPay Server)
2
+
3
+ These directions describe OpenReceive 0.4.4.
4
+
5
+ Connect a BTCPay Server store to a receive-only NWC wallet with the OpenReceive
6
+ plugin, and optionally let payers pay BTCPay invoices with USDT, USDC, ETH or
7
+ SOL. You do not need a copy of the OpenReceive source, and there is no
8
+ application code to write: the plugin is configured through BTCPay's store UI
9
+ or its Greenfield API, and the quickstart is appended to this file in full.
10
+
11
+ This is the BTCPay plugin, not the Node or Rails library. Do not install
12
+ `@openreceive/*` packages or the `openreceive-rails` gem into a BTCPay
13
+ deployment, do not add `openreceive_payments` tables, and do not mount
14
+ OpenReceive HTTP routes. BTCPay's invoices, checkout, webhooks and Greenfield
15
+ API are the host; the plugin only supplies the Lightning backend and the swap
16
+ rail.
17
+
18
+ ## What the plugin is
19
+
20
+ A BTCPay Server plugin (`BTCPayServer.Plugins.OpenReceive`) that registers a
21
+ Lightning connection-string handler for `type=openreceive;nwc=<NWC URI>`.
22
+ Saving that string makes the NWC wallet the store's Lightning node: BTCPay
23
+ mints every Lightning invoice in that wallet and its own `LightningListener`
24
+ records the payments. The plugin never calls a NIP-47 `pay_*` method, so
25
+ every send-side BTCPay feature (Lightning payouts, pull-payment refunds over
26
+ Lightning, the send tab) is unavailable by design.
27
+
28
+ The one required credential is a receive-only NWC code. A Lightning Swap
29
+ Connect (LSC) code optionally adds server-side swaps: a provider order aimed at
30
+ the invoice's existing BOLT11, tracked in the plugin's own table, with the
31
+ refund path on the same checkout screen.
32
+
33
+ ## Step 0 — check the deployment before you change anything
34
+
35
+ 1. Confirm the BTCPay Server version is 2.4.2 or later (Server Settings →
36
+ About, or `GET /api/v1/server/info`). The plugin declares that minimum and
37
+ BTCPay refuses to load it below.
38
+ 2. Check whether the plugin is installed (Server Settings → Plugins, or the
39
+ store navigation shows an "OpenReceive" entry). If not, install it from the
40
+ BTCPay plugin directory (Server Settings → Plugins, search "OpenReceive"),
41
+ as the quickstart says; do not invent an installer command.
42
+ 3. Check whether the store already has an OpenReceive connection:
43
+ `GET /api/v1/stores/{storeId}/openreceive/settings` returns
44
+ `lightningNodeIsOpenReceive`. If true, the wallet step is done — go to
45
+ swaps only if the user wants them.
46
+ 4. If no receive-only NWC code is available, stop and tell the user exactly
47
+ what to create:
48
+
49
+ > OpenReceive cannot mint an invoice without a receive-only NWC code. Get
50
+ > one at https://openreceive.org/get_a_nwc_code_to_receive_payments and
51
+ > paste it into Store → OpenReceive → Test connection, or hand it to me and
52
+ > I will set it through the Greenfield API.
53
+
54
+ Never print, log or echo the code; report only whether it is set. Never
55
+ paste a bare `nostr+walletconnect://` string into BTCPay's Lightning node
56
+ screen — that form is claimed by the Nostr plugin, without the receive-only
57
+ guard.
58
+ 5. If the user wants altcoin payments, ask for an LSC code from
59
+ https://openreceive.org/set_up_swap_provider. Do not wait for it: the
60
+ wallet works without it, and swaps switch on later with one settings change.
61
+
62
+ Only then start the quickstart.
63
+
64
+ ## Non-negotiables
65
+
66
+ - The connection string is `type=openreceive;nwc=<NWC URI>[;allow-spend=true]`
67
+ and nothing else. Set it through the setup page or
68
+ `PUT /api/v1/stores/{storeId}/openreceive/settings` with `nwcUri`, never by
69
+ editing BTCPay's Lightning node screen by hand.
70
+ - Receive-only is required. A code that advertises `pay_invoice` or another
71
+ spend method is refused on save. The override (`allowSpendCapableWallet`,
72
+ the checkbox on the setup page) is the user's explicit choice; never tick it
73
+ to make a save succeed.
74
+ - The wallet's network must match BTCPay's. A mismatch is a refusal, not a
75
+ warning.
76
+ - The wallet must grant `make_invoice` and `list_transactions`.
77
+ `lookup_invoice` is optional; do not ask the user for a code that grants it.
78
+ - Swaps require the store's Lightning node to be the OpenReceive connection.
79
+ Enabling swaps on a store using the internal node is refused
80
+ (`wallet_required`).
81
+ - Swaps set the store's invoice expiration to 60 minutes when it is shorter,
82
+ and the plugin refuses to create a swap on an invoice with less than the
83
+ provider's window left. Do not lower the expiration below 45 minutes on a
84
+ swap-enabled store.
85
+ - Top-up (amountless) invoices are unsupported on this backend. Do not
86
+ configure a point of sale or payment link that relies on them with this
87
+ wallet.
88
+ - Secrets stay server-side. The NWC code and LSC code live in BTCPay's
89
+ database like every other BTCPay credential; never copy them into
90
+ screenshots, tickets, browser code or logs. The provider's order token never
91
+ leaves the server.
92
+ - BTCPay's `LightningListener` is the settlement authority. Provider
93
+ `completed` is not payment; only the wallet reporting the Lightning invoice
94
+ settled is. Do not build anything that fulfils on a provider state.
95
+ - There is no merchant-initiated refund of a settled Lightning payment. A swap
96
+ refund is a payer reclaiming a deposit that never converted, and only from
97
+ the `refund_required` provider state.
98
+
99
+ ## Verifying
100
+
101
+ Store → OpenReceive → **Run a health check** (the doctor page) runs every probe now: connection, preflight,
102
+ notifications, last scan, provider reachability, invoice expiration, swaps
103
+ needing attention. On a regtest machine, `packages/dotnet/docker/up.sh` then
104
+ `e2e.sh` in the OpenReceive repository proves the whole path end to end, and
105
+ that is the only situation where cloning the repository is the right move.
106
+
107
+ ## More documentation
108
+
109
+ Fetch one when the moment comes. Each is raw markdown, so a plain GET is
110
+ enough; drop the `.md` for the same page a person would read.
111
+
112
+ - https://openreceive.org/guides/btcpay-reference.md — every setting, route, swap state, doctor probe and log event of the plugin
113
+ - https://openreceive.org/guides/security.md — why receive-only is the only wallet credential
114
+ - https://openreceive.org/guides/lightning-swap-connect.md — what an LSC code actually is
115
+ - https://openreceive.org/guides/automated-swaps.md — provider states, and what turning swaps on commits a merchant to
116
+ - https://openreceive.org/guides/swap-refunds.md — the refund states; the route back is BTCPay's own invoice checkout page here
117
+ - https://openreceive.org/guides.md — the index, if what you need is not above
118
+
119
+ Questions, or a problem with the plugin itself:
120
+ https://openreceive.org/contact
121
+
122
+ ---
123
+
124
+ ## The quickstart, in full
125
+
126
+ Inlined verbatim so this file needs no network access — follow it once Step 0
127
+ passes. The page it comes from is https://openreceive.org/guides/quickstart-btcpay.
128
+
129
+ ## BTCPay Server quickstart
130
+
131
+ Requires BTCPay Server ≥ 2.4.2.
132
+
133
+ The OpenReceive plugin makes a receive-only NWC wallet the Lightning node of a
134
+ BTCPay store. BTCPay mints every Lightning invoice in that wallet and records
135
+ payments through its own settlement machinery. Optionally, payers can pay a
136
+ BTCPay invoice with USDT, USDC, ETH or SOL through a Lightning Swap Connect
137
+ provider; the swap settles into the same wallet. The store's internal node is
138
+ never used.
139
+
140
+ This is not the Node or Rails library. There are no hooks, no
141
+ `openreceive_payments` table and no OpenReceive HTTP routes: BTCPay's
142
+ invoices, checkout, webhooks and Greenfield API are the host.
143
+
144
+ ### 1. Prerequisites
145
+
146
+ - A BTCPay Server, version 2.4.2 or later, on any network (mainnet, testnet,
147
+ signet, regtest). The wallet must be on the same network.
148
+ - A receive-only NWC code for the wallet you want to receive into
149
+ ([get one here](https://openreceive.org/get_a_nwc_code_to_receive_payments)).
150
+ The code must grant `make_invoice` and `list_transactions` and must not
151
+ advertise any spend method. `lookup_invoice` is optional.
152
+ - Optionally, a Lightning Swap Connect (LSC) code from a
153
+ [swap provider](https://openreceive.org/set_up_swap_provider), if payers
154
+ should be able to pay with USDT, USDC, ETH or SOL.
155
+
156
+ ### 2. Install the plugin
157
+
158
+ In BTCPay, open **Server Settings → Plugins**, search the plugin directory
159
+ for **OpenReceive**, click **Install**, and restart BTCPay when prompted.
160
+ BTCPay creates the plugin's one table (`openreceive_swaps`, schema
161
+ `BTCPayServer.Plugins.OpenReceive`) in its own Postgres at startup; nothing
162
+ else is created.
163
+
164
+ To build the plugin from source instead, follow
165
+ [the .NET workspace README](https://github.com/OpenReceive/openreceive/blob/master/packages/dotnet/README.md).
166
+
167
+ ### 3. Connect the wallet
168
+
169
+ Follow the plugin README's illustrated walkthrough:
170
+ [OpenReceive for BTCPay Server](https://github.com/OpenReceive/openreceive/blob/master/packages/dotnet/BTCPayServer.Plugins.OpenReceive/README.md).
171
+ It opens the **OpenReceive** page in the store's sidebar, saves the
172
+ receive-only NWC code, optionally saves the LSC code to turn swaps on, and
173
+ creates a first test invoice. There is nothing else to configure: you never
174
+ open BTCPay's Lightning node screen, and the plugin never reads the internal
175
+ node.
176
+
177
+ Saving fails closed if the wallet advertises a spend method such as
178
+ `pay_invoice`. Mint a receive-only code instead; the override for a wallet
179
+ that cannot is a deliberate, logged choice. Swaps raise the store's invoice
180
+ expiration to 60 minutes when it is shorter, because a swap needs at least 45
181
+ minutes of invoice life.
182
+
183
+ ### 4. Check it
184
+
185
+ **Run a health check** on the OpenReceive page runs every probe in place:
186
+ the connection, the wallet preflight, payment notifications, the last wallet
187
+ scan, the swap provider and its assets, the invoice expiration, and swaps
188
+ that need a human. Each failing probe carries a fix link.
189
+
190
+ Every setting, Greenfield route, swap state, log event and probe is in the
191
+ [BTCPay plugin reference](https://openreceive.org/guides/btcpay-reference.md), including what is
192
+ unsupported by design: every send-side feature, top-up invoices, and a bare
193
+ `nostr+walletconnect://` string in BTCPay's Lightning node screen.