Search in sources :

Example 1 with User

use of io.bitsquare.user.User in project bitsquare by bitsquare.

the class CreateTakeOfferFeeTx method run.

@Override
protected void run() {
    try {
        runInterceptHook();
        User user = processModel.getUser();
        NodeAddress selectedArbitratorNodeAddress = ArbitrationSelectionRule.select(user.getAcceptedArbitratorAddresses(), processModel.getOffer());
        log.debug("selectedArbitratorAddress " + selectedArbitratorNodeAddress);
        Arbitrator selectedArbitrator = user.getAcceptedArbitratorByAddress(selectedArbitratorNodeAddress);
        checkNotNull(selectedArbitrator, "selectedArbitrator must not be null at CreateTakeOfferFeeTx");
        WalletService walletService = processModel.getWalletService();
        String id = model.getOffer().getId();
        AddressEntry addressEntry = walletService.getOrCreateAddressEntry(id, AddressEntry.Context.OFFER_FUNDING);
        AddressEntry reservedForTradeAddressEntry = walletService.getOrCreateAddressEntry(id, AddressEntry.Context.RESERVED_FOR_TRADE);
        AddressEntry changeAddressEntry = walletService.getOrCreateAddressEntry(AddressEntry.Context.AVAILABLE);
        Address fundingAddress = addressEntry.getAddress();
        Address reservedForTradeAddress = reservedForTradeAddressEntry.getAddress();
        Address changeAddress = changeAddressEntry.getAddress();
        Transaction createTakeOfferFeeTx = processModel.getTradeWalletService().createTradingFeeTx(fundingAddress, reservedForTradeAddress, changeAddress, processModel.getFundsNeededForTrade(), processModel.getUseSavingsWallet(), FeePolicy.getTakeOfferFee(), selectedArbitrator.getBtcAddress());
        processModel.setTakeOfferFeeTx(createTakeOfferFeeTx);
        trade.setTakeOfferFeeTxId(createTakeOfferFeeTx.getHashAsString());
        complete();
    } catch (Throwable t) {
        failed(t);
    }
}
Also used : User(io.bitsquare.user.User) NodeAddress(io.bitsquare.p2p.NodeAddress) Address(org.bitcoinj.core.Address) Transaction(org.bitcoinj.core.Transaction) AddressEntry(io.bitsquare.btc.AddressEntry) NodeAddress(io.bitsquare.p2p.NodeAddress) Arbitrator(io.bitsquare.arbitration.Arbitrator) WalletService(io.bitsquare.btc.WalletService)

Aggregations

Arbitrator (io.bitsquare.arbitration.Arbitrator)1 AddressEntry (io.bitsquare.btc.AddressEntry)1 WalletService (io.bitsquare.btc.WalletService)1 NodeAddress (io.bitsquare.p2p.NodeAddress)1 User (io.bitsquare.user.User)1 Address (org.bitcoinj.core.Address)1 Transaction (org.bitcoinj.core.Transaction)1