From eed26cd58d04d90a0dd04440859366a801740d40 Mon Sep 17 00:00:00 2001 From: Nishant Ghodke Date: Thu, 27 Jul 2023 10:44:48 +0530 Subject: [PATCH] fix: deduct custom outs total to calculate correct change --- packages/sdk/src/transactions/OrdTransaction.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/sdk/src/transactions/OrdTransaction.ts b/packages/sdk/src/transactions/OrdTransaction.ts index 13685cad..4514dc11 100644 --- a/packages/sdk/src/transactions/OrdTransaction.ts +++ b/packages/sdk/src/transactions/OrdTransaction.ts @@ -86,7 +86,10 @@ export class OrdTransaction { fees = calculateTxFeeWithRate(1, 0, this.feeRate, 1); } - const change = this.#suitableUnspent.sats - fees; + const customOutsAmount = this.#outs.reduce((acc, cur) => { + return acc + cur.value; + }, 0); + const change = this.#suitableUnspent.sats - fees - customOutsAmount; const networkObj = getNetwork(this.network);