From 50ca83a0f21fb8090ba39481cf3d331c331d26ba Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Fri, 4 Dec 2026 13:24:12 -0700 Subject: ark: completeBoard takes the funding output's index. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit A service boarding coins paid from another wallet (the ark → ark2 migrator's float) can't count on the board output being first; the outpoint now carries the index the caller found (default 0, which is what the app's own wallet always produces). Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01VMan6WoqaQDYdpWkatPCar --- src/ark/manager.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/ark/manager.js b/src/ark/manager.js index fc298d9..d85c563 100644 --- a/src/ark/manager.js +++ b/src/ark/manager.js @@ -2390,11 +2390,15 @@ export class ArkManager { return { actionId: action.id, fundingAddress: p2trAddress(probe.fundingTaproot.outputXOnly, hrp), feeSat }; } - async completeBoard(actionId, fundingTxid) { + // fundingVout: where the board output sits in the funding tx. The app's own + // wallet always puts it first; another wallet (paying a service's board + // address) may not, so the caller can say. + async completeBoard(actionId, fundingTxid, fundingVout = 0) { const action = this.state.actions.find((a) => a.id === actionId); if (!action || action.type !== 'board') throw new Error('unknown board action'); if (action.step === 'created') { action.fundingTxid = fundingTxid; + action.fundingVout = fundingVout; action.step = 'funded'; this._save(); } @@ -2430,7 +2434,8 @@ export class ArkManager { if (!(confs >= need)) return; // retried on sync const fundingOutpointRaw = new Uint8Array(36); - fundingOutpointRaw.set(hex.decode(action.fundingTxid).reverse(), 0); // vout 0 + fundingOutpointRaw.set(hex.decode(action.fundingTxid).reverse(), 0); + new DataView(fundingOutpointRaw.buffer).setUint32(32, action.fundingVout || 0, true); // vout, little-endian const board = buildBoard({ userPub: keys.pubkey, serverPub: this.serverPub, amountSat: action.amountSat, feeSat: action.feeSat, -- cgit v1.2.3