Skip to content

Commit

Permalink
Merge pull request #4848 from BitGo/WP-2523
Browse files Browse the repository at this point in the history
feat(sdk-core): improve wallet.signTransaction to get the user key
  • Loading branch information
margueriteblair committed Aug 29, 2024
2 parents 3bf04d5 + c52a484 commit 61a3215
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
1 change: 1 addition & 0 deletions modules/sdk-core/src/bitgo/wallet/iWallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,7 @@ export interface WalletSignTransactionOptions extends WalletSignBaseOptions {
customMPCv2SigningRound3GenerationFunction?: CustomMPCv2SigningRound3GeneratingFunction;
apiVersion?: ApiVersion;
multisigTypeVersion?: 'MPCv2';
walletPassphrase?: string;
[index: string]: unknown;
}

Expand Down
15 changes: 15 additions & 0 deletions modules/sdk-core/src/bitgo/wallet/wallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1717,6 +1717,21 @@ export class Wallet implements IWallet {
params.txPrebuild = { txRequestId };
}

if (params.walletPassphrase && !(params.keychain || params.key)) {
if (!_.isString(params.walletPassphrase)) {
throw new Error('walletPassphrase must be a string');
}
const keychains = await this.getKeychainsAndValidatePassphrase({
reqId: params.reqId,
walletPassphrase: params.walletPassphrase,
});
const userKeychain = keychains[0];
if (!userKeychain || !userKeychain.encryptedPrv) {
throw new Error('the user keychain does not have property encryptedPrv');
}
params.keychain = userKeychain;
}

const presign = await this.baseCoin.presignTransaction({
...params,
walletData: this._wallet,
Expand Down

0 comments on commit 61a3215

Please sign in to comment.