From 7420afa66aaa5be478b8ef182e30c3c7b2f33575 Mon Sep 17 00:00:00 2001 From: Nishant Ghodke <64554492+iamcrazycoder@users.noreply.github.com> Date: Fri, 29 Sep 2023 12:48:07 +0530 Subject: [PATCH] feat(sdk): add sigHash to inputsToSign getter (#75) --- packages/sdk/src/transactions/PSBTBuilder.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/packages/sdk/src/transactions/PSBTBuilder.ts b/packages/sdk/src/transactions/PSBTBuilder.ts index 066bf0d1..7a37a78e 100644 --- a/packages/sdk/src/transactions/PSBTBuilder.ts +++ b/packages/sdk/src/transactions/PSBTBuilder.ts @@ -1,5 +1,5 @@ /* eslint-disable @typescript-eslint/no-extra-semi */ -import { networks, Psbt } from "bitcoinjs-lib" +import { networks, Psbt, Transaction } from "bitcoinjs-lib" import reverseBuffer from "buffer-reverse" import { @@ -133,12 +133,17 @@ export class PSBTBuilder extends FeeEstimator { } get inputsToSign() { + const instantTradeSellerFlow = this.instantTradeMode && !this.autoAdjustment return this.psbt.txInputs.reduce( (acc, _, index) => { if (!this.instantTradeMode || (this.instantTradeMode && index !== INSTANT_BUY_SELLER_INPUT_INDEX)) { acc.signingIndexes = acc.signingIndexes.concat(index) } + if (instantTradeSellerFlow) { + acc.sigHash = Transaction.SIGHASH_SINGLE | Transaction.SIGHASH_ANYONECANPAY + } + return acc }, {