mirror of
https://github.com/bisq-network/bisq.git
synced 2025-02-25 15:29:38 +01:00
Inline CreateOfferFeeTx#run into CreateOfferCoordinator
This commit is contained in:
parent
7fffa81f02
commit
2adac9475e
2 changed files with 14 additions and 52 deletions
|
@ -24,9 +24,9 @@ import io.bitsquare.offer.OfferRepository;
|
||||||
import io.bitsquare.persistence.Persistence;
|
import io.bitsquare.persistence.Persistence;
|
||||||
import io.bitsquare.trade.handlers.TransactionResultHandler;
|
import io.bitsquare.trade.handlers.TransactionResultHandler;
|
||||||
import io.bitsquare.trade.protocol.createoffer.tasks.BroadCastOfferFeeTx;
|
import io.bitsquare.trade.protocol.createoffer.tasks.BroadCastOfferFeeTx;
|
||||||
import io.bitsquare.trade.protocol.createoffer.tasks.CreateOfferFeeTx;
|
|
||||||
import io.bitsquare.util.task.FaultHandler;
|
import io.bitsquare.util.task.FaultHandler;
|
||||||
|
|
||||||
|
import org.bitcoinj.core.InsufficientMoneyException;
|
||||||
import org.bitcoinj.core.Transaction;
|
import org.bitcoinj.core.Transaction;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
@ -123,14 +123,20 @@ public class CreateOfferCoordinator {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
CreateOfferFeeTx.run(this::onOfferFeeTxCreated, faultHandler, walletFacade, offer.getId());
|
try {
|
||||||
|
model.transaction = walletFacade.createOfferFeeTx(offer.getId());
|
||||||
|
model.setState(State.OFFER_FEE_TX_CREATED);
|
||||||
|
offer.setOfferFeePaymentTxID(model.transaction.getHashAsString());
|
||||||
|
} catch (InsufficientMoneyException ex) {
|
||||||
|
faultHandler.handleFault(
|
||||||
|
"Offer fee payment failed because there is insufficient money in the trade wallet", ex);
|
||||||
|
return;
|
||||||
|
} catch (Throwable ex) {
|
||||||
|
faultHandler.handleFault("Offer fee payment failed because of an exception occurred", ex);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void onOfferFeeTxCreated(Transaction transaction) {
|
BroadCastOfferFeeTx.run(this::onOfferFeeTxBroadCasted, faultHandler, walletFacade, model.transaction);
|
||||||
model.transaction = transaction;
|
|
||||||
model.setState(State.OFFER_FEE_TX_CREATED);
|
|
||||||
offer.setOfferFeePaymentTxID(transaction.getHashAsString());
|
|
||||||
BroadCastOfferFeeTx.run(this::onOfferFeeTxBroadCasted, faultHandler, walletFacade, transaction);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void onOfferFeeTxBroadCasted() {
|
private void onOfferFeeTxBroadCasted() {
|
||||||
|
|
|
@ -1,44 +0,0 @@
|
||||||
/*
|
|
||||||
* This file is part of Bitsquare.
|
|
||||||
*
|
|
||||||
* Bitsquare is free software: you can redistribute it and/or modify it
|
|
||||||
* under the terms of the GNU Affero General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or (at
|
|
||||||
* your option) any later version.
|
|
||||||
*
|
|
||||||
* Bitsquare is distributed in the hope that it will be useful, but WITHOUT
|
|
||||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public
|
|
||||||
* License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Affero General Public License
|
|
||||||
* along with Bitsquare. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package io.bitsquare.trade.protocol.createoffer.tasks;
|
|
||||||
|
|
||||||
import io.bitsquare.btc.WalletFacade;
|
|
||||||
import io.bitsquare.util.task.FaultHandler;
|
|
||||||
import io.bitsquare.trade.handlers.TransactionResultHandler;
|
|
||||||
|
|
||||||
import org.bitcoinj.core.InsufficientMoneyException;
|
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
public class CreateOfferFeeTx {
|
|
||||||
private static final Logger log = LoggerFactory.getLogger(CreateOfferFeeTx.class);
|
|
||||||
|
|
||||||
public static void run(TransactionResultHandler resultHandler, FaultHandler faultHandler,
|
|
||||||
WalletFacade walletFacade, String offerId) {
|
|
||||||
try {
|
|
||||||
resultHandler.onResult(walletFacade.createOfferFeeTx(offerId));
|
|
||||||
} catch (InsufficientMoneyException e) {
|
|
||||||
faultHandler.handleFault("Offer fee payment failed because there is insufficient money in the trade " +
|
|
||||||
"wallet. " +
|
|
||||||
"", e);
|
|
||||||
} catch (Throwable t) {
|
|
||||||
faultHandler.handleFault("Offer fee payment failed because of an exception occurred. ", t);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Add table
Reference in a new issue