Search in sources :

Example 1 with SendResult

use of org.bitcoinj.wallet.Wallet.SendResult in project catena-java by alinush.

the class CatenaServer method appendStatement.

/**
 * Appends a statement to the Catena chain. This function first commits
 * the statement on disk, then schedules it for publication on the
 * blockchain.
 *
 * @param statement
 * @throws InsufficientMoneyException
 *
 * @return
 */
public Transaction appendStatement(byte[] statement) throws InsufficientMoneyException {
    Transaction tx = wallet.appendStatement(statement);
    // Broadcast Catena transaction
    // 
    // WARNING: Sending the TX this way by calling sendCatenaTxOfflline
    // (it used to be Wallet::sendCoinsOffline but we subclassed Wallet) and then
    // peerGroup().broadcastTransaction() might not work in future version of
    // bitcoinj
    final SendResult result = new SendResult();
    result.tx = tx;
    result.broadcast = peerGroup().broadcastTransaction(tx);
    result.broadcastComplete = result.broadcast.future();
    log.trace("Catena server TX (" + tx.getHash() + ") for '" + statement + "' after sending: " + tx);
    return tx;
}
Also used : Transaction(org.bitcoinj.core.Transaction) SendResult(org.bitcoinj.wallet.Wallet.SendResult)

Aggregations

Transaction (org.bitcoinj.core.Transaction)1 SendResult (org.bitcoinj.wallet.Wallet.SendResult)1