aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2026-03-12 17:09:01 -0700
committerAdam Soltys <[email protected]>2026-03-13 15:14:51 -0700
commitd3ee2bbc3baa33140f18a95c3e4b78a797330ad0 (patch)
tree53692c72057f824628cc740f5766f8169b169be5 /lib
parent6cdb3175ec10fcf27efea6d4ed076af33f19d3ac (diff)
downloadcoinos-server-d3ee2bbc3baa33140f18a95c3e4b78a797330ad0.tar.gz
coinos-server-d3ee2bbc3baa33140f18a95c3e4b78a797330ad0.zip
ark fixes
Diffstat (limited to 'lib')
-rw-r--r--lib/ark.ts14
-rw-r--r--lib/payments.ts18
2 files changed, 23 insertions, 9 deletions
diff --git a/lib/ark.ts b/lib/ark.ts
index 65f43e16..3fc33ef6 100644
--- a/lib/ark.ts
+++ b/lib/ark.ts
@@ -28,7 +28,13 @@ const getWallet = async () => {
let refreshing = false;
let lastRefresh = 0;
const REFRESH_COOLDOWN = 30_000;
-const failedBoardingOutpoints = new Set<string>();
+let failedBoardingOutpoints = new Set<string>();
+const FAILED_BOARDING_KEY = "ark:failedBoardingOutpoints";
+const loadFailedOutpoints = async () => {
+ const members = await db.sMembers(FAILED_BOARDING_KEY);
+ failedBoardingOutpoints = new Set(members);
+};
+loadFailedOutpoints();
let recoveryFailures = 0;
let renewalFailures = 0;
@@ -147,10 +153,14 @@ export const refreshArkWallet = async (force = false) => {
l("ark onboarded boarding utxo:", utxo.value, "sats, txid:", txid);
await logArkOp("onboard", { txid, amount: utxo.value, boardingTxid: utxo.txid, vout: utxo.vout });
failedBoardingOutpoints.clear();
+ await db.del(FAILED_BOARDING_KEY);
break;
} catch (e: any) {
const retriable = /not enough intent confirmations|timed out|signing_session/i.test(e.message);
- if (!retriable) failedBoardingOutpoints.add(outpointKey(utxo));
+ if (!retriable) {
+ failedBoardingOutpoints.add(outpointKey(utxo));
+ await db.sAdd(FAILED_BOARDING_KEY, outpointKey(utxo));
+ }
warn("ark onboard failed:", utxo.value, "sats:", e.message);
}
}
diff --git a/lib/payments.ts b/lib/payments.ts
index 417c0b8d..dfbdd3c4 100644
--- a/lib/payments.ts
+++ b/lib/payments.ts
@@ -390,9 +390,9 @@ export const completePayment = async (inv, p, user) => {
inv.forwarded = true;
await s(`invoice:${inv.id}`, inv);
- // Skip forward if destination belongs to the same user
+ // Skip forward if destination is the same account (not just same user)
const destInv = await getInvoice(inv.forward).catch(() => null);
- if (destInv?.uid === id) return;
+ if (destInv?.uid === id && destInv?.aid === aid) return;
await pay({ amount: p.amount, to: inv.forward, user });
} catch (e) {
@@ -762,6 +762,7 @@ export const sendOnchain = async (params) => {
p.fee = fee;
p.hex = hex;
+ (p as any).address = params.address;
(p as any).bumpReserve = bumpReserve;
(p as any).p2aVout = p2aVout;
(p as any).parentVsize = parentVsize;
@@ -896,19 +897,22 @@ export const sendOnchain = async (params) => {
p.fee = fee;
p.hex = hex;
+ (p as any).address = params.address;
- if (isBitcoin && bumpReserve > 0) {
- (p as any).bumpReserve = bumpReserve;
- (p as any).p2aVout = p2aVout;
- (p as any).parentVsize = parentVsize;
+ if (isBitcoin) {
p.confirmed = false;
+ if (bumpReserve > 0) {
+ (p as any).bumpReserve = bumpReserve;
+ (p as any).p2aVout = p2aVout;
+ (p as any).parentVsize = parentVsize;
+ }
}
await s(`payment:${p.id}`, p);
await node.sendRawTransaction(hex);
- if (isBitcoin && bumpReserve > 0) {
+ if (isBitcoin) {
await db.sAdd("outgoing:unconfirmed", p.id);
}