Skip to content

Commit 4584ba5

Browse files
authored
Merge pull request #8538 from BitGo/revert-WAL-375-8462
Revert "Merge pull request #8462 from BitGo/WAL-375-mpcv2-sign-tx-req
2 parents 6bc1fd3 + dfbcd47 commit 4584ba5

7 files changed

Lines changed: 8 additions & 104 deletions

File tree

modules/bitgo/test/v2/unit/internal/tssUtils/ecdsa.ts

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -747,7 +747,6 @@ describe('TSS Ecdsa Utils:', async function () {
747747
backupNShare: backupKeyShare.nShares[1],
748748
}),
749749
reqId,
750-
txParams: { recipients: [{ address: '0xrecipient', amount: '1000' }] },
751750
});
752751
signedTxRequest.unsignedTxs.should.deepEqual(txRequest.unsignedTxs);
753752
const userGpgActual = sendShareSpy.getCalls()[0].args[10] as string;
@@ -765,46 +764,12 @@ describe('TSS Ecdsa Utils:', async function () {
765764
backupNShare: backupKeyShare.nShares[1],
766765
}),
767766
reqId,
768-
txParams: { recipients: [{ address: '0xrecipient', amount: '1000' }] },
769767
});
770768
signedTxRequest.unsignedTxs.should.deepEqual(txRequest.unsignedTxs);
771769
const userGpgActual = sendShareSpy.getCalls()[0].args[10] as string;
772770
userGpgActual.should.startWith('-----BEGIN PGP PUBLIC KEY BLOCK-----');
773771
});
774772

775-
it('signTxRequest should fail when txParams is missing', async function () {
776-
await tssUtils
777-
.signTxRequest({
778-
txRequest,
779-
prv: JSON.stringify({
780-
pShare: userKeyShare.pShare,
781-
bitgoNShare: bitgoKeyShare.nShares[1],
782-
backupNShare: backupKeyShare.nShares[1],
783-
}),
784-
reqId,
785-
})
786-
.should.be.rejectedWith(
787-
'Recipient details are required to verify this transaction before signing. Pass txParams with at least one recipient.'
788-
);
789-
});
790-
791-
it('signTxRequest should fail when txParams has empty recipients', async function () {
792-
await tssUtils
793-
.signTxRequest({
794-
txRequest,
795-
prv: JSON.stringify({
796-
pShare: userKeyShare.pShare,
797-
bitgoNShare: bitgoKeyShare.nShares[1],
798-
backupNShare: backupKeyShare.nShares[1],
799-
}),
800-
reqId,
801-
txParams: { recipients: [] },
802-
})
803-
.should.be.rejectedWith(
804-
'Recipient details are required to verify this transaction before signing. Pass txParams with at least one recipient.'
805-
);
806-
});
807-
808773
it('signTxRequest should fail with wrong recipient', async function () {
809774
// To generate these Hex values, we used the bitgo-ui to create a transaction and then
810775
// used the `signableHex` and `serializedTxHex` values from the prebuild.

modules/bitgo/test/v2/unit/internal/tssUtils/ecdsaMPCv2/signTxRequest.ts

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,6 @@ describe('signTxRequest:', function () {
193193
txRequest,
194194
prv: userPrvBase64,
195195
reqId,
196-
txParams: { recipients: [{ address: '0xrecipient', amount: '1000' }] },
197196
});
198197
nockPromises[0].isDone().should.be.true();
199198
nockPromises[1].isDone().should.be.true();
@@ -216,7 +215,6 @@ describe('signTxRequest:', function () {
216215
prv: backupPrvBase64,
217216
mpcv2PartyId: 1,
218217
reqId,
219-
txParams: { recipients: [{ address: '0xrecipient', amount: '1000' }] },
220218
});
221219
nockPromises[0].isDone().should.be.true();
222220
nockPromises[1].isDone().should.be.true();
@@ -238,7 +236,6 @@ describe('signTxRequest:', function () {
238236
txRequest,
239237
prv: userPrvBase64,
240238
reqId,
241-
txParams: { recipients: [{ address: '0xrecipient', amount: '1000' }] },
242239
});
243240
nockPromises[0].isDone().should.be.true();
244241
nockPromises[1].isDone().should.be.true();
@@ -260,7 +257,6 @@ describe('signTxRequest:', function () {
260257
txRequest,
261258
prv: userPrvBase64,
262259
reqId,
263-
txParams: { recipients: [{ address: '0xrecipient', amount: '1000' }] },
264260
});
265261
nockPromises[0].isDone().should.be.true();
266262
nockPromises[1].isDone().should.be.true();
@@ -281,41 +277,11 @@ describe('signTxRequest:', function () {
281277
txRequest,
282278
prv: userPrvBase64,
283279
reqId,
284-
txParams: { recipients: [{ address: '0xrecipient', amount: '1000' }] },
285280
})
286281
.should.be.rejectedWith('Too many requests, slow down!');
287282
nockPromises[0].isDone().should.be.true();
288283
nockPromises[1].isDone().should.be.false();
289284
});
290-
291-
it('rejects signTxRequest when txParams is missing', async function () {
292-
const userShare = fs.readFileSync(shareFiles[vector.party1]);
293-
const userPrvBase64 = Buffer.from(userShare).toString('base64');
294-
await tssUtils
295-
.signTxRequest({
296-
txRequest,
297-
prv: userPrvBase64,
298-
reqId,
299-
})
300-
.should.be.rejectedWith(
301-
'Recipient details are required to verify this transaction before signing. Pass txParams with at least one recipient.'
302-
);
303-
});
304-
305-
it('rejects signTxRequest when txParams has empty recipients', async function () {
306-
const userShare = fs.readFileSync(shareFiles[vector.party1]);
307-
const userPrvBase64 = Buffer.from(userShare).toString('base64');
308-
await tssUtils
309-
.signTxRequest({
310-
txRequest,
311-
prv: userPrvBase64,
312-
reqId,
313-
txParams: { recipients: [] },
314-
})
315-
.should.be.rejectedWith(
316-
'Recipient details are required to verify this transaction before signing. Pass txParams with at least one recipient.'
317-
);
318-
});
319285
});
320286

321287
export function getBitGoPartyGpgKeyPrv(key: openpgp.SerializedKeyPair<string>): DklsTypes.PartyGpgKey {

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -246,9 +246,7 @@ export class PendingApproval implements IPendingApproval {
246246
}
247247

248248
const decryptedPrv = await this.wallet.getPrv({ walletPassphrase });
249-
const pendingApprovalRecipients = this._pendingApproval.info?.transactionRequest?.recipients;
250-
const txParams = pendingApprovalRecipients?.length ? { recipients: pendingApprovalRecipients } : undefined;
251-
const txRequest = await this.tssUtils!.recreateTxRequest(txRequestId, decryptedPrv, reqId, txParams);
249+
const txRequest = await this.tssUtils!.recreateTxRequest(txRequestId, decryptedPrv, reqId);
252250
if (txRequest.apiVersion === 'lite') {
253251
if (!txRequest.unsignedTxs || txRequest.unsignedTxs.length === 0) {
254252
throw new Error('Unexpected error, no transactions found in txRequest.');

modules/sdk-core/src/bitgo/utils/tss/baseTSSUtils.ts

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ import {
3939
TxRequest,
4040
TxRequestVersion,
4141
} from './baseTypes';
42-
import { TransactionParams } from '../../baseCoin/iBaseCoin';
4342
import { GShare, SignShare } from '../../../account-lib/mpc/tss';
4443
import { RequestTracer } from '../util';
4544
import { envRequiresBitgoPubGpgKeyConfig, getBitgoMpcGpgPubKey } from '../../tss/bitgoPubKeys';
@@ -534,16 +533,11 @@ export default class BaseTssUtils<KeyShare> extends MpcUtils implements ITssUtil
534533
* @param {RequestTracer} reqId id tracer.
535534
* @returns {Promise<any>}
536535
*/
537-
async recreateTxRequest(
538-
txRequestId: string,
539-
decryptedPrv: string,
540-
reqId: IRequestTracer,
541-
txParams?: TransactionParams
542-
): Promise<TxRequest> {
536+
async recreateTxRequest(txRequestId: string, decryptedPrv: string, reqId: IRequestTracer): Promise<TxRequest> {
543537
await this.deleteSignatureShares(txRequestId, reqId);
544538
// after delete signatures shares get the tx without them
545539
const txRequest = await getTxRequest(this.bitgo, this.wallet.id(), txRequestId, reqId);
546-
return await this.signTxRequest({ txRequest, prv: decryptedPrv, reqId, txParams });
540+
return await this.signTxRequest({ txRequest, prv: decryptedPrv, reqId });
547541
}
548542

549543
/**

modules/sdk-core/src/bitgo/utils/tss/baseTypes.ts

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -759,12 +759,7 @@ export interface ITssUtils<KeyShare = EDDSA.KeyShare> {
759759
deleteSignatureShares(txRequestId: string): Promise<SignatureShareRecord[]>;
760760
// eslint-disable-next-line @typescript-eslint/no-explicit-any
761761
sendTxRequest(txRequestId: string): Promise<any>;
762-
recreateTxRequest(
763-
txRequestId: string,
764-
decryptedPrv: string,
765-
reqId: IRequestTracer,
766-
txParams?: TransactionParams
767-
): Promise<TxRequest>;
762+
recreateTxRequest(txRequestId: string, decryptedPrv: string, reqId: IRequestTracer): Promise<TxRequest>;
768763
getTxRequest(txRequestId: string): Promise<TxRequest>;
769764
supportedTxRequestVersions(): TxRequestVersion[];
770765
}

modules/sdk-core/src/bitgo/utils/tss/ecdsa/ecdsa.ts

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ import {
4747
} from '../../../tss/types';
4848
import { BaseEcdsaUtils } from './base';
4949
import { IRequestTracer } from '../../../../api';
50-
import { InvalidTransactionError } from '../../../errors';
5150

5251
const encryptNShare = ECDSAMethods.encryptNShare;
5352

@@ -746,27 +745,21 @@ export class EcdsaUtils extends BaseEcdsaUtils {
746745
const unsignedTx =
747746
txRequest.apiVersion === 'full' ? txRequest.transactions![0].unsignedTx : txRequest.unsignedTxs[0];
748747

749-
if (!params.txParams?.recipients?.length) {
750-
throw new InvalidTransactionError(
751-
'Recipient details are required to verify this transaction before signing. Pass txParams with at least one recipient.'
752-
);
753-
}
754-
755748
// For ICP transactions, the HSM signs the serializedTxHex, while the user signs the signableHex separately.
756749
// Verification cannot be performed directly on the signableHex alone. However, we can parse the serializedTxHex
757750
// to regenerate the signableHex and compare it against the provided value for verification.
758751
// In contrast, for other coin families, verification is typically done using just the signableHex.
759752
if (this.baseCoin.getConfig().family === 'icp') {
760753
await this.baseCoin.verifyTransaction({
761754
txPrebuild: { txHex: unsignedTx.serializedTxHex, txInfo: unsignedTx.signableHex },
762-
txParams: params.txParams,
755+
txParams: params.txParams || { recipients: [] },
763756
wallet: this.wallet,
764757
walletType: this.wallet.multisigType(),
765758
});
766759
} else {
767760
await this.baseCoin.verifyTransaction({
768761
txPrebuild: { txHex: unsignedTx.signableHex },
769-
txParams: params.txParams,
762+
txParams: params.txParams || { recipients: [] },
770763
wallet: this.wallet,
771764
walletType: this.wallet.multisigType(),
772765
});

modules/sdk-core/src/bitgo/utils/tss/ecdsa/ecdsaMPCv2.ts

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ import {
3232
verifyBitGoMessagesAndSignaturesRoundOne,
3333
verifyBitGoMessagesAndSignaturesRoundTwo,
3434
} from '../../../tss/ecdsa/ecdsaMPCv2';
35-
import { InvalidTransactionError } from '../../../errors';
3635
import { KeyCombined } from '../../../tss/ecdsa/types';
3736
import { generateGPGKeyPair } from '../../opengpgUtils';
3837
import {
@@ -737,27 +736,21 @@ export class EcdsaMPCv2Utils extends BaseEcdsaUtils {
737736
const unsignedTx =
738737
txRequest.apiVersion === 'full' ? txRequest.transactions![0].unsignedTx : txRequest.unsignedTxs[0];
739738

740-
if (!params.txParams?.recipients?.length) {
741-
throw new InvalidTransactionError(
742-
'Recipient details are required to verify this transaction before signing. Pass txParams with at least one recipient.'
743-
);
744-
}
745-
746739
// For ICP transactions, the HSM signs the serializedTxHex, while the user signs the signableHex separately.
747740
// Verification cannot be performed directly on the signableHex alone. However, we can parse the serializedTxHex
748741
// to regenerate the signableHex and compare it against the provided value for verification.
749742
// In contrast, for other coin families, verification is typically done using just the signableHex.
750743
if (this.baseCoin.getConfig().family === 'icp') {
751744
await this.baseCoin.verifyTransaction({
752745
txPrebuild: { txHex: unsignedTx.serializedTxHex, txInfo: unsignedTx.signableHex },
753-
txParams: params.txParams,
746+
txParams: params.txParams || { recipients: [] },
754747
wallet: this.wallet,
755748
walletType: this.wallet.multisigType(),
756749
});
757750
} else {
758751
await this.baseCoin.verifyTransaction({
759752
txPrebuild: { txHex: unsignedTx.signableHex },
760-
txParams: params.txParams,
753+
txParams: params.txParams || { recipients: [] },
761754
wallet: this.wallet,
762755
walletType: this.wallet.multisigType(),
763756
});

0 commit comments

Comments
 (0)