From 47919c94e861e98fc5c21956c3c53e896052aea4 Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Wed, 5 Aug 2026 12:39:05 -0700 Subject: Boards show the server their funding tx, as mainnet now insists Co-Authored-By: Claude Fable 5 Claude-Session: https://claude.ai/code/session_01M5kFodm9azZJVTQxnkDdKe --- src/ark/board.js | 7 ++++++- src/ark/manager.js | 2 ++ 2 files changed, 8 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/ark/board.js b/src/ark/board.js index 7544353..4192716 100644 --- a/src/ark/board.js +++ b/src/ark/board.js @@ -49,13 +49,18 @@ export function buildBoard({ userPub, serverPub, amountSat, feeSat, expiryHeight return { fundingTaproot, exitTaproot, exitTx, sighash }; } -export async function requestBoardCosign(ark, { amountSat, fundingOutpointRaw, expiryHeight, userPub, pubNonce }) { +export async function requestBoardCosign(ark, { amountSat, fundingOutpointRaw, expiryHeight, userPub, pubNonce, fundingTxBytes }) { const w = pbWriter(); w.varintField(1, amountSat); w.bytesField(2, fundingOutpointRaw); w.varintField(3, expiryHeight); w.bytesField(4, userPub); w.bytesField(5, pubNonce); + // Mandatory on mainnet since 0.6.0 (require_board_funding_tx): the server + // validates the board outpoint against the funding tx and refuses inputs + // that are VTXOs. The txid check ignores witnesses, so the broadcast + // (signed) serialization is fine here. + if (fundingTxBytes) w.bytesField(6, fundingTxBytes); const resp = await grpcCall(ark, 'bark_server.ArkService/RequestBoardCosign', w.finish()); const out = {}; for (const { field, value } of pbFields(resp)) { diff --git a/src/ark/manager.js b/src/ark/manager.js index a478d19..84c0769 100644 --- a/src/ark/manager.js +++ b/src/ark/manager.js @@ -1223,9 +1223,11 @@ export class ArkManager { fundingOutpointRaw, }); const nonces = musig2.nonceGen(keys.pubkey, keys.privkey, undefined, board.sighash); + const fundingTxHex = await this.chain.getTxHex(action.fundingTxid); const cosign = await requestBoardCosign(this.arkUrl, { amountSat: action.amountSat, fundingOutpointRaw, expiryHeight: action.expiryHeight, userPub: keys.pubkey, pubNonce: nonces.public, + fundingTxBytes: fundingTxHex ? hex.decode(fundingTxHex.trim()) : undefined, }); const finalSig = combineBoardSignature({ board, serverCosign: cosign, userNonces: nonces, vtxoKeys: keys, serverPub: this.serverPub }); action.vtxoBytes = hex.encode(encodeBoardVtxo({ -- cgit v1.2.3