Skip to content

Commit

Permalink
feat(sdk): add sigHash to inputsToSign getter (#75)
Browse files Browse the repository at this point in the history
  • Loading branch information
iamcrazycoder authored Sep 29, 2023
1 parent b1ef7b5 commit 7420afa
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion packages/sdk/src/transactions/PSBTBuilder.ts
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down Expand Up @@ -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
},
{
Expand Down

0 comments on commit 7420afa

Please sign in to comment.