Module bdk::blockchain::any [−][src]
Runtime-checked blockchain types
This module provides the implementation of AnyBlockchain
which allows switching the
inner Blockchain
type at runtime.
Example
In this example both wallet_electrum
and wallet_esplora
have the same type of
Wallet<AnyBlockchain, MemoryDatabase>
. This means that they could both, for instance, be
assigned to a struct member.
let electrum_blockchain = ElectrumBlockchain::from(electrum_client::Client::new("...")?); let wallet_electrum: Wallet<AnyBlockchain, _> = Wallet::new( "...", None, Network::Testnet, MemoryDatabase::default(), electrum_blockchain.into(), )?; let esplora_blockchain = EsploraBlockchain::new("...", None); let wallet_esplora: Wallet<AnyBlockchain, _> = Wallet::new( "...", None, Network::Testnet, MemoryDatabase::default(), esplora_blockchain.into(), )?;
When paired with the use of ConfigurableBlockchain
, it allows creating wallets with any
blockchain type supported using a single line of code:
let config = serde_json::from_str("...")?; let blockchain = AnyBlockchain::from_config(&config)?; let wallet = Wallet::new( "...", None, Network::Testnet, MemoryDatabase::default(), blockchain, )?;
Enums
AnyBlockchain | Type that can contain any of the |
AnyBlockchainConfig | Type that can contain any of the blockchain configurations defined by the library |