Merge branch 'tiero:master' into master
Some checks failed
CI / test (push) Has been cancelled

This commit is contained in:
Overtorment 2026-06-10 15:37:19 +01:00 committed by GitHub
commit 25a41bb239
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 20 additions and 6 deletions

View File

@ -81,7 +81,11 @@ export async function attachPaymentNotifications(deps: PaymentServiceDeps): Prom
priority: "high",
memo: reg.label ?? swap.request?.description ?? "",
preimage: swap.preimage ?? "",
amtPaidSat: swap.request?.invoiceAmount ?? swap.response?.onchainAmount ?? 0,
// What the receiver actually gets: `onchainAmount` is net of Boltz
// fees. `invoiceAmount` is what the *payer* paid over Lightning
// (larger by the fee), so it's only a last-resort fallback when the
// wallet registered a swap without the Boltz response.
amtPaidSat: swap.response?.onchainAmount ?? swap.request?.invoiceAmount ?? 0,
},
);
// Delivered: stop watching and prune.

View File

@ -17,7 +17,10 @@ export const silentLogger = {
export interface MockReverseSwapOptions {
preimage?: string;
preimageHash?: string;
/** What the payer pays over Lightning (gross). */
invoiceAmount?: number;
/** What the receiver claims on-chain, net of Boltz fees. Defaults to invoiceAmount. */
onchainAmount?: number;
description?: string;
}
@ -43,7 +46,7 @@ export function mockReverseSwap(
id,
invoice: "lnbc100n1ptest",
lockupAddress: "ark1test",
onchainAmount: opts.invoiceAmount ?? 10_000,
onchainAmount: opts.onchainAmount ?? opts.invoiceAmount ?? 10_000,
refundPublicKey: "0".repeat(66),
timeoutBlockHeights: {
refund: 100,

View File

@ -103,7 +103,12 @@ describe("payment flow (real SwapManager, mocked Boltz events)", () => {
it("end-to-end: register → Boltz funds (claimable) → one wake push → registry and manager pruned", async () => {
const ws = FakeWebSocket.instances[0]!;
const hash = "11".repeat(32);
const swap = mockReverseSwap("reverse-swap-1", "swap.created", { preimageHash: hash });
// Payer pays 1003 over Lightning; receiver claims 1000 on-chain after fees.
const swap = mockReverseSwap("reverse-swap-1", "swap.created", {
preimageHash: hash,
invoiceAmount: 1003,
onchainAmount: 1000,
});
const res = await app.inject({
method: "POST",
@ -131,7 +136,8 @@ describe("payment flow (real SwapManager, mocked Boltz events)", () => {
body: "⚡ Lightning payment received (1000 sats).",
memo: "1000 sats",
preimage: "",
amtPaidSat: 10_000,
// The amount the receiver got (net of Boltz fees), not the 1003 the payer paid.
amtPaidSat: 1000,
});
const list = await app.inject({ method: "GET", url: "/register" });

View File

@ -55,7 +55,8 @@ describe("attachPaymentNotifications", () => {
registry.add({
swap: mockReverseSwap("s1", "swap.created", {
preimageHash: hash,
invoiceAmount: 42_000,
invoiceAmount: 42_000, // gross, paid by the payer over Lightning
onchainAmount: 41_900, // net of Boltz fees, what the receiver claims
description: "latte",
}),
topic: hash,
@ -74,7 +75,7 @@ describe("attachPaymentNotifications", () => {
body: "⚡ Lightning payment received (42k sats).",
memo: "42k sats",
preimage: "",
amtPaidSat: 42_000,
amtPaidSat: 41_900, // the receiver's net amount, not the 42_000 paid
tags: ["zap", "moneybag"],
priority: "high",
});