Check if output is a legacy address.

Remove `sendToAddress != null` check.
This commit is contained in:
chimp1984 2020-11-10 11:11:42 -05:00
parent 7c65000ff2
commit b5f88c4932
No known key found for this signature in database
GPG Key ID: 9801B4EC591F90E3

View File

@ -27,6 +27,7 @@ import bisq.core.dao.state.model.blockchain.TxType;
import bisq.core.locale.Res; import bisq.core.locale.Res;
import bisq.core.util.coin.BsqFormatter; import bisq.core.util.coin.BsqFormatter;
import org.bitcoinj.core.Address;
import org.bitcoinj.core.Coin; import org.bitcoinj.core.Coin;
import org.bitcoinj.core.LegacyAddress; import org.bitcoinj.core.LegacyAddress;
import org.bitcoinj.core.Transaction; import org.bitcoinj.core.Transaction;
@ -101,24 +102,24 @@ class BsqTxListItem extends TxConfidenceListItem {
WalletService.isOutputScriptConvertibleToAddress(output)) { WalletService.isOutputScriptConvertibleToAddress(output)) {
// We don't support send txs with multiple outputs to multiple receivers, so we can // We don't support send txs with multiple outputs to multiple receivers, so we can
// assume that only one output is not from our own wallets. // assume that only one output is not from our own wallets.
LegacyAddress addressFromOutput = (LegacyAddress) WalletService.getAddressFromOutput(output); // We ignore segwit outputs
if (addressFromOutput != null) { Address addressFromOutput = WalletService.getAddressFromOutput(output);
sendToAddress = bsqFormatter.getBsqAddressStringFromAddress(addressFromOutput); if (addressFromOutput instanceof LegacyAddress) {
} sendToAddress = bsqFormatter.getBsqAddressStringFromAddress((LegacyAddress) addressFromOutput);
break; break;
} }
} }
}
// In the case we sent to ourselves (either to BSQ or BTC wallet) we show the first as the other is // In the case we sent to ourselves (either to BSQ or BTC wallet) we show the first as the other is
// usually the change output. // usually the change output.
String receivedWithAddress = Res.get("shared.na"); String receivedWithAddress = Res.get("shared.na");
if (sendToAddress != null) {
for (TransactionOutput output : transaction.getOutputs()) { for (TransactionOutput output : transaction.getOutputs()) {
if (WalletService.isOutputScriptConvertibleToAddress(output)) { if (WalletService.isOutputScriptConvertibleToAddress(output)) {
LegacyAddress addressFromOutput = (LegacyAddress) WalletService.getAddressFromOutput(output); Address addressFromOutput = WalletService.getAddressFromOutput(output);
if (addressFromOutput != null) { // We ignore segwit outputs
receivedWithAddress = bsqFormatter.getBsqAddressStringFromAddress(addressFromOutput); if (addressFromOutput instanceof LegacyAddress) {
} receivedWithAddress = bsqFormatter.getBsqAddressStringFromAddress((LegacyAddress) addressFromOutput);
break; break;
} }
} }