From 8370bc98d5f5e8df73ce97a65450631a4bc98484 Mon Sep 17 00:00:00 2001 From: Oscar Guindzberg Date: Tue, 13 Oct 2020 20:25:26 -0300 Subject: [PATCH] Use LegacyAddress instead of Address for BSQ --- .../main/java/bisq/core/btc/wallet/BsqWalletService.java | 6 +++--- .../dao/state/model/governance/CompensationProposal.java | 1 - .../dao/state/model/governance/ReimbursementProposal.java | 1 - core/src/main/java/bisq/core/util/coin/BsqFormatter.java | 3 +-- .../java/bisq/desktop/main/dao/wallet/tx/BsqTxListItem.java | 5 +++-- 5 files changed, 7 insertions(+), 9 deletions(-) diff --git a/core/src/main/java/bisq/core/btc/wallet/BsqWalletService.java b/core/src/main/java/bisq/core/btc/wallet/BsqWalletService.java index 5a88b67baf..1c13e4c310 100644 --- a/core/src/main/java/bisq/core/btc/wallet/BsqWalletService.java +++ b/core/src/main/java/bisq/core/btc/wallet/BsqWalletService.java @@ -774,12 +774,12 @@ public class BsqWalletService extends WalletService implements DaoStateListener // Addresses /////////////////////////////////////////////////////////////////////////////////////////// - private Address getChangeAddress() { + private LegacyAddress getChangeAddress() { return getUnusedAddress(); } - public Address getUnusedAddress() { - return wallet.getIssuedReceiveAddresses().stream() + public LegacyAddress getUnusedAddress() { + return (LegacyAddress) wallet.getIssuedReceiveAddresses().stream() .filter(this::isAddressUnused) .findAny() .orElse(wallet.freshReceiveAddress()); diff --git a/core/src/main/java/bisq/core/dao/state/model/governance/CompensationProposal.java b/core/src/main/java/bisq/core/dao/state/model/governance/CompensationProposal.java index 8a4871b0a4..d23249b6c4 100644 --- a/core/src/main/java/bisq/core/dao/state/model/governance/CompensationProposal.java +++ b/core/src/main/java/bisq/core/dao/state/model/governance/CompensationProposal.java @@ -27,7 +27,6 @@ import bisq.common.app.Version; import bisq.common.config.Config; import bisq.common.util.CollectionUtils; -import org.bitcoinj.core.Address; import org.bitcoinj.core.AddressFormatException; import org.bitcoinj.core.Coin; import org.bitcoinj.core.LegacyAddress; diff --git a/core/src/main/java/bisq/core/dao/state/model/governance/ReimbursementProposal.java b/core/src/main/java/bisq/core/dao/state/model/governance/ReimbursementProposal.java index 6501e83631..fb83ab23d5 100644 --- a/core/src/main/java/bisq/core/dao/state/model/governance/ReimbursementProposal.java +++ b/core/src/main/java/bisq/core/dao/state/model/governance/ReimbursementProposal.java @@ -27,7 +27,6 @@ import bisq.common.app.Version; import bisq.common.config.Config; import bisq.common.util.CollectionUtils; -import org.bitcoinj.core.Address; import org.bitcoinj.core.AddressFormatException; import org.bitcoinj.core.Coin; import org.bitcoinj.core.LegacyAddress; diff --git a/core/src/main/java/bisq/core/util/coin/BsqFormatter.java b/core/src/main/java/bisq/core/util/coin/BsqFormatter.java index 65a75f2cd5..025d578d46 100644 --- a/core/src/main/java/bisq/core/util/coin/BsqFormatter.java +++ b/core/src/main/java/bisq/core/util/coin/BsqFormatter.java @@ -31,7 +31,6 @@ import bisq.common.app.DevEnv; import bisq.common.config.Config; import bisq.common.util.MathUtils; -import org.bitcoinj.core.Address; import org.bitcoinj.core.AddressFormatException; import org.bitcoinj.core.Coin; import org.bitcoinj.core.LegacyAddress; @@ -97,7 +96,7 @@ public class BsqFormatter implements CoinFormatter { * Returns the base-58 encoded String representation of this * object, including version and checksum bytes. */ - public String getBsqAddressStringFromAddress(Address address) { + public String getBsqAddressStringFromAddress(LegacyAddress address) { final String addressString = address.toString(); if (useBsqAddressFormat) return prefix + addressString; diff --git a/desktop/src/main/java/bisq/desktop/main/dao/wallet/tx/BsqTxListItem.java b/desktop/src/main/java/bisq/desktop/main/dao/wallet/tx/BsqTxListItem.java index be22c82fcc..93fb748b88 100644 --- a/desktop/src/main/java/bisq/desktop/main/dao/wallet/tx/BsqTxListItem.java +++ b/desktop/src/main/java/bisq/desktop/main/dao/wallet/tx/BsqTxListItem.java @@ -28,6 +28,7 @@ import bisq.core.locale.Res; import bisq.core.util.coin.BsqFormatter; import org.bitcoinj.core.Coin; +import org.bitcoinj.core.LegacyAddress; import org.bitcoinj.core.Transaction; import org.bitcoinj.core.TransactionOutput; @@ -102,7 +103,7 @@ class BsqTxListItem extends TxConfidenceListItem { WalletService.isOutputScriptConvertibleToAddress(output)) { // 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. - sendToAddress = bsqFormatter.getBsqAddressStringFromAddress(WalletService.getAddressFromOutput(output)); + sendToAddress = bsqFormatter.getBsqAddressStringFromAddress((LegacyAddress) WalletService.getAddressFromOutput(output)); break; } } @@ -113,7 +114,7 @@ class BsqTxListItem extends TxConfidenceListItem { if (sendToAddress != null) { for (TransactionOutput output : transaction.getOutputs()) { if (WalletService.isOutputScriptConvertibleToAddress(output)) { - receivedWithAddress = bsqFormatter.getBsqAddressStringFromAddress(WalletService.getAddressFromOutput(output)); + receivedWithAddress = bsqFormatter.getBsqAddressStringFromAddress((LegacyAddress) WalletService.getAddressFromOutput(output)); break; } }