Skip to content

Commit 27c4e89

Browse files
OttoAllmendingerllm-git
andcommitted
fix(abstract-utxo): normalize address comparison in parseOutput
When comparing addresses, normalize them to a standard script format to ensure accurate matching regardless of address representation. We can now pass `txParams.txRecipients` to `parseOutputs`. It previously passed `expectedOutputs`, which did multiple things at once: - Normalize the address format for comparison (which is what we wanted) - Append the changeAddress in certain cases (which is not desired in parseOutput) This allows us to change the `toExpectedOutputs` function. Issue: BTC-2962 Co-authored-by: llm-git <llm-git@ttll.de>
1 parent 3a2037f commit 27c4e89

2 files changed

Lines changed: 5 additions & 2 deletions

File tree

modules/abstract-utxo/src/transaction/fixedScript/parseOutput.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import {
1414

1515
import { AbstractUtxoCoin } from '../../abstractUtxoCoin';
1616
import { Output, FixedScriptWalletOutput } from '../types';
17+
import { fromExtendedAddressFormatToScript } from '../recipient';
1718

1819
const debug = debugLib('bitgo:v2:parseoutput');
1920

@@ -284,7 +285,9 @@ export async function parseOutput({
284285
*/
285286
if (txParams.recipients !== undefined && txParams.recipients.length > RECIPIENT_THRESHOLD) {
286287
const isCurrentAddressInRecipients = txParams.recipients.some((recipient) =>
287-
recipient.address.includes(currentAddress)
288+
fromExtendedAddressFormatToScript(recipient.address, coin.name).equals(
289+
fromExtendedAddressFormatToScript(currentAddress, coin.name)
290+
)
288291
);
289292

290293
if (isCurrentAddressInRecipients) {

modules/abstract-utxo/src/transaction/fixedScript/parseTransaction.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ export async function parseTransaction<TNumber extends bigint | number>(
183183
keychainArray: toKeychainTriple(keychains),
184184
wallet,
185185
txParams: {
186-
recipients: expectedOutputs,
186+
recipients: txParams.recipients ?? [],
187187
changeAddress: txParams.changeAddress,
188188
},
189189
customChange,

0 commit comments

Comments
 (0)