Search in sources :

Example 11 with Transaction

use of com.sparrowwallet.drongo.protocol.Transaction in project sparrow by sparrowwallet.

the class BlockTransactionMapper method map.

@Override
public Map.Entry<Sha256Hash, BlockTransaction> map(ResultSet rs, StatementContext ctx) throws SQLException {
    Sha256Hash txid = Sha256Hash.wrap(rs.getBytes("txid"));
    byte[] txBytes = rs.getBytes("transaction");
    Transaction transaction = null;
    if (txBytes != null) {
        transaction = new Transaction(txBytes);
    }
    Long fee = rs.getLong("fee");
    if (rs.wasNull()) {
        fee = null;
    }
    BlockTransaction blockTransaction = new BlockTransaction(Sha256Hash.wrap(rs.getBytes("hash")), rs.getInt("height"), rs.getTimestamp("date"), fee, transaction, rs.getBytes("blockHash") == null ? null : Sha256Hash.wrap(rs.getBytes("blockHash")), rs.getString("label"));
    blockTransaction.setId(rs.getLong("id"));
    return new Map.Entry<>() {

        @Override
        public Sha256Hash getKey() {
            return txid;
        }

        @Override
        public BlockTransaction getValue() {
            return blockTransaction;
        }

        @Override
        public BlockTransaction setValue(BlockTransaction value) {
            return null;
        }
    };
}
Also used : Transaction(com.sparrowwallet.drongo.protocol.Transaction) BlockTransaction(com.sparrowwallet.drongo.wallet.BlockTransaction) Sha256Hash(com.sparrowwallet.drongo.protocol.Sha256Hash) BlockTransaction(com.sparrowwallet.drongo.wallet.BlockTransaction)

Aggregations

Transaction (com.sparrowwallet.drongo.protocol.Transaction)11 TransactionOutput (com.sparrowwallet.drongo.protocol.TransactionOutput)4 TransactionInput (com.sparrowwallet.drongo.protocol.TransactionInput)3 Subscribe (com.google.common.eventbus.Subscribe)2 Cahoots (com.samourai.wallet.cahoots.Cahoots)2 KeyPurpose (com.sparrowwallet.drongo.KeyPurpose)2 Address (com.sparrowwallet.drongo.address.Address)2 InvalidAddressException (com.sparrowwallet.drongo.address.InvalidAddressException)2 PaymentCode (com.sparrowwallet.drongo.bip47.PaymentCode)2 ECKey (com.sparrowwallet.drongo.crypto.ECKey)2 Sha256Hash (com.sparrowwallet.drongo.protocol.Sha256Hash)2 PSBT (com.sparrowwallet.drongo.psbt.PSBT)2 PSBTParseException (com.sparrowwallet.drongo.psbt.PSBTParseException)2 com.sparrowwallet.drongo.wallet (com.sparrowwallet.drongo.wallet)2 ElectrumServer (com.sparrowwallet.sparrow.net.ElectrumServer)2 java.util (java.util)2 Collectors (java.util.stream.Collectors)2 JsonRpcClient (com.github.arteam.simplejsonrpc.client.JsonRpcClient)1 JsonRpcException (com.github.arteam.simplejsonrpc.client.exception.JsonRpcException)1 ImmutableMap (com.google.common.collect.ImmutableMap)1