Class EsploraClient
java.lang.Object
com.codename1.crypto.rpc.EsploraClient
A Bitcoin client for the Esplora REST API, which Blockstream and mempool.space run in public and anyone can self-host: unspent outputs, balances, fee estimates and broadcasting.
EsploraClient btc = new EsploraClient(new NetworkTransport(), EsploraClient.MEMPOOL_TESTNET);
BitcoinAddress address = BitcoinAddress.parse("tb1qw508d6qejxtdg4y5r3zarvary0c5xw7kxpjzsx",
BitcoinNetwork.TESTNET);
List<EsploraClient.Utxo> coins = btc.getUtxos(address);
double satPerVbyte = btc.getFeeEstimates().get("6");
BitcoinTransaction signed = new BitcoinTransaction(); // signed through a Psbt
String txid = btc.broadcast(signed);
-
Nested Class Summary
Nested Classes -
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionEsploraClient(RpcTransport transport, String baseUrl) A client for an Esplora base URL, such asMEMPOOL_MAINNET. -
Method Summary
Modifier and TypeMethodDescriptionbroadcast(BitcoinTransaction signed) Broadcasts a signed transaction, answering its txid.long[]getBalance(BitcoinAddress address) The balance of an address in satoshis:{confirmed, unconfirmed}, the second the net effect of mempool transactions and possibly negative.longgetConfirmationHeight(String txid) Whether a transaction is confirmed, and at what height:-1while it is in the mempool.Fee estimates in sat/vB keyed by confirmation target in blocks ("1","3","6","144"and the others the server answers).longThe height of the chain tip.getTransaction(String txid) A transaction by id.getUtxos(BitcoinAddress address) The unspent outputs paying an address, confirmed and in the mempool.
-
Field Details
-
MEMPOOL_MAINNET
-
MEMPOOL_TESTNET
-
MEMPOOL_SIGNET
-
BLOCKSTREAM_MAINNET
-
-
Constructor Details
-
EsploraClient
A client for an Esplora base URL, such asMEMPOOL_MAINNET.
-
-
Method Details
-
getUtxos
The unspent outputs paying an address, confirmed and in the mempool.- Throws:
IOException
-
getBalance
The balance of an address in satoshis:{confirmed, unconfirmed}, the second the net effect of mempool transactions and possibly negative.- Throws:
IOException
-
getFeeEstimates
Fee estimates in sat/vB keyed by confirmation target in blocks ("1","3","6","144"and the others the server answers).- Throws:
IOException
-
getTipHeight
-
getTransaction
A transaction by id.- Throws:
IOException
-
getConfirmationHeight
Whether a transaction is confirmed, and at what height:-1while it is in the mempool.- Throws:
IOException
-
broadcast
Broadcasts a signed transaction, answering its txid.- Throws:
IOException
-