Skip to content

Commit

Permalink
feat(sdk-core): improve wallet.signTransaction to get the user key
Browse files Browse the repository at this point in the history
In order to allow the signTssTx express endpoint to sign tx without external signer, we need to
modify the signTransaction method to get the key if the walletPassphrase is provided

WP-2535

TICKET: WP-2523
  • Loading branch information
alebusse committed Aug 23, 2024
1 parent 6f665f2 commit c52a484
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 c52a484

Please sign in to comment.