mirror of
https://github.com/bisq-network/bisq.git
synced 2024-11-19 09:52:23 +01:00
Move null check for address to validateDonationAddress method
Remove dispute as unused param Remove redundant methods Signed-off-by: HenrikJannsen <boilingfrog@gmx.com>
This commit is contained in:
parent
e8c6b0ae14
commit
cfb3780e6b
@ -400,14 +400,13 @@ public abstract class DisputeManager<T extends DisputeList<Dispute>> extends Sup
|
||||
|
||||
Trade trade = optionalTrade.get();
|
||||
try {
|
||||
TradeDataValidation.validateDelayedPayoutTx(trade,
|
||||
trade.getDelayedPayoutTx(),
|
||||
dispute,
|
||||
btcWalletService);
|
||||
DisputeValidation.validateDonationAddress(dispute,
|
||||
Objects.requireNonNull(trade.getDelayedPayoutTx()),
|
||||
btcWalletService.getParams(),
|
||||
daoFacade);
|
||||
TradeDataValidation.validateDelayedPayoutTx(trade,
|
||||
trade.getDelayedPayoutTx(),
|
||||
btcWalletService);
|
||||
} catch (TradeDataValidation.ValidationException | DisputeValidation.ValidationException e) {
|
||||
// The peer sent us an invalid donation address. We do not return here as we don't want to break
|
||||
// mediation/arbitration and log only the issue. The dispute agent will run validation as well and will get
|
||||
|
@ -26,8 +26,10 @@ import bisq.network.p2p.NodeAddress;
|
||||
import bisq.common.config.Config;
|
||||
import bisq.common.util.Tuple3;
|
||||
|
||||
import org.bitcoinj.core.Address;
|
||||
import org.bitcoinj.core.NetworkParameters;
|
||||
import org.bitcoinj.core.Transaction;
|
||||
import org.bitcoinj.core.TransactionOutput;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
@ -86,7 +88,15 @@ public class DisputeValidation {
|
||||
DaoFacade daoFacade
|
||||
)
|
||||
throws AddressException {
|
||||
String delayedPayoutTxOutputAddress = delayedPayoutTx.getOutput(0).getScriptPubKey().getToAddress(params).toString();
|
||||
TransactionOutput output = delayedPayoutTx.getOutput(0);
|
||||
Address address = output.getScriptPubKey().getToAddress(params);
|
||||
if (address == null) {
|
||||
String errorMsg = "Donation address cannot be resolved (not of type P2PK nor P2SH nor P2WH). Output: " + output;
|
||||
log.error(errorMsg);
|
||||
log.error(delayedPayoutTx.toString());
|
||||
throw new DisputeValidation.AddressException(dispute, errorMsg);
|
||||
}
|
||||
String delayedPayoutTxOutputAddress = address.toString();
|
||||
validateDonationAddress(delayedPayoutTxOutputAddress, daoFacade);
|
||||
|
||||
if (dispute != null) {
|
||||
|
@ -23,7 +23,6 @@ import bisq.core.support.dispute.Dispute;
|
||||
import bisq.core.support.dispute.DisputeValidation;
|
||||
import bisq.core.trade.model.bisq_v1.Trade;
|
||||
|
||||
import org.bitcoinj.core.Address;
|
||||
import org.bitcoinj.core.Coin;
|
||||
import org.bitcoinj.core.NetworkParameters;
|
||||
import org.bitcoinj.core.Transaction;
|
||||
@ -49,40 +48,12 @@ public class TradeDataValidation {
|
||||
InvalidTxException, InvalidLockTimeException, InvalidAmountException {
|
||||
validateDelayedPayoutTx(trade,
|
||||
delayedPayoutTx,
|
||||
null,
|
||||
btcWalletService,
|
||||
null);
|
||||
}
|
||||
|
||||
public static void validateDelayedPayoutTx(Trade trade,
|
||||
Transaction delayedPayoutTx,
|
||||
@Nullable Dispute dispute,
|
||||
BtcWalletService btcWalletService)
|
||||
throws DisputeValidation.AddressException, MissingTxException,
|
||||
InvalidTxException, InvalidLockTimeException, InvalidAmountException {
|
||||
validateDelayedPayoutTx(trade,
|
||||
delayedPayoutTx,
|
||||
dispute,
|
||||
btcWalletService,
|
||||
null);
|
||||
}
|
||||
|
||||
public static void validateDelayedPayoutTx(Trade trade,
|
||||
Transaction delayedPayoutTx,
|
||||
BtcWalletService btcWalletService,
|
||||
@Nullable Consumer<String> addressConsumer)
|
||||
throws DisputeValidation.AddressException, MissingTxException,
|
||||
InvalidTxException, InvalidLockTimeException, InvalidAmountException {
|
||||
validateDelayedPayoutTx(trade,
|
||||
delayedPayoutTx,
|
||||
null,
|
||||
btcWalletService,
|
||||
addressConsumer);
|
||||
}
|
||||
|
||||
public static void validateDelayedPayoutTx(Trade trade,
|
||||
Transaction delayedPayoutTx,
|
||||
@Nullable Dispute dispute,
|
||||
BtcWalletService btcWalletService,
|
||||
@Nullable Consumer<String> addressConsumer)
|
||||
throws DisputeValidation.AddressException, MissingTxException,
|
||||
@ -143,17 +114,9 @@ public class TradeDataValidation {
|
||||
}
|
||||
|
||||
NetworkParameters params = btcWalletService.getParams();
|
||||
Address delayedPayoutTxOutputAddress = output.getScriptPubKey().getToAddress(params);
|
||||
if (delayedPayoutTxOutputAddress == null) {
|
||||
errorMsg = "Donation address cannot be resolved (not of type P2PK nor P2SH nor P2WH). Output: " + output;
|
||||
log.error(errorMsg);
|
||||
log.error(delayedPayoutTx.toString());
|
||||
throw new DisputeValidation.AddressException(dispute, errorMsg);
|
||||
}
|
||||
|
||||
String delayedPayoutTxOutputAddressAsString = delayedPayoutTxOutputAddress.toString();
|
||||
String delayedPayoutTxOutputAddress = output.getScriptPubKey().getToAddress(params).toString();
|
||||
if (addressConsumer != null) {
|
||||
addressConsumer.accept(delayedPayoutTxOutputAddressAsString);
|
||||
addressConsumer.accept(delayedPayoutTxOutputAddress);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user