Skip to content

Commit ad3c6c4

Browse files
committed
fix(sdk-core): add keychain info to transaction verification process, fixes unit tests
Ticket: WP-5945
1 parent 7300cc0 commit ad3c6c4

File tree

2 files changed

+24
-13
lines changed

2 files changed

+24
-13
lines changed

modules/bitgo/test/v2/unit/wallet.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1589,6 +1589,7 @@ describe('V2 Wallet:', function () {
15891589
'unsigned'
15901590
)
15911591
);
1592+
psbts.forEach((psbt) => utxoLib.bitgo.addXpubsToPsbt(psbt, rootWalletKey));
15921593
const txHexes = psbts.map((psbt) => ({ txHex: psbt.toHex() }));
15931594

15941595
const nocks: nock.Scope[] = [];
@@ -1627,6 +1628,7 @@ describe('V2 Wallet:', function () {
16271628
rootWalletKey,
16281629
'unsigned'
16291630
);
1631+
utxoLib.bitgo.addXpubsToPsbt(psbt, rootWalletKey);
16301632

16311633
const nocks: nock.Scope[] = [];
16321634
nocks.push(

modules/sdk-core/src/bitgo/wallet/wallet.ts

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -735,24 +735,33 @@ export class Wallet implements IWallet {
735735
return buildResponse;
736736
}
737737

738+
const keychains = (await this.baseCoin
739+
.keychains()
740+
.getKeysForSigning({ wallet: this, reqId })) as unknown as Keychain[];
741+
738742
// Validate that the platform-built transaction matches user parameters
739743
const txPrebuilds = Array.isArray(buildResponse) ? buildResponse : [buildResponse];
740744
await Promise.all(
741-
txPrebuilds.map((txPrebuild) =>
742-
this.baseCoin.verifyTransaction({
743-
txParams: params,
744-
txPrebuild,
745-
wallet: this,
746-
verification: params.verification ?? {},
747-
reqId,
748-
})
749-
)
745+
txPrebuilds
746+
.filter((txPrebuild) => txPrebuild.txHex)
747+
.map((txPrebuild) =>
748+
this.baseCoin.verifyTransaction({
749+
txParams: params,
750+
txPrebuild,
751+
wallet: this,
752+
verification: {
753+
...(params.verification ?? {}),
754+
keychains: {
755+
user: keychains[0],
756+
backup: keychains[1],
757+
bitgo: keychains[2],
758+
},
759+
},
760+
reqId,
761+
})
762+
)
750763
);
751764

752-
const keychains = (await this.baseCoin
753-
.keychains()
754-
.getKeysForSigning({ wallet: this, reqId })) as unknown as Keychain[];
755-
756765
const transactionParams = {
757766
...params,
758767
keychain: keychains[0],

0 commit comments

Comments
 (0)