Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions modules/abstract-utxo/src/abstractUtxoCoin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -558,6 +558,9 @@ export abstract class AbstractUtxoCoin
params.recipients instanceof Array
? params?.recipients?.map((recipient) => {
const { address, ...rest } = recipient;
if (address === undefined) {
return recipient; // Already { script, amount } — pass through unchanged
}
return { ...rest, ...fromExtendedAddressFormat(address) };
})
: params.recipients;
Expand Down
16 changes: 16 additions & 0 deletions modules/abstract-utxo/test/unit/transaction/recipient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,22 @@ import assert from 'assert';

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

describe('AbstractUtxoCoin.preprocessBuildParams', function () {
const coin = getUtxoCoin('btc');

it('does not crash when recipients includes an OP_RETURN output with no address field', function () {
const params = {
recipients: [
{ address: '3L3jdUJ9YCpGFjYB2Tuu7iBJes6ZHJFmnS', amount: '999612' },
{ amount: '0', script: '6a0c3230323651312d6175646974' }, // OP_RETURN, no address
],
};
assert.doesNotThrow(() => coin.preprocessBuildParams(params));
// The OP_RETURN recipient should be passed through unchanged
assert.deepStrictEqual(params.recipients[1], { amount: '0', script: '6a0c3230323651312d6175646974' });
});
});

describe('AbstractUtxoCoin.checkRecipient', function () {
const coin = getUtxoCoin('btc');

Expand Down
Loading