fix: on SendDetails screen move targets creation out of options loop

This commit is contained in:
Ivan Vershigora 2025-02-28 11:52:06 +00:00
parent c4b1e67f9d
commit 7bb3dd6aef
No known key found for this signature in database
GPG key ID: DCCF7FB5ED2CEBD7

View file

@ -295,38 +295,38 @@ const SendDetails = () => {
const newFeePrecalc: /* Record<string, any> */ IFee = { ...feePrecalc };
let targets = [];
for (const transaction of addresses) {
if (transaction.amount === BitcoinUnit.MAX) {
// single output with MAX
targets = [{ address: transaction.address }];
break;
}
const value = transaction.amountSats;
if (Number(value) > 0) {
targets.push({ address: transaction.address, value });
} else if (transaction.amount) {
if (btcToSatoshi(transaction.amount) > 0) {
targets.push({ address: transaction.address, value: btcToSatoshi(transaction.amount) });
}
}
}
// if targets is empty, insert dust
if (targets.length === 0) {
targets.push({ address: '36JxaUrpDzkEerkTf1FzwHNE1Hb7cCjgJV', value: 546 });
}
// replace wrong addresses with dump
targets = targets.map(t => {
if (!wallet.isAddressValid(t.address)) {
return { ...t, address: '36JxaUrpDzkEerkTf1FzwHNE1Hb7cCjgJV' };
} else {
return t;
}
});
for (const opt of options) {
let targets = [];
for (const transaction of addresses) {
if (transaction.amount === BitcoinUnit.MAX) {
// single output with MAX
targets = [{ address: transaction.address }];
break;
}
const value = transaction.amountSats;
if (Number(value) > 0) {
targets.push({ address: transaction.address, value });
} else if (transaction.amount) {
if (btcToSatoshi(transaction.amount) > 0) {
targets.push({ address: transaction.address, value: btcToSatoshi(transaction.amount) });
}
}
}
// if targets is empty, insert dust
if (targets.length === 0) {
targets.push({ address: '36JxaUrpDzkEerkTf1FzwHNE1Hb7cCjgJV', value: 546 });
}
// replace wrong addresses with dump
targets = targets.map(t => {
if (!wallet.isAddressValid(t.address)) {
return { ...t, address: '36JxaUrpDzkEerkTf1FzwHNE1Hb7cCjgJV' };
} else {
return t;
}
});
let flag = false;
while (true) {
try {