Package foundation.omni.netapi.omnicore
Class OmniCoreClient
java.lang.Object
foundation.omni.netapi.omnicore.OmniCoreClient
- All Implemented Interfaces:
ConsensusService
,OmniBalanceService
,ConsensusFetcher
,AutoCloseable
,RichListService<OmniValue,
,CurrencyID> ChainTipService
- Direct Known Subclasses:
OmniCoreConsensusTool
public class OmniCoreClient
extends Object
implements ConsensusService, RichListService<OmniValue,CurrencyID>, AutoCloseable
Omni Core "REST" client that implements same interfaces as Omniwallet REST client
-
Nested Class Summary
Nested classes/interfaces inherited from interface foundation.omni.rpc.ConsensusFetcher
ConsensusFetcher.IndeterminateSnapshotException
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionOmniCoreClient
(OmniClient client) Constructor that takes an existing RxOmniClientOmniCoreClient
(SSLContext sslContext, org.bitcoinj.base.Network network, URI coreURI, String user, String pass) OmniCoreClient
(SSLContext sslContext, org.bitcoinj.base.Network network, URI coreURI, String user, String pass, boolean useZmq, boolean isOmniProxy) OmniCoreClient
(org.bitcoinj.base.Network network, URI coreURI, String user, String pass) -
Method Summary
Modifier and TypeMethodDescriptionbalancesForAddressAsync
(org.bitcoinj.base.Address address) Get balances for a single addresses asynchronouslybalancesForAddressesAsync
(List<org.bitcoinj.base.Address> addresses) Get balances for multiple addresses asynchronouslyvoid
close()
createSnapshot
(CurrencyID id, int blockHeight, SortedMap<org.bitcoinj.base.Address, BalanceEntry> entries) Create a ConsensusSnapshot record.Fetch the current block heightReturn current ChainTipCompletableFuture
<SortedMap<org.bitcoinj.base.Address, BalanceEntry>> getConsensusForCurrencyAsync
(CurrencyID currencyID) Asynchronously get a sorted address-balance map for currencyprotected static SSLContext
Return the defaultSSLContext
without declaring a checked exceptionDeprecated.use getRxOmniClientList
<org.bitcoinj.base.Address> Get all addresses in a wallet Requires wallet support to be activeGet a list of smart properties asynchronously.io.reactivex.rxjava3.core.Single
<TokenRichList<OmniValue, CurrencyID>> richList
(CurrencyID id, int n) org.reactivestreams.Publisher
<TokenRichList<OmniValue, CurrencyID>> richListUpdates
(CurrencyID id, int n) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface foundation.omni.rpc.ConsensusFetcher
attemptConsensusSnapshotAsync, completeOrRetryConsensusSnapshot, getConsensusForCurrency, getConsensusSnapshot, getConsensusSnapshotAsync
Methods inherited from interface foundation.omni.netapi.OmniBalanceService
balancesForAddress, balancesForAddresses
-
Field Details
-
client
-
-
Constructor Details
-
OmniCoreClient
Constructor that takes an existing RxOmniClient- Parameters:
client
- An existing client instance
-
OmniCoreClient
public OmniCoreClient(SSLContext sslContext, org.bitcoinj.base.Network network, URI coreURI, String user, String pass, boolean useZmq, boolean isOmniProxy) -
OmniCoreClient
public OmniCoreClient(SSLContext sslContext, org.bitcoinj.base.Network network, URI coreURI, String user, String pass) -
OmniCoreClient
-
-
Method Details
-
getDefaultSSLContext
Return the defaultSSLContext
without declaring a checked exception- Returns:
- The default
SSLContext
-
currentBlockHeightAsync
Description copied from interface:ConsensusFetcher
Fetch the current block height- Specified by:
currentBlockHeightAsync
in interfaceConsensusFetcher
- Returns:
- A future for the current block height of the remote consensus server
-
listSmartProperties
Description copied from interface:ConsensusFetcher
Get a list of smart properties asynchronously.- Specified by:
listSmartProperties
in interfaceConsensusFetcher
- Returns:
- List of OmniPropertyInfo including an entry for Bitcoin
-
getConsensusForCurrencyAsync
public CompletableFuture<SortedMap<org.bitcoinj.base.Address,BalanceEntry>> getConsensusForCurrencyAsync(CurrencyID currencyID) Description copied from interface:ConsensusFetcher
Asynchronously get a sorted address-balance map for currency- Specified by:
getConsensusForCurrencyAsync
in interfaceConsensusFetcher
- Parameters:
currencyID
- the currency.- Returns:
- a future for the address-balance map.
-
balancesForAddressesAsync
public CompletableFuture<OmniJBalances> balancesForAddressesAsync(List<org.bitcoinj.base.Address> addresses) Description copied from interface:OmniBalanceService
Get balances for multiple addresses asynchronously- Specified by:
balancesForAddressesAsync
in interfaceOmniBalanceService
- Parameters:
addresses
- List of addresses to query- Returns:
- A future, for a map of maps containing each property balance for each address
-
createSnapshot
public ConsensusSnapshot createSnapshot(CurrencyID id, int blockHeight, SortedMap<org.bitcoinj.base.Address, BalanceEntry> entries) Description copied from interface:ConsensusFetcher
Create a ConsensusSnapshot record. Fills in client-specific information.- Specified by:
createSnapshot
in interfaceConsensusFetcher
- Parameters:
id
- Currency IDblockHeight
- blockheightentries
- a map of BalanceEntry objects- Returns:
- ConsensusSnapshot
-
balancesForAddressAsync
public CompletableFuture<WalletAddressBalance> balancesForAddressAsync(org.bitcoinj.base.Address address) Description copied from interface:OmniBalanceService
Get balances for a single addresses asynchronously- Specified by:
balancesForAddressAsync
in interfaceOmniBalanceService
- Parameters:
address
- Single address to query- Returns:
- a future for a map of currency IDs to balances
-
getActiveChainTip
Description copied from interface:OmniBalanceService
Return current ChainTip- Specified by:
getActiveChainTip
in interfaceOmniBalanceService
- Returns:
- "active" ChainTip
-
getOmniClient
Deprecated.use getRxOmniClient -
getRxOmniClient
-
richList
public io.reactivex.rxjava3.core.Single<TokenRichList<OmniValue,CurrencyID>> richList(CurrencyID id, int n) - Specified by:
richList
in interfaceRichListService<OmniValue,
CurrencyID>
-
richListUpdates
public org.reactivestreams.Publisher<TokenRichList<OmniValue,CurrencyID>> richListUpdates(CurrencyID id, int n) - Specified by:
richListUpdates
in interfaceRichListService<OmniValue,
CurrencyID>
-
chainTipPublisher
- Specified by:
chainTipPublisher
in interfaceChainTipService
-
close
- Specified by:
close
in interfaceAutoCloseable
- Throws:
Exception
-
getWalletAddresses
public List<org.bitcoinj.base.Address> getWalletAddresses() throws JsonRpcStatusException, IOExceptionGet all addresses in a wallet Requires wallet support to be active- Returns:
- A list of addresses
- Throws:
JsonRpcStatusException
- JSON HTTP status was not 200IOException
- Exception at lower-level
-