@@ -2562,7 +2562,7 @@ export class Wallet implements IWallet {
25622562 }
25632563 userPrv = await decryptKeychainPrivateKey ( this . bitgo , userKeychain , params . walletPassphrase ) ;
25642564 if ( ! userPrv ) {
2565- throw new Error ( 'failed to decrypt user keychain' ) ;
2565+ throw new IncorrectPasswordError ( ) ;
25662566 }
25672567 }
25682568 return userPrv ;
@@ -4813,16 +4813,16 @@ export class Wallet implements IWallet {
48134813 await this . tssUtils . deleteSignatureShares ( txRequestId , reqId ) ;
48144814
48154815 try {
4816- const signedTxRequest = await this . tssUtils . signEddsaTssUsingExternalSigner (
4816+ return await this . tssUtils . signEddsaTssUsingExternalSigner (
48174817 txRequestId ,
48184818 params . customCommitmentGeneratingFunction ,
48194819 params . customRShareGeneratingFunction ,
48204820 params . customGShareGeneratingFunction ,
48214821 reqId
48224822 ) ;
4823- return signedTxRequest ;
48244823 } catch ( e ) {
4825- throw new Error ( 'failed to sign transaction ' + e ) ;
4824+ debug ( 'failed to sign transaction %O' , e ) ;
4825+ throw e ;
48264826 }
48274827 }
48284828
@@ -4919,9 +4919,9 @@ export class Wallet implements IWallet {
49194919 throw new Error ( 'Generator function for S share required to sign transactions with External Signer.' ) ;
49204920 }
49214921
4922+ assert ( this . tssUtils , 'tssUtils must be defined' ) ;
49224923 try {
4923- assert ( this . tssUtils , 'tssUtils must be defined' ) ;
4924- const signedTxRequest = await this . tssUtils . signEcdsaTssUsingExternalSigner (
4924+ return await this . tssUtils . signEcdsaTssUsingExternalSigner (
49254925 {
49264926 txRequest : txRequestId ,
49274927 reqId : params . reqId || new RequestTracer ( ) ,
@@ -4932,9 +4932,9 @@ export class Wallet implements IWallet {
49324932 params . customMuDeltaShareGeneratingFunction ,
49334933 params . customSShareGeneratingFunction
49344934 ) ;
4935- return signedTxRequest ;
49364935 } catch ( e ) {
4937- throw new Error ( 'failed to sign transaction ' + e ) ;
4936+ debug ( 'failed to sign transaction %O' , e ) ;
4937+ throw e ;
49384938 }
49394939 }
49404940
@@ -4974,9 +4974,9 @@ export class Wallet implements IWallet {
49744974 ) ;
49754975 }
49764976
4977+ assert ( this . tssUtils , 'tssUtils must be defined' ) ;
49774978 try {
4978- assert ( this . tssUtils , 'tssUtils must be defined' ) ;
4979- const signedTxRequest = await this . tssUtils . signEddsaMPCv2TssUsingExternalSigner (
4979+ return await this . tssUtils . signEddsaMPCv2TssUsingExternalSigner (
49804980 {
49814981 txRequest : txRequestId ,
49824982 reqId : params . reqId || new RequestTracer ( ) ,
@@ -4985,9 +4985,9 @@ export class Wallet implements IWallet {
49854985 params . customEddsaMPCv2SigningRound2GenerationFunction ,
49864986 params . customEddsaMPCv2SigningRound3GenerationFunction
49874987 ) ;
4988- return signedTxRequest ;
49894988 } catch ( e ) {
4990- throw new Error ( 'failed to sign transaction ' + e ) ;
4989+ debug ( 'failed to sign transaction %O' , e ) ;
4990+ throw e ;
49914991 }
49924992 }
49934993
@@ -5021,9 +5021,9 @@ export class Wallet implements IWallet {
50215021 throw new Error ( 'Generator function for MPCv2 Round 3 share required to sign transactions with External Signer.' ) ;
50225022 }
50235023
5024+ assert ( this . tssUtils , 'tssUtils must be defined' ) ;
50245025 try {
5025- assert ( this . tssUtils , 'tssUtils must be defined' ) ;
5026- const signedTxRequest = await this . tssUtils . signEcdsaMPCv2TssUsingExternalSigner (
5026+ return await this . tssUtils . signEcdsaMPCv2TssUsingExternalSigner (
50275027 {
50285028 txRequest : txRequestId ,
50295029 reqId : params . reqId || new RequestTracer ( ) ,
@@ -5032,9 +5032,9 @@ export class Wallet implements IWallet {
50325032 params . customMPCv2SigningRound2GenerationFunction ,
50335033 params . customMPCv2SigningRound3GenerationFunction
50345034 ) ;
5035- return signedTxRequest ;
50365035 } catch ( e ) {
5037- throw new Error ( 'failed to sign transaction ' + e ) ;
5036+ debug ( 'failed to sign transaction %O' , e ) ;
5037+ throw e ;
50385038 }
50395039 }
50405040
@@ -5056,23 +5056,23 @@ export class Wallet implements IWallet {
50565056 throw new Error ( 'prv required to sign transactions with TSS' ) ;
50575057 }
50585058
5059- try {
5060- let txRequest : string | TxRequest = params . txPrebuild . txRequestId ;
5061- let txParams : TransactionParams | undefined = params . txPrebuild . buildParams ;
5062-
5063- // EdDSA MPCv2 re-sign path: buildParams is absent when the UI calls signAndSendTxRequest with
5064- // only txRequestId. Derive txParams from the persisted intent so verifyTransaction receives
5065- // the correct recipients before DSG starts. Other TSS variants are unaffected by the guard.
5066- if ( ! txParams && this . multisigTypeVersion ( ) === 'MPCv2' && this . baseCoin . getMPCAlgorithm ( ) === 'eddsa' ) {
5067- txRequest = await getTxRequest (
5068- this . bitgo ,
5069- this . id ( ) ,
5070- params . txPrebuild . txRequestId ,
5071- params . reqId || new RequestTracer ( )
5072- ) ;
5073- txParams = txParamsFromIntent ( txRequest . intent , this . baseCoin . getChain ( ) ) ;
5074- }
5059+ let txRequest : string | TxRequest = params . txPrebuild . txRequestId ;
5060+ let txParams : TransactionParams | undefined = params . txPrebuild . buildParams ;
5061+
5062+ // EdDSA MPCv2 re-sign path: buildParams is absent when the UI calls signAndSendTxRequest with
5063+ // only txRequestId. Derive txParams from the persisted intent so verifyTransaction receives
5064+ // the correct recipients before DSG starts. Other TSS variants are unaffected by the guard.
5065+ if ( ! txParams && this . multisigTypeVersion ( ) === 'MPCv2' && this . baseCoin . getMPCAlgorithm ( ) === 'eddsa' ) {
5066+ txRequest = await getTxRequest (
5067+ this . bitgo ,
5068+ this . id ( ) ,
5069+ params . txPrebuild . txRequestId ,
5070+ params . reqId || new RequestTracer ( )
5071+ ) ;
5072+ txParams = txParamsFromIntent ( txRequest . intent , this . baseCoin . getChain ( ) ) ;
5073+ }
50755074
5075+ try {
50765076 return await this . tssUtils ! . signTxRequest ( {
50775077 txRequest,
50785078 txParams,
@@ -5081,7 +5081,8 @@ export class Wallet implements IWallet {
50815081 apiVersion : params . apiVersion ,
50825082 } ) ;
50835083 } catch ( e ) {
5084- throw new Error ( 'failed to sign transaction ' + e ) ;
5084+ debug ( 'failed to sign transaction %O' , e ) ;
5085+ throw e ;
50855086 }
50865087 }
50875088
@@ -5383,11 +5384,7 @@ export class Wallet implements IWallet {
53835384 // which means that the user is handling the signing in external signing mode
53845385 if ( ! customSigningFunction && keychains ?. [ 0 ] ?. encryptedPrv && walletPassphrase ) {
53855386 if ( ! ( await decryptKeychainPrivateKey ( this . bitgo , keychains [ 0 ] , walletPassphrase ) ) ) {
5386- const error : Error & { code ?: string } = new Error (
5387- `unable to decrypt keychain with the given wallet passphrase`
5388- ) ;
5389- error . code = 'wallet_passphrase_incorrect' ;
5390- throw error ;
5387+ throw new IncorrectPasswordError ( ) ;
53915388 }
53925389 }
53935390 return keychains ;
0 commit comments