This commit is contained in:
commit
25a41bb239
@ -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.
|
||||
|
||||
@ -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,
|
||||
|
||||
@ -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" });
|
||||
|
||||
@ -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",
|
||||
});
|
||||
|
||||
Loading…
Reference in New Issue
Block a user