Skip to content

Commit

Permalink
fix(sign): skip address validation for non instant-buy psbt
Browse files Browse the repository at this point in the history
  • Loading branch information
iamcrazycoder committed Jul 17, 2023
1 parent a5a1813 commit 77e838a
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions packages/sdk/src/wallet/Ordit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ export class Ordit {
return accounts;
}

signPsbt(value: string, { finalized = true }: { finalized?: boolean }) {
signPsbt(value: string, { finalized = true, instantBuy = false }: SignPSBTOptions) {
const networkObj = getNetwork(this.#network);
let psbt: bitcoin.Psbt | null = null;

Expand Down Expand Up @@ -194,7 +194,9 @@ export class Ordit {
const isSigned = v.finalScriptSig || v.finalScriptWitness;
if (script && !isSigned) {
const address = bitcoin.address.fromOutputScript(script, networkObj);
if (this.selectedAddress === address) {

// TODO: improvise the below logic by accepting indexes to sign
if (!instantBuy || (instantBuy && this.selectedAddress === address)) {
inputsToSign.push({
index,
publicKey: this.publicKey,
Expand Down Expand Up @@ -336,3 +338,8 @@ export interface Input {
publicKey: string;
sighashTypes?: number[];
}

export interface SignPSBTOptions {
finalized?: boolean;
instantBuy?: boolean;
}

0 comments on commit 77e838a

Please sign in to comment.