Skip to content

Commit d322a84

Browse files
Merge pull request #8668 from BitGo/revert-8539-fix/WAL-375-recipients-guard-v2
fix(abstract-utxo): guard undefined address in preprocessBuildParams
2 parents 430c661 + 9651f36 commit d322a84

2 files changed

Lines changed: 19 additions & 0 deletions

File tree

modules/abstract-utxo/src/abstractUtxoCoin.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -558,6 +558,9 @@ export abstract class AbstractUtxoCoin
558558
params.recipients instanceof Array
559559
? params?.recipients?.map((recipient) => {
560560
const { address, ...rest } = recipient;
561+
if (address === undefined) {
562+
return recipient; // Already { script, amount } — pass through unchanged
563+
}
561564
return { ...rest, ...fromExtendedAddressFormat(address) };
562565
})
563566
: params.recipients;

modules/abstract-utxo/test/unit/transaction/recipient.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,22 @@ import assert from 'assert';
22

33
import { getUtxoCoin } from '../util/utxoCoins';
44

5+
describe('AbstractUtxoCoin.preprocessBuildParams', function () {
6+
const coin = getUtxoCoin('btc');
7+
8+
it('does not crash when recipients includes an OP_RETURN output with no address field', function () {
9+
const params = {
10+
recipients: [
11+
{ address: '3L3jdUJ9YCpGFjYB2Tuu7iBJes6ZHJFmnS', amount: '999612' },
12+
{ amount: '0', script: '6a0c3230323651312d6175646974' }, // OP_RETURN, no address
13+
],
14+
};
15+
assert.doesNotThrow(() => coin.preprocessBuildParams(params));
16+
// The OP_RETURN recipient should be passed through unchanged
17+
assert.deepStrictEqual(params.recipients[1], { amount: '0', script: '6a0c3230323651312d6175646974' });
18+
});
19+
});
20+
521
describe('AbstractUtxoCoin.checkRecipient', function () {
622
const coin = getUtxoCoin('btc');
723

0 commit comments

Comments
 (0)