Skip to content

Commit 113de6e

Browse files
Merge pull request #2 from lnbits/feat/funding-sources
2 parents 0fb59a0 + 37b2a9b commit 113de6e

52 files changed

Lines changed: 3959 additions & 394 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,14 @@ ssh lnbitsadmin@<pi-ip-address>
206206
sudo lnbitspi-reset
207207
```
208208

209+
**Then reboot:**
210+
```bash
211+
sudo reboot
212+
```
213+
**And access the wizard again at:**
214+
`http://<pi-ip-address>/` or `http://lnbits.local/`
215+
216+
209217
This will:
210218
- Stop LNbits and Spark sidecar services
211219
- Remove the configuration marker

docs/development.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
To build the image yourself, follow these instructions for Debian/Ubuntu systems.
44

5+
For Phoenixd version bumps, see [Phoenixd Upgrade Guide](./phoenixd-upgrades.md).
6+
57
## Build Options
68

79
You can build two variants of the SD image:
@@ -118,8 +120,8 @@ cachix use raspberry-pi-nix
118120
Clone the repository:
119121

120122
```bash
121-
git clone https://github.com/blackcoffeexbt/lnbitspi
122-
cd lnbitspi
123+
git clone https://github.com/lnbits/LNbitsBox
124+
cd LNbitsBox
123125
```
124126

125127
Build the SD image:

docs/phoenixd-upgrades.md

Lines changed: 217 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,217 @@
1+
# Phoenixd Upgrade Guide
2+
3+
This project packages Phoenixd from source as a JVM application instead of using ACINQ's prebuilt `linux-arm64` binary.
4+
5+
That choice is intentional: on NixOS Raspberry Pi builds, the ACINQ ARM64 binary has issues LSP connectivity. Building Phoenixd from source with the JVM distribution fixed that issue.
6+
7+
Use this guide whenever you want to upgrade Phoenixd, for example from `0.7.3` to `0.7.4`.
8+
9+
## Overview
10+
11+
A Phoenixd upgrade usually touches these files:
12+
13+
- `flake.nix`
14+
- `flake.lock`
15+
- `nixos/phoenixd-package.nix`
16+
- `nixos/phoenixd-no-git.patch`
17+
- `nixos/phoenixd-deps.json`
18+
19+
In practice, the work is:
20+
21+
1. Update the Phoenixd source input.
22+
2. Update the packaged Phoenixd version.
23+
3. Check whether the upstream Gradle wrapper version changed.
24+
4. Regenerate the Gradle dependency lock file on the Debian build machine.
25+
5. Build the Phoenixd package.
26+
6. Build the full image.
27+
28+
## 1. Update the Phoenixd source input
29+
30+
Edit `flake.nix` and change the Phoenixd input tag:
31+
32+
```nix
33+
phoenixd.url = "github:ACINQ/phoenixd/v0.7.4";
34+
```
35+
36+
Then update the flake lock:
37+
38+
```bash
39+
nix flake lock --update-input phoenixd
40+
```
41+
42+
This updates `flake.lock` to the new Phoenixd source revision and hash.
43+
44+
## 2. Update the packaged Phoenixd version
45+
46+
In `nixos/phoenixd-package.nix`, update:
47+
48+
```nix
49+
version = "0.7.4";
50+
```
51+
52+
This version string is used when installing the generated `jvmDistZip` artifact.
53+
54+
## 3. Check the upstream Gradle wrapper version
55+
56+
Phoenixd is built with a pinned Gradle version in `nixos/phoenixd-package.nix` to match upstream and avoid Gradle/Kotlin DSL mismatches.
57+
58+
Check the upstream wrapper version:
59+
60+
```bash
61+
grep distributionUrl gradle/wrapper/gradle-wrapper.properties
62+
```
63+
64+
If upstream changed the wrapper version, update the custom Gradle version in `nixos/phoenixd-package.nix`.
65+
66+
Example:
67+
68+
```nix
69+
version = "8.9";
70+
hash = "sha256-...";
71+
```
72+
73+
To compute the Nix-style hash for a Gradle distribution:
74+
75+
1. Take the upstream `distributionSha256Sum` value from `gradle-wrapper.properties`.
76+
2. Convert it from hex to Nix `sha256-...` base64 format.
77+
78+
One way to do that:
79+
80+
```bash
81+
python3 - <<'PY'
82+
import base64, binascii
83+
hexhash = "PUT_UPSTREAM_HEX_SHA256_HERE"
84+
print("sha256-" + base64.b64encode(binascii.unhexlify(hexhash)).decode())
85+
PY
86+
```
87+
88+
If the wrapper version did not change, leave the Gradle pin alone.
89+
90+
## 4. Check whether the local patch still applies
91+
92+
This repo patches Phoenixd so that:
93+
94+
- it does not require a live `.git` checkout during the Nix build
95+
- it can skip native targets and build JVM-only
96+
- Gradle plugin resolution includes `mavenCentral()`
97+
98+
The patch lives in:
99+
100+
- `nixos/phoenixd-no-git.patch`
101+
102+
After bumping Phoenixd, build output will tell you if this patch no longer applies cleanly.
103+
104+
If it fails during `patchPhase`, refresh the patch against the new upstream sources before continuing.
105+
106+
## 5. Regenerate the Gradle dependency lock on the Debian builder
107+
108+
Do this on the Debian/Ubuntu machine you use for real builds, not on macOS.
109+
110+
Generate the dependency update script:
111+
112+
```bash
113+
nix-build -E 'let pkgs = import <nixpkgs> {}; phoenixd = pkgs.fetchFromGitHub { owner = "ACINQ"; repo = "phoenixd"; rev = "REV_FROM_FLAKE_LOCK"; hash = "NAR_HASH_FROM_FLAKE_LOCK"; }; in (pkgs.callPackage ./nixos/phoenixd-package.nix { inherit phoenixd; }).mitmCache.updateScript'
114+
```
115+
116+
That command prints a `/nix/store/...-fetch-deps.sh` path.
117+
118+
Run the printed script:
119+
120+
```bash
121+
/nix/store/...-fetch-deps.sh
122+
```
123+
124+
This regenerates:
125+
126+
- `nixos/phoenixd-deps.json`
127+
128+
Important:
129+
130+
- Regenerate `phoenixd-deps.json` whenever the Phoenixd source changes.
131+
- Regenerate it whenever the Gradle version changes.
132+
- If package build errors mention missing Maven or Kotlin artifacts, the lock file may be stale.
133+
134+
## 6. Build the Phoenixd package
135+
136+
First test the package by itself:
137+
138+
```bash
139+
nix build .#packages.x86_64-linux.phoenixd -L
140+
```
141+
142+
If you build natively on Linux ARM, you can also test:
143+
144+
```bash
145+
nix build .#packages.aarch64-linux.phoenixd -L
146+
```
147+
148+
This should produce a working JVM-based Phoenixd package containing:
149+
150+
- `bin/phoenixd`
151+
- `bin/phoenix-cli`
152+
153+
## 7. Build the full LNbitsBox image
154+
155+
Once the Phoenixd package build succeeds, build the full image:
156+
157+
```bash
158+
nix build .#sdImageUncompressed -L
159+
```
160+
161+
Or the release image:
162+
163+
```bash
164+
nix build .#sdImage -L
165+
```
166+
167+
## 8. Validate on Raspberry Pi
168+
169+
After flashing or deploying the image, validate on the Pi:
170+
171+
```bash
172+
phoenix-cli getinfo
173+
phoenix-cli createinvoice --amountSat=1000 --desc="upgrade test"
174+
```
175+
176+
Then pay that invoice from another Lightning wallet or node.
177+
178+
The key regression to watch for is:
179+
180+
- Phoenixd starts and connects
181+
- invoice creation works
182+
- but invoices are not payable
183+
184+
If that regression returns, do not switch back to the upstream prebuilt ARM64 binary. Keep investigating the source-built JVM path.
185+
186+
## Troubleshooting
187+
188+
### Patch fails during `patchPhase`
189+
190+
The upstream Phoenixd sources changed enough that `nixos/phoenixd-no-git.patch` needs to be refreshed.
191+
192+
### `kotlin-stdlib` or `kotlin-reflect` artifact not found
193+
194+
Usually one of these is true:
195+
196+
- the Gradle pin in `nixos/phoenixd-package.nix` does not match upstream closely enough
197+
- `nixos/phoenixd-deps.json` is stale
198+
- the patch adding `mavenCentral()` is missing or no longer applies
199+
200+
### `attribute 'mkGradle' missing`
201+
202+
Your local `nixpkgs` revision exposes Gradle internals differently. The package file in this repo is written to support both the newer and older nixpkgs layouts. Make sure you are using the current repo version of `nixos/phoenixd-package.nix`.
203+
204+
## Suggested upgrade checklist
205+
206+
```text
207+
[ ] Update `flake.nix` Phoenixd tag
208+
[ ] Run `nix flake lock --update-input phoenixd`
209+
[ ] Update `version` in `nixos/phoenixd-package.nix`
210+
[ ] Check `gradle-wrapper.properties` upstream
211+
[ ] Update Gradle pin if wrapper version changed
212+
[ ] Refresh `nixos/phoenixd-no-git.patch` if needed
213+
[ ] Regenerate `nixos/phoenixd-deps.json` on Debian
214+
[ ] Build `.#packages.x86_64-linux.phoenixd`
215+
[ ] Build `.#sdImageUncompressed`
216+
[ ] Test invoice creation and payment on Pi
217+
```

flake.lock

Lines changed: 46 additions & 12 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)