feat: merge a link's extra into the payout payment (v1.2.2-aio.2)
Adds an optional `extra` (JSON) field to a withdraw link. When the link
is claimed, that `extra` is merged onto the payout payment's `extra`, so
a caller can tag the resulting payment with metadata an external listener
keys on — the link is the only place to attach it (the customer-facing
LNURL-withdraw payout otherwise carries just `{tag, withdrawal_link_id}`).
Motivating use: bitSpire cash-in settlements. The operator's spirekeeper
listener fires a `cash_in` settlement (fee split to the platform) only on
an outbound payment stamped `source=bitspire`; before this there was no
way to stamp an LNURL-withdraw payout, so cash-ins never settled. bitSpire
now creates the cash-in link for the NET amount with
`extra={source, type:cash_in, principal_sats, fee_sats, ...}` and the
settlement fires on claim.
- models: `extra: dict | None` on CreateWithdrawData + WithdrawLink.
LNbits' db layer (de)serializes dict columns to/from JSON natively
(same as Payment.extra) — no per-field validator needed.
- migrations_fork.py: `withdraw_link.extra TEXT` under `withdraw_fork`,
keeping the upstream-tracked migrations.py byte-identical for clean
rebases (aiolabs/lnbits#8 pattern).
- views_lnurl: `extra={**(link.extra or {}), "tag": ..., "withdrawal_link_id": ...}`
— the withdraw extension's own keys are written last so a caller cannot
clobber them.
Verified end-to-end on the dev stack: a stamped link's payout carries the
merged extra and drives a spirekeeper cash_in settlement + super-fee payout.
This commit is contained in:
parent
2877cf6b20
commit
9c0e58a87c
5 changed files with 66 additions and 2 deletions
|
|
@ -141,7 +141,16 @@ async def api_lnurl_callback(
|
|||
wallet_id=link.wallet,
|
||||
payment_request=pr,
|
||||
max_sat=link.max_withdrawable,
|
||||
extra={"tag": "withdraw", "withdrawal_link_id": link.id},
|
||||
# Merge the link's caller-supplied `extra` onto the payout so an
|
||||
# external listener can key on it (e.g. bitSpire cash-in
|
||||
# settlements via spirekeeper). The withdraw extension's own
|
||||
# `tag`/`withdrawal_link_id` are written last so a caller cannot
|
||||
# clobber them.
|
||||
extra={
|
||||
**(link.extra or {}),
|
||||
"tag": "withdraw",
|
||||
"withdrawal_link_id": link.id,
|
||||
},
|
||||
)
|
||||
await increment_withdraw_link(link)
|
||||
# If the payment succeeds, delete the record with the unique_hash.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue