Skip to content

Add phoenixd support#7

Merged
Sjors merged 6 commits intomasterfrom
2026/03/phoenixd
Mar 24, 2026
Merged

Add phoenixd support#7
Sjors merged 6 commits intomasterfrom
2026/03/phoenixd

Conversation

@Sjors
Copy link
Copy Markdown
Owner

@Sjors Sjors commented Mar 23, 2026

Usage:

phoenix-cli exportcsv
cargo run -- export --country FR --phoenixd-csv payments.csv --nodeid 03864e... --output lightning.xml

@Sjors Sjors force-pushed the 2026/03/phoenixd branch 8 times, most recently from d640251 to 385cfe7 Compare March 24, 2026 00:07
Sjors and others added 5 commits March 24, 2026 09:54
Add a closing_balance_sats field to Statement so consumers (e.g. the
export summary) can report the final BTC balance without recomputing
it.  Include the closing sat balance in the export summary line when
FIFO or mark-to-market entries are present.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Extend WalletTransaction with two new fields:

- payment_hash: Optional Lightning payment hash for invoice matching.
- kind: TxKind enum distinguishing standard transactions from
  liquidity purchases that need special accounting treatment.

All existing constructors set the defaults (None / TxKind::Default).
No behavioral changes yet — this is purely a data-model extension.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Teach the accounting engine to handle Lightning-specific fields:

- Refactor format_description to support empty labels (Lightning
  transactions have no address) and an optional suffix for payment
  hash or fee notes.
- Handle TxKind::LiquidityPurchase: emit as a single fee entry with
  pre-formatted mining/service fee breakdown.
- Include payment_hash in receive and send descriptions.
- Add fee_threshold_cents: fees below this threshold are folded into
  the parent entry description instead of emitted as separate entries.
- Use "Lightning send fee" label when tx.label is "lightning_sent".
- Add --fee-threshold-cents CLI flag.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add a phoenixd CSV transaction source that parses the CSV format
produced by `phoenix-cli exportcsv` (phoenixd v0.7.3).  Supported
types: lightning_received, lightning_sent, swap_out, channel_close,
and liquidity_purchase.  All other types are rejected with an error.

Channel-opening receives (lightning_received with mining/service fees)
are split into a plain receive plus a LiquidityPurchase fee entry.
Fee credits are folded into the received amount.

The CSV fixture contains 7 representative rows from the upstream
phoenixd testnet sample database.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add --phoenixd-csv and --nodeid flags to the export command.  When
--phoenixd-csv is given, transactions are read from a phoenixd CSV
export instead of Bitcoin Core RPC.  The node ID is cached in
.cache/phoenixd_node.txt after the first run.

Refactor run() into run_bitcoin_core_source() and
run_phoenixd_source() that return a common (iban, transactions,
wallet_balance, descriptors, bank_name) tuple.

The integration test uses real CSV rows from the upstream phoenixd
testnet sample database and real 2024 Kraken EUR/BTC daily rates.
CI validates the generated XML against the CAMT.053 XSD.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@Sjors Sjors force-pushed the 2026/03/phoenixd branch from 385cfe7 to f405fea Compare March 24, 2026 09:07
@Sjors Sjors merged commit f405fea into master Mar 24, 2026
1 check passed
@Sjors Sjors deleted the 2026/03/phoenixd branch March 24, 2026 09:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant