From fad003e639bbfe418795dc8a0130ac45dbf872e4 Mon Sep 17 00:00:00 2001 From: sosaucily Date: Thu, 8 Jan 2026 16:23:49 +0100 Subject: [PATCH 1/2] feat: add optional destination address parameter to withdraw functions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add destinationAddress parameter to createWithdrawTransaction and related handler methods. This allows specifying a custom destination for withdrawals (e.g., Bitsafe address for iBTC sunset) instead of always using the user's payment address. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 --- src/dlc-handlers/abstract-dlc-handler.ts | 6 ++++-- src/dlc-handlers/ledger-dlc-handler.ts | 6 ++++-- src/functions/bitcoin/psbt-functions.ts | 11 +++++++---- 3 files changed, 15 insertions(+), 8 deletions(-) diff --git a/src/dlc-handlers/abstract-dlc-handler.ts b/src/dlc-handlers/abstract-dlc-handler.ts index 17abafb..599953f 100644 --- a/src/dlc-handlers/abstract-dlc-handler.ts +++ b/src/dlc-handlers/abstract-dlc-handler.ts @@ -182,7 +182,8 @@ export abstract class AbstractDLCHandler { fundingTransactionID: string, feeRecipient: string, feeRateMultiplier?: number, - customFeeRate?: bigint + customFeeRate?: bigint, + destinationAddress?: string ): Promise { const { fundingPayment, multisigPayment } = await this.createPaymentInformation( vault.uuid, @@ -200,7 +201,8 @@ export abstract class AbstractDLCHandler { fundingPayment, feeRate, feeRecipient, - vault.btcRedeemFeeBasisPoints.toBigInt() + vault.btcRedeemFeeBasisPoints.toBigInt(), + destinationAddress ); } diff --git a/src/dlc-handlers/ledger-dlc-handler.ts b/src/dlc-handlers/ledger-dlc-handler.ts index 5b228b5..32ecccb 100644 --- a/src/dlc-handlers/ledger-dlc-handler.ts +++ b/src/dlc-handlers/ledger-dlc-handler.ts @@ -318,7 +318,8 @@ export class LedgerDLCHandler extends AbstractDLCHandler { fundingTransactionID: string, feeRecipient: string, feeRateMultiplier?: number, - customFeeRate?: bigint + customFeeRate?: bigint, + destinationAddress?: string ): Promise { try { const { fundingPayment, taprootDerivedPublicKey, multisigPayment } = await this.createPayment( @@ -337,7 +338,8 @@ export class LedgerDLCHandler extends AbstractDLCHandler { fundingPayment, feeRate, feeRecipient, - vault.btcRedeemFeeBasisPoints.toBigInt() + vault.btcRedeemFeeBasisPoints.toBigInt(), + destinationAddress ); const withdrawTransactionSigningConfiguration = createBitcoinInputSigningConfiguration( diff --git a/src/functions/bitcoin/psbt-functions.ts b/src/functions/bitcoin/psbt-functions.ts index ff5c238..f26f8d4 100644 --- a/src/functions/bitcoin/psbt-functions.ts +++ b/src/functions/bitcoin/psbt-functions.ts @@ -244,7 +244,7 @@ export async function createDepositTransaction( /** * Creates a Withdraw Transaction to withdraw Bitcoin from a Vault. * Uses the existing Vault's Funding Transaction ID to create the Withdraw Transaction. - * The specified amount of Bitcoin is sent to the User's Address. + * The specified amount of Bitcoin is sent to the User's Address (or custom destination if provided). * The remaining amount is sent back to the Vault's Multisig Address. * * @param bitcoinBlockchainURL - The Bitcoin Blockchain URL used to fetch the Vault's Funding Transaction. @@ -252,10 +252,11 @@ export async function createDepositTransaction( * @param withdrawAmount - The amount of Bitcoin to withdraw from the Vault. * @param vaultTransactionID - The ID of the Vault Funding Transaction. * @param multisigPayment - The Multisig Payment object created from the User's Taproot Public Key, the Attestor's Public Key, and the Unspendable Public Key committed to the Vault's UUID. - * @param withdrawPayment - The User's Payment object which will be used to receive the withdrawn Bitcoin. + * @param withdrawPayment - The User's Payment object which will be used to receive the withdrawn Bitcoin (if no custom destination is provided). * @param feeRate - The Fee Rate to use for the Transaction. * @param feeRecipient - The Fee Recipient's Public Key or Address. * @param feeBasisPoints - The Fee Basis Points. + * @param destinationAddress - Optional custom destination address for the withdrawn Bitcoin. If not provided, uses the withdrawPayment address. * @returns A Withdraw Transaction. */ export async function createWithdrawTransaction( @@ -267,7 +268,8 @@ export async function createWithdrawTransaction( withdrawPayment: P2Ret | P2TROut, feeRate: bigint, feeRecipient: string, - feeBasisPoints: bigint + feeBasisPoints: bigint, + destinationAddress?: string ): Promise { const multisigAddress = multisigPayment.address; @@ -275,7 +277,8 @@ export async function createWithdrawTransaction( throw new Error('Multisig Transaction is missing Address'); } - const withdrawAddress = withdrawPayment.address; + // Use custom destination address if provided, otherwise use the withdraw payment address + const withdrawAddress = destinationAddress ?? withdrawPayment.address; if (!withdrawAddress) { throw new Error('Withdraw Payment is missing Address'); From 82054e8a705bb40d3ae5afac084d394a9aed6626 Mon Sep 17 00:00:00 2001 From: sosaucily Date: Thu, 8 Jan 2026 16:48:51 +0100 Subject: [PATCH 2/2] chore: add prepare script to build on git install MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When installing from a git reference, npm doesn't include the dist/ folder. Adding a prepare script ensures the package builds automatically after being cloned. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 --- package.json | 1 + 1 file changed, 1 insertion(+) diff --git a/package.json b/package.json index ccfe87c..7eb0fb3 100644 --- a/package.json +++ b/package.json @@ -21,6 +21,7 @@ "./starknet-functions": "./dist/functions/starknet/index.js" }, "scripts": { + "prepare": "npm run build", "clean": "rm -rf dist && rm -rf node_modules", "build": "rm -rf dist && tsc", "test": "jest",