From 8465744ca75accd6289638becf42c6f7137a7de5 Mon Sep 17 00:00:00 2001 From: Marzooqa Naeema Kather Date: Mon, 19 Jan 2026 15:39:56 +0530 Subject: [PATCH] fix: sanitize wallet object from logs TICKET: WP-7489 --- modules/sdk-core/src/bitgo/wallet/wallet.ts | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/modules/sdk-core/src/bitgo/wallet/wallet.ts b/modules/sdk-core/src/bitgo/wallet/wallet.ts index 5f600dc158..7d356a013b 100644 --- a/modules/sdk-core/src/bitgo/wallet/wallet.ts +++ b/modules/sdk-core/src/bitgo/wallet/wallet.ts @@ -2407,7 +2407,15 @@ export class Wallet implements IWallet { 'transaction params:', _.omit(params, ['keychain', 'prv', 'passphrase', 'walletPassphrase', 'key', 'wallet']) ); - console.error('transaction prebuild:', txPrebuild); + // Sanitize to remove _token from bitgo + const sanitizedPrebuild = { + ..._.omit(txPrebuild, ['wallet']), + wallet: { + ...this, + bitgo: _.omit(this.bitgo, ['_token']), + }, + }; + console.error('transaction prebuild:', sanitizedPrebuild); console.trace(e); throw e; } @@ -2449,7 +2457,13 @@ export class Wallet implements IWallet { confirmedBalance: this.confirmedBalance(), spendableBalance: this.spendableBalance(), }; - error.txParams = _.omit(params, ['keychain', 'prv', 'passphrase', 'walletPassphrase', 'key']); + error.txParams = { + ..._.omit(params, ['keychain', 'prv', 'passphrase', 'walletPassphrase', 'key', 'wallet']), + wallet: { + ...this, + bitgo: _.omit(this.bitgo, ['_token']), + }, + }; } throw error; }