mirror of
https://github.com/bisq-network/bisq.git
synced 2024-11-19 01:41:11 +01:00
bitcoinj 0.15: Use LegacyAddress.fromBase58() instead of Address.fromBase58().
This commit is contained in:
parent
46f2ba6ee0
commit
7356b64f59
@ -19,6 +19,7 @@ package bisq.asset;
|
||||
|
||||
import org.bitcoinj.core.Address;
|
||||
import org.bitcoinj.core.AddressFormatException;
|
||||
import org.bitcoinj.core.LegacyAddress;
|
||||
import org.bitcoinj.core.NetworkParameters;
|
||||
import org.bitcoinj.params.MainNetParams;
|
||||
|
||||
@ -27,7 +28,7 @@ import org.bitcoinj.params.MainNetParams;
|
||||
*
|
||||
* @author Chris Beams
|
||||
* @since 0.7.0
|
||||
* @see org.bitcoinj.core.Address#fromBase58(NetworkParameters, String)
|
||||
* @see org.bitcoinj.core.LegacyAddress#fromBase58(NetworkParameters, String)
|
||||
*/
|
||||
public class Base58BitcoinAddressValidator implements AddressValidator {
|
||||
|
||||
@ -44,7 +45,7 @@ public class Base58BitcoinAddressValidator implements AddressValidator {
|
||||
@Override
|
||||
public AddressValidationResult validate(String address) {
|
||||
try {
|
||||
Address.fromBase58(networkParameters, address);
|
||||
LegacyAddress.fromBase58(networkParameters, address);
|
||||
} catch (AddressFormatException ex) {
|
||||
return AddressValidationResult.invalidAddress(ex);
|
||||
}
|
||||
|
@ -43,6 +43,7 @@ import org.bitcoinj.core.BlockChain;
|
||||
import org.bitcoinj.core.Coin;
|
||||
import org.bitcoinj.core.ECKey;
|
||||
import org.bitcoinj.core.InsufficientMoneyException;
|
||||
import org.bitcoinj.core.LegacyAddress;
|
||||
import org.bitcoinj.core.NetworkParameters;
|
||||
import org.bitcoinj.core.listeners.TransactionConfidenceEventListener;
|
||||
import org.bitcoinj.script.ScriptException;
|
||||
@ -538,7 +539,7 @@ public class BsqWalletService extends WalletService implements DaoStateListener
|
||||
Transaction tx = new Transaction(params);
|
||||
checkArgument(Restrictions.isAboveDust(receiverAmount),
|
||||
"The amount is too low (dust limit).");
|
||||
tx.addOutput(receiverAmount, Address.fromBase58(params, receiverAddress));
|
||||
tx.addOutput(receiverAmount, LegacyAddress.fromBase58(params, receiverAddress));
|
||||
|
||||
SendRequest sendRequest = SendRequest.forTx(tx);
|
||||
sendRequest.fee = Coin.ZERO;
|
||||
|
@ -33,6 +33,7 @@ import org.bitcoinj.core.Address;
|
||||
import org.bitcoinj.core.AddressFormatException;
|
||||
import org.bitcoinj.core.Coin;
|
||||
import org.bitcoinj.core.InsufficientMoneyException;
|
||||
import org.bitcoinj.core.LegacyAddress;
|
||||
import org.bitcoinj.core.Transaction;
|
||||
import org.bitcoinj.core.TransactionConfidence;
|
||||
import org.bitcoinj.core.TransactionInput;
|
||||
@ -1057,7 +1058,7 @@ public class BtcWalletService extends WalletService {
|
||||
final Coin receiverAmount = amount.subtract(fee);
|
||||
Preconditions.checkArgument(Restrictions.isAboveDust(receiverAmount),
|
||||
"The amount is too low (dust limit).");
|
||||
tx.addOutput(receiverAmount, Address.fromBase58(params, toAddress));
|
||||
tx.addOutput(receiverAmount, LegacyAddress.fromBase58(params, toAddress));
|
||||
|
||||
SendRequest sendRequest = SendRequest.forTx(tx);
|
||||
sendRequest.fee = fee;
|
||||
@ -1088,7 +1089,7 @@ public class BtcWalletService extends WalletService {
|
||||
checkArgument(Restrictions.isAboveDust(netValue),
|
||||
"The amount is too low (dust limit).");
|
||||
|
||||
tx.addOutput(netValue, Address.fromBase58(params, toAddress));
|
||||
tx.addOutput(netValue, LegacyAddress.fromBase58(params, toAddress));
|
||||
|
||||
SendRequest sendRequest = SendRequest.forTx(tx);
|
||||
sendRequest.fee = fee;
|
||||
@ -1153,14 +1154,14 @@ public class BtcWalletService extends WalletService {
|
||||
Preconditions.checkArgument(Restrictions.isAboveDust(buyerAmount),
|
||||
"The buyerAmount is too low (dust limit).");
|
||||
|
||||
tx.addOutput(buyerAmount, Address.fromBase58(params, buyerAddressString));
|
||||
tx.addOutput(buyerAmount, LegacyAddress.fromBase58(params, buyerAddressString));
|
||||
}
|
||||
// sellerAmount can be 0
|
||||
if (sellerAmount.isPositive()) {
|
||||
Preconditions.checkArgument(Restrictions.isAboveDust(sellerAmount),
|
||||
"The sellerAmount is too low (dust limit).");
|
||||
|
||||
tx.addOutput(sellerAmount, Address.fromBase58(params, sellerAddressString));
|
||||
tx.addOutput(sellerAmount, LegacyAddress.fromBase58(params, sellerAddressString));
|
||||
}
|
||||
|
||||
SendRequest sendRequest = SendRequest.forTx(tx);
|
||||
|
@ -36,6 +36,7 @@ import org.bitcoinj.core.AddressFormatException;
|
||||
import org.bitcoinj.core.Coin;
|
||||
import org.bitcoinj.core.ECKey;
|
||||
import org.bitcoinj.core.InsufficientMoneyException;
|
||||
import org.bitcoinj.core.LegacyAddress;
|
||||
import org.bitcoinj.core.NetworkParameters;
|
||||
import org.bitcoinj.core.Sha256Hash;
|
||||
import org.bitcoinj.core.Transaction;
|
||||
@ -151,7 +152,7 @@ public class TradeWalletService {
|
||||
Transaction tradingFeeTx = new Transaction(params);
|
||||
SendRequest sendRequest = null;
|
||||
try {
|
||||
tradingFeeTx.addOutput(tradingFee, Address.fromBase58(params, feeReceiverAddress));
|
||||
tradingFeeTx.addOutput(tradingFee, LegacyAddress.fromBase58(params, feeReceiverAddress));
|
||||
// the reserved amount we need for the trade we send to our trade reservedForTradeAddress
|
||||
tradingFeeTx.addOutput(reservedFundsForOffer, reservedForTradeAddress);
|
||||
|
||||
@ -515,7 +516,7 @@ public class TradeWalletService {
|
||||
TransactionOutput takerTransactionOutput = null;
|
||||
if (takerChangeOutputValue > 0 && takerChangeAddressString != null) {
|
||||
takerTransactionOutput = new TransactionOutput(params, preparedDepositTx, Coin.valueOf(takerChangeOutputValue),
|
||||
Address.fromBase58(params, takerChangeAddressString));
|
||||
LegacyAddress.fromBase58(params, takerChangeAddressString));
|
||||
}
|
||||
|
||||
if (makerIsBuyer) {
|
||||
@ -685,7 +686,7 @@ public class TradeWalletService {
|
||||
delayedPayoutTx.addInput(p2SHMultiSigOutput);
|
||||
applyLockTime(lockTime, delayedPayoutTx);
|
||||
Coin outputAmount = p2SHMultiSigOutput.getValue().subtract(minerFee);
|
||||
delayedPayoutTx.addOutput(outputAmount, Address.fromBase58(params, donationAddressString));
|
||||
delayedPayoutTx.addOutput(outputAmount, LegacyAddress.fromBase58(params, donationAddressString));
|
||||
WalletService.printTx("Unsigned delayedPayoutTx ToDonationAddress", delayedPayoutTx);
|
||||
WalletService.verifyTransaction(delayedPayoutTx);
|
||||
return delayedPayoutTx;
|
||||
@ -937,10 +938,10 @@ public class TradeWalletService {
|
||||
Transaction payoutTx = new Transaction(params);
|
||||
payoutTx.addInput(p2SHMultiSigOutput);
|
||||
if (buyerPayoutAmount.isPositive()) {
|
||||
payoutTx.addOutput(buyerPayoutAmount, Address.fromBase58(params, buyerAddressString));
|
||||
payoutTx.addOutput(buyerPayoutAmount, LegacyAddress.fromBase58(params, buyerAddressString));
|
||||
}
|
||||
if (sellerPayoutAmount.isPositive()) {
|
||||
payoutTx.addOutput(sellerPayoutAmount, Address.fromBase58(params, sellerAddressString));
|
||||
payoutTx.addOutput(sellerPayoutAmount, LegacyAddress.fromBase58(params, sellerAddressString));
|
||||
}
|
||||
|
||||
// take care of sorting!
|
||||
@ -1000,10 +1001,10 @@ public class TradeWalletService {
|
||||
payoutTx.addInput(new TransactionInput(params, depositTx, p2SHMultiSigOutputScript.getProgram(), new TransactionOutPoint(params, 0, spendTxHash), msOutput));
|
||||
|
||||
if (buyerPayoutAmount.isPositive()) {
|
||||
payoutTx.addOutput(buyerPayoutAmount, Address.fromBase58(params, buyerAddressString));
|
||||
payoutTx.addOutput(buyerPayoutAmount, LegacyAddress.fromBase58(params, buyerAddressString));
|
||||
}
|
||||
if (sellerPayoutAmount.isPositive()) {
|
||||
payoutTx.addOutput(sellerPayoutAmount, Address.fromBase58(params, sellerAddressString));
|
||||
payoutTx.addOutput(sellerPayoutAmount, LegacyAddress.fromBase58(params, sellerAddressString));
|
||||
}
|
||||
|
||||
// take care of sorting!
|
||||
@ -1145,10 +1146,10 @@ public class TradeWalletService {
|
||||
Transaction transaction = new Transaction(params);
|
||||
transaction.addInput(p2SHMultiSigOutput);
|
||||
if (buyerPayoutAmount.isPositive()) {
|
||||
transaction.addOutput(buyerPayoutAmount, Address.fromBase58(params, buyerAddressString));
|
||||
transaction.addOutput(buyerPayoutAmount, LegacyAddress.fromBase58(params, buyerAddressString));
|
||||
}
|
||||
if (sellerPayoutAmount.isPositive()) {
|
||||
transaction.addOutput(sellerPayoutAmount, Address.fromBase58(params, sellerAddressString));
|
||||
transaction.addOutput(sellerPayoutAmount, LegacyAddress.fromBase58(params, sellerAddressString));
|
||||
}
|
||||
checkArgument(transaction.getOutputs().size() >= 1, "We need at least one output.");
|
||||
return transaction;
|
||||
|
@ -37,6 +37,7 @@ import org.bitcoinj.core.Coin;
|
||||
import org.bitcoinj.core.Context;
|
||||
import org.bitcoinj.core.ECKey;
|
||||
import org.bitcoinj.core.InsufficientMoneyException;
|
||||
import org.bitcoinj.core.LegacyAddress;
|
||||
import org.bitcoinj.core.NetworkParameters;
|
||||
import org.bitcoinj.core.listeners.TransactionConfidenceEventListener;
|
||||
import org.bitcoinj.script.ScriptException;
|
||||
@ -499,7 +500,7 @@ public abstract class WalletService {
|
||||
ResultHandler resultHandler,
|
||||
ErrorMessageHandler errorMessageHandler)
|
||||
throws InsufficientMoneyException, AddressFormatException {
|
||||
SendRequest sendRequest = SendRequest.emptyWallet(Address.fromBase58(params, toAddress));
|
||||
SendRequest sendRequest = SendRequest.emptyWallet(LegacyAddress.fromBase58(params, toAddress));
|
||||
sendRequest.fee = Coin.ZERO;
|
||||
sendRequest.feePerKb = getTxFeeForWithdrawalPerByte().multiply(1000);
|
||||
sendRequest.aesKey = aesKey;
|
||||
|
@ -30,6 +30,7 @@ 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;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.Map;
|
||||
@ -120,7 +121,7 @@ public final class CompensationProposal extends Proposal implements IssuanceProp
|
||||
public Address getAddress() throws AddressFormatException {
|
||||
// Remove leading 'B'
|
||||
String underlyingBtcAddress = bsqAddress.substring(1, bsqAddress.length());
|
||||
return Address.fromBase58(Config.baseCurrencyNetworkParameters(), underlyingBtcAddress);
|
||||
return LegacyAddress.fromBase58(Config.baseCurrencyNetworkParameters(), underlyingBtcAddress);
|
||||
}
|
||||
|
||||
|
||||
|
@ -30,6 +30,7 @@ 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;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.Map;
|
||||
@ -120,7 +121,7 @@ public final class ReimbursementProposal extends Proposal implements IssuancePro
|
||||
public Address getAddress() throws AddressFormatException {
|
||||
// Remove leading 'B'
|
||||
String underlyingBtcAddress = bsqAddress.substring(1, bsqAddress.length());
|
||||
return Address.fromBase58(Config.baseCurrencyNetworkParameters(), underlyingBtcAddress);
|
||||
return LegacyAddress.fromBase58(Config.baseCurrencyNetworkParameters(), underlyingBtcAddress);
|
||||
}
|
||||
|
||||
|
||||
|
@ -34,6 +34,7 @@ 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;
|
||||
import org.bitcoinj.utils.MonetaryFormat;
|
||||
|
||||
import javax.inject.Inject;
|
||||
@ -110,7 +111,7 @@ public class BsqFormatter implements CoinFormatter {
|
||||
encoded = encoded.substring(prefix.length(), encoded.length());
|
||||
|
||||
try {
|
||||
return Address.fromBase58(Config.baseCurrencyNetworkParameters(), encoded);
|
||||
return LegacyAddress.fromBase58(Config.baseCurrencyNetworkParameters(), encoded);
|
||||
} catch (AddressFormatException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
@ -23,6 +23,7 @@ import bisq.common.config.Config;
|
||||
|
||||
import org.bitcoinj.core.Address;
|
||||
import org.bitcoinj.core.AddressFormatException;
|
||||
import org.bitcoinj.core.LegacyAddress;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
@ -44,7 +45,7 @@ public final class BtcAddressValidator extends InputValidator {
|
||||
|
||||
private ValidationResult validateBtcAddress(String input) {
|
||||
try {
|
||||
Address.fromBase58(Config.baseCurrencyNetworkParameters(), input);
|
||||
LegacyAddress.fromBase58(Config.baseCurrencyNetworkParameters(), input);
|
||||
return new ValidationResult(true);
|
||||
} catch (AddressFormatException e) {
|
||||
return new ValidationResult(false, Res.get("validation.btc.invalidFormat"));
|
||||
|
@ -70,6 +70,7 @@ import bisq.common.util.Utilities;
|
||||
|
||||
import org.bitcoinj.core.Address;
|
||||
import org.bitcoinj.core.Coin;
|
||||
import org.bitcoinj.core.LegacyAddress;
|
||||
import org.bitcoinj.core.TransactionConfidence;
|
||||
import org.bitcoinj.uri.BitcoinURI;
|
||||
import org.bitcoinj.utils.Fiat;
|
||||
@ -718,7 +719,7 @@ public class GUIUtil {
|
||||
|
||||
public static String getBitcoinURI(String address, Coin amount, String label) {
|
||||
return address != null ?
|
||||
BitcoinURI.convertToBitcoinURI(Address.fromBase58(Config.baseCurrencyNetworkParameters(),
|
||||
BitcoinURI.convertToBitcoinURI(LegacyAddress.fromBase58(Config.baseCurrencyNetworkParameters(),
|
||||
address), amount, label, null) :
|
||||
"";
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user