diff options
| author | Adam Soltys <[email protected]> | 2026-03-11 23:01:00 -0700 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2026-03-11 23:01:00 -0700 |
| commit | 79252576d1bd24bc74fe1b7fc9cc3d4d68a1c8a0 (patch) | |
| tree | b25510681bb1b935be477c59585fbc8c45deeb86 /lib/payments.ts | |
| parent | 05119b32f331ee97130a5300feb5c02f791aac80 (diff) | |
| download | coinos-server-79252576d1bd24bc74fe1b7fc9cc3d4d68a1c8a0.tar.gz coinos-server-79252576d1bd24bc74fe1b7fc9cc3d4d68a1c8a0.zip | |
try to cpfp piggyback on in flight withdrawals
Diffstat (limited to 'lib/payments.ts')
| -rw-r--r-- | lib/payments.ts | 11 |
1 files changed, 4 insertions, 7 deletions
diff --git a/lib/payments.ts b/lib/payments.ts index cc5551ce..d936314b 100644 --- a/lib/payments.ts +++ b/lib/payments.ts @@ -849,7 +849,7 @@ export const sendOnchain = async (params) => { } } - fee = totalIn - total; + fee = totalIn - total - (p2aVout >= 0 ? P2A_VALUE : 0); } const amount = total - change; @@ -1219,19 +1219,16 @@ export const build = async ({ aid, amount, address, feeRate, subtract, user }) = let bumpReserve = 0; let parentVsize = 0; - // Check if confirmed UTXOs can cover this send — if not, fall back to CPFP+send + // Piggyback on an unconfirmed parent via CPFP if one exists if (isBitcoin) { - const confirmedUtxos = await node.listUnspent(1); - const confirmedTotal = confirmedUtxos.reduce((sum, u) => sum + sats(u.amount), 0); - if (confirmedTotal < amount + P2A_VALUE) { - const balance = await getBalance(aid); + try { let ourfee = Math.round(amount * config.fee[type]); const creditBal = await getCredit(aid, type); const covered = Math.min(creditBal, ourfee); ourfee -= covered; const cpfp = await buildCpfpSend({ address, amount: amount - ourfee, feeRate, fees }); return { ...cpfp, feeRate, ourfee, fees, inputs: [], subtract, signed: true }; - } + } catch {} } try { |
