enforce trade limit over grpc
This commit is contained in:
parent
31dfdd7710
commit
f11c816cda
@ -96,6 +96,10 @@ class CorePaymentAccountsService {
|
||||
}
|
||||
}
|
||||
|
||||
PaymentAccount getPaymentAccount(String paymentAccountId) {
|
||||
return user.getPaymentAccount(paymentAccountId);
|
||||
}
|
||||
|
||||
Set<PaymentAccount> getPaymentAccounts() {
|
||||
return user.getPaymentAccounts();
|
||||
}
|
||||
|
@ -17,6 +17,7 @@
|
||||
|
||||
package bisq.core.offer;
|
||||
|
||||
import bisq.core.account.witness.AccountAgeWitnessService;
|
||||
import bisq.core.api.CoreContext;
|
||||
import bisq.core.api.CoreMoneroConnectionsService;
|
||||
import bisq.core.btc.wallet.BtcWalletService;
|
||||
@ -136,6 +137,8 @@ public class OpenOfferManager implements PeerManager.Listener, DecryptedDirectMe
|
||||
private Timer periodicRepublishOffersTimer, periodicRefreshOffersTimer, retryRepublishOffersTimer;
|
||||
@Getter
|
||||
private final ObservableList<Tuple2<OpenOffer, String>> invalidOffers = FXCollections.observableArrayList();
|
||||
@Getter
|
||||
private final AccountAgeWitnessService accountAgeWitnessService;
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
@ -161,7 +164,8 @@ public class OpenOfferManager implements PeerManager.Listener, DecryptedDirectMe
|
||||
FilterManager filterManager,
|
||||
Broadcaster broadcaster,
|
||||
PersistenceManager<TradableList<OpenOffer>> persistenceManager,
|
||||
PersistenceManager<SignedOfferList> signedOfferPersistenceManager) {
|
||||
PersistenceManager<SignedOfferList> signedOfferPersistenceManager,
|
||||
AccountAgeWitnessService accountAgeWitnessService) {
|
||||
this.coreContext = coreContext;
|
||||
this.keyRing = keyRing;
|
||||
this.user = user;
|
||||
@ -181,6 +185,7 @@ public class OpenOfferManager implements PeerManager.Listener, DecryptedDirectMe
|
||||
this.broadcaster = broadcaster;
|
||||
this.persistenceManager = persistenceManager;
|
||||
this.signedOfferPersistenceManager = signedOfferPersistenceManager;
|
||||
this.accountAgeWitnessService = accountAgeWitnessService;
|
||||
|
||||
this.persistenceManager.initialize(openOffers, "OpenOffers", PersistenceManager.Source.PRIVATE);
|
||||
this.signedOfferPersistenceManager.initialize(signedOffers, "SignedOffers", PersistenceManager.Source.PRIVATE); // arbitrator stores reserve tx for signed offers
|
||||
@ -741,7 +746,7 @@ public class OpenOfferManager implements PeerManager.Listener, DecryptedDirectMe
|
||||
}
|
||||
|
||||
private void signAndPostOffer(OpenOffer openOffer,
|
||||
Coin offerReserveAmount, // TODO: switch to BigInteger
|
||||
Coin offerReserveAmount,
|
||||
boolean useSavingsWallet, // TODO: remove this
|
||||
TransactionResultHandler resultHandler, ErrorMessageHandler errorMessageHandler) {
|
||||
log.info("Signing and posting offer " + openOffer.getId());
|
||||
@ -760,7 +765,8 @@ public class OpenOfferManager implements PeerManager.Listener, DecryptedDirectMe
|
||||
tradeStatisticsManager,
|
||||
user,
|
||||
keyRing,
|
||||
filterManager);
|
||||
filterManager,
|
||||
accountAgeWitnessService);
|
||||
|
||||
// create protocol
|
||||
PlaceOfferProtocol placeOfferProtocol = new PlaceOfferProtocol(model,
|
||||
|
@ -17,6 +17,7 @@
|
||||
|
||||
package bisq.core.offer.placeoffer;
|
||||
|
||||
import bisq.core.account.witness.AccountAgeWitnessService;
|
||||
import bisq.core.btc.wallet.BtcWalletService;
|
||||
import bisq.core.btc.wallet.TradeWalletService;
|
||||
import bisq.core.btc.wallet.XmrWalletService;
|
||||
@ -63,6 +64,8 @@ public class PlaceOfferModel implements Model {
|
||||
private final KeyRing keyRing;
|
||||
@Getter
|
||||
private final FilterManager filterManager;
|
||||
@Getter
|
||||
private final AccountAgeWitnessService accountAgeWitnessService;
|
||||
|
||||
// Mutable
|
||||
@Setter
|
||||
@ -87,7 +90,8 @@ public class PlaceOfferModel implements Model {
|
||||
TradeStatisticsManager tradeStatisticsManager,
|
||||
User user,
|
||||
KeyRing keyRing,
|
||||
FilterManager filterManager) {
|
||||
FilterManager filterManager,
|
||||
AccountAgeWitnessService accountAgeWitnessService) {
|
||||
this.offer = offer;
|
||||
this.reservedFundsForOffer = reservedFundsForOffer;
|
||||
this.useSavingsWallet = useSavingsWallet;
|
||||
@ -102,6 +106,7 @@ public class PlaceOfferModel implements Model {
|
||||
this.user = user;
|
||||
this.keyRing = keyRing;
|
||||
this.filterManager = filterManager;
|
||||
this.accountAgeWitnessService = accountAgeWitnessService;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -19,6 +19,7 @@ package bisq.core.offer.placeoffer.tasks;
|
||||
|
||||
import bisq.core.offer.Offer;
|
||||
import bisq.core.offer.placeoffer.PlaceOfferModel;
|
||||
import bisq.core.trade.HavenoUtils;
|
||||
import bisq.core.trade.messages.TradeMessage;
|
||||
|
||||
import bisq.common.taskrunner.Task;
|
||||
@ -65,8 +66,9 @@ public class ValidateOffer extends Task<PlaceOfferModel> {
|
||||
/*checkArgument(offer.getMinAmount().compareTo(ProposalConsensus.getMinTradeAmount()) >= 0,
|
||||
"MinAmount is less than " + ProposalConsensus.getMinTradeAmount().toFriendlyString());*/
|
||||
|
||||
checkArgument(offer.getAmount().compareTo(offer.getPaymentMethod().getMaxTradeLimitAsCoin(offer.getCurrencyCode())) <= 0,
|
||||
"Amount is larger than " + offer.getPaymentMethod().getMaxTradeLimitAsCoin(offer.getCurrencyCode()).toFriendlyString());
|
||||
long maxAmount = model.getAccountAgeWitnessService().getMyTradeLimit(model.getUser().getPaymentAccount(offer.getMakerPaymentAccountId()), offer.getCurrencyCode(), offer.getDirection());
|
||||
checkArgument(offer.getAmount().longValue() <= maxAmount,
|
||||
"Amount is larger than " + HavenoUtils.coinToXmr(offer.getPaymentMethod().getMaxTradeLimitAsCoin(offer.getCurrencyCode())) + " XMR");
|
||||
checkArgument(offer.getAmount().compareTo(offer.getMinAmount()) >= 0, "MinAmount is larger than Amount");
|
||||
|
||||
checkNotNull(offer.getPrice(), "Price is null");
|
||||
@ -89,7 +91,6 @@ public class ValidateOffer extends Task<PlaceOfferModel> {
|
||||
"maxTradePeriod must be positive. maxTradePeriod=" + offer.getMaxTradePeriod());
|
||||
// TODO check upper and lower bounds for fiat
|
||||
// TODO check rest of new parameters
|
||||
// TODO check for account age witness base tradeLimit is missing
|
||||
|
||||
complete();
|
||||
} catch (Exception e) {
|
||||
|
@ -38,7 +38,6 @@ import bisq.core.trade.protocol.TradeListener;
|
||||
import bisq.core.trade.protocol.TradeProtocol;
|
||||
import bisq.core.trade.protocol.TradingPeer;
|
||||
import bisq.core.trade.txproof.AssetTxProofResult;
|
||||
import bisq.core.util.ParsingUtils;
|
||||
import bisq.core.util.VolumeUtil;
|
||||
import bisq.network.p2p.AckMessage;
|
||||
import bisq.network.p2p.NodeAddress;
|
||||
@ -701,7 +700,6 @@ public abstract class Trade implements Tradable, Model {
|
||||
public MoneroTxWallet createPayoutTx() {
|
||||
|
||||
// gather info
|
||||
XmrWalletService walletService = processModel.getProvider().getXmrWalletService();
|
||||
MoneroWallet multisigWallet = getWallet();
|
||||
if (multisigWallet.isMultisigImportNeeded()) throw new RuntimeException("Cannot create payout tx because multisig import is needed");
|
||||
String sellerPayoutAddress = this.getSeller().getPayoutAddressString();
|
||||
|
@ -73,7 +73,8 @@ public class OpenOfferManagerTest {
|
||||
null,
|
||||
null,
|
||||
persistenceManager,
|
||||
signedOfferPersistenceManager);
|
||||
signedOfferPersistenceManager,
|
||||
null);
|
||||
|
||||
AtomicBoolean startEditOfferSuccessful = new AtomicBoolean(false);
|
||||
|
||||
@ -119,7 +120,8 @@ public class OpenOfferManagerTest {
|
||||
null,
|
||||
null,
|
||||
persistenceManager,
|
||||
signedOfferPersistenceManager);
|
||||
signedOfferPersistenceManager,
|
||||
null);
|
||||
|
||||
AtomicBoolean startEditOfferSuccessful = new AtomicBoolean(false);
|
||||
|
||||
@ -159,7 +161,8 @@ public class OpenOfferManagerTest {
|
||||
null,
|
||||
null,
|
||||
persistenceManager,
|
||||
signedOfferPersistenceManager);
|
||||
signedOfferPersistenceManager,
|
||||
null);
|
||||
|
||||
AtomicBoolean startEditOfferSuccessful = new AtomicBoolean(false);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user