Search in sources :

Example 1 with TxMalleabilityException

use of bisq.core.btc.wallet.TxMalleabilityException in project bisq-core by bisq-network.

the class LockupService method publishLockupTx.

public void publishLockupTx(Coin lockupAmount, int lockTime, LockupType lockupType, BondedRole bondedRole, ResultHandler resultHandler, ExceptionHandler exceptionHandler) {
    checkArgument(lockTime <= BondingConsensus.getMaxLockTime() && lockTime >= BondingConsensus.getMinLockTime(), "lockTime not in rage");
    try {
        byte[] hash = BondingConsensus.getHash(lockupType, bondedRole);
        byte[] opReturnData = BondingConsensus.getLockupOpReturnData(lockTime, lockupType, hash);
        final Transaction lockupTx = getLockupTx(lockupAmount, opReturnData);
        // noinspection Duplicates
        walletsManager.publishAndCommitBsqTx(lockupTx, new TxBroadcaster.Callback() {

            @Override
            public void onSuccess(Transaction transaction) {
                resultHandler.handleResult();
            }

            @Override
            public void onTxMalleability(TxMalleabilityException exception) {
                exceptionHandler.handleException(exception);
            }

            @Override
            public void onFailure(TxBroadcastException exception) {
                exceptionHandler.handleException(exception);
            }
        });
    } catch (TransactionVerificationException | InsufficientMoneyException | WalletException | IOException exception) {
        exceptionHandler.handleException(exception);
    }
}
Also used : WalletException(bisq.core.btc.exceptions.WalletException) TxMalleabilityException(bisq.core.btc.wallet.TxMalleabilityException) TxBroadcaster(bisq.core.btc.wallet.TxBroadcaster) Transaction(org.bitcoinj.core.Transaction) TransactionVerificationException(bisq.core.btc.exceptions.TransactionVerificationException) InsufficientMoneyException(org.bitcoinj.core.InsufficientMoneyException) IOException(java.io.IOException) TxBroadcastException(bisq.core.btc.wallet.TxBroadcastException)

Example 2 with TxMalleabilityException

use of bisq.core.btc.wallet.TxMalleabilityException in project bisq-core by bisq-network.

the class UnlockService method publishUnlockTx.

public void publishUnlockTx(String lockupTxId, ResultHandler resultHandler, ExceptionHandler exceptionHandler) {
    try {
        TxOutput lockupTxOutput = bsqStateService.getLockupTxOutput(lockupTxId).get();
        final Transaction unlockTx = getUnlockTx(lockupTxOutput);
        // noinspection Duplicates
        walletsManager.publishAndCommitBsqTx(unlockTx, new TxBroadcaster.Callback() {

            @Override
            public void onSuccess(Transaction transaction) {
                resultHandler.handleResult();
            }

            @Override
            public void onTxMalleability(TxMalleabilityException exception) {
                exceptionHandler.handleException(exception);
            }

            @Override
            public void onFailure(TxBroadcastException exception) {
                exceptionHandler.handleException(exception);
            }
        });
    } catch (TransactionVerificationException | InsufficientMoneyException | WalletException exception) {
        exceptionHandler.handleException(exception);
    }
}
Also used : WalletException(bisq.core.btc.exceptions.WalletException) TxOutput(bisq.core.dao.state.blockchain.TxOutput) TxMalleabilityException(bisq.core.btc.wallet.TxMalleabilityException) TxBroadcaster(bisq.core.btc.wallet.TxBroadcaster) Transaction(org.bitcoinj.core.Transaction) TransactionVerificationException(bisq.core.btc.exceptions.TransactionVerificationException) InsufficientMoneyException(org.bitcoinj.core.InsufficientMoneyException) TxBroadcastException(bisq.core.btc.wallet.TxBroadcastException)

Aggregations

TransactionVerificationException (bisq.core.btc.exceptions.TransactionVerificationException)2 WalletException (bisq.core.btc.exceptions.WalletException)2 TxBroadcastException (bisq.core.btc.wallet.TxBroadcastException)2 TxBroadcaster (bisq.core.btc.wallet.TxBroadcaster)2 TxMalleabilityException (bisq.core.btc.wallet.TxMalleabilityException)2 InsufficientMoneyException (org.bitcoinj.core.InsufficientMoneyException)2 Transaction (org.bitcoinj.core.Transaction)2 TxOutput (bisq.core.dao.state.blockchain.TxOutput)1 IOException (java.io.IOException)1