diff options
| author | Adam Soltys <[email protected]> | 2024-12-02 22:06:01 -0800 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2024-12-02 22:06:01 -0800 |
| commit | 7fc51785cd190f51f5ef7cfbcb262a238b68e175 (patch) | |
| tree | 4717d95e85af94afe63678f73c8c56ec75dd0978 /lib/payments.ts | |
| parent | a25cd41e1c38b91465ea95e4bcba66c4a089091e (diff) | |
| download | coinos-server-7fc51785cd190f51f5ef7cfbcb262a238b68e175.tar.gz coinos-server-7fc51785cd190f51f5ef7cfbcb262a238b68e175.zip | |
keysend
Diffstat (limited to 'lib/payments.ts')
| -rw-r--r-- | lib/payments.ts | 19 |
1 files changed, 8 insertions, 11 deletions
diff --git a/lib/payments.ts b/lib/payments.ts index 2b344817..bc3d73d2 100644 --- a/lib/payments.ts +++ b/lib/payments.ts @@ -418,12 +418,14 @@ export const sendOnchain = async (params) => { export const sendKeysend = async ({ amount, pubkey, - fee, + fee = undefined, memo = undefined, user, }) => { - let p = await debit({ - hash: pubkey, + fee = Math.max(parseInt(fee || amount * 0.005), 5); + + const p = await debit({ + hash: v4(), amount, fee, memo, @@ -431,9 +433,6 @@ export const sendKeysend = async ({ type: types.lightning, }); - fee = Math.max(parseInt(fee || 0), 5); - if (fee < 0) fail("Fee cannot be negative"); - const r = await ln.keysend({ pubkey, amount_msat: amount * 1000, @@ -441,11 +440,9 @@ export const sendKeysend = async ({ retry_for: 10, }); - try { - if (r.status === "complete") p = await finalize(r, p); - } catch (e) { - warn("failed to process payment", p.id); - } + if (r.status !== "complete") reverse(p); + + return r; }; export const sendLightning = async ({ |
