Expand description
LWK is a collection of libraries for Liquid wallets.
lwk_wollet is the library for Watch-Only Wallets, the wollet spelling is not a typo but highlights the fact it is Watch-Only.
A Wollet is defined by a CT descriptor,
which consists in a Bitcoin descriptor plus the descriptor blinding key. More precisely a subset of descriptors are supported, everything parsed by WolletDescriptor.
Every method on the Wollet will operate on local data, without network calls. The wallet data is updated via the Wollet::apply_update() method.
With a wallet you can:
- Generate addresses via
Wollet::address(). - Pass it to a blockchain backend (
ElectrumClient,blocking::EsploraClient) to retrieve wallet history via theblocking::BlockchainBackend::full_scan()trait. Or asyncronously via theasyncr::EsploraClient::full_scan()method. The convenience methodfull_scan_with_electrum_client()is also provided. - Create transactions, inclunding issuances, reissuances and burn via the
TxBuilder. - Analyze a partially signed transaction with respect to the wallet via
Wollet::get_details().
§Examples
§Generate an address
let desc = "ct(slip77(ab5824f4477b4ebb00a132adfd8eb0b7935cf24f6ac151add5d1913db374ce92),elwpkh([759db348/84'/1'/0']tpubDCRMaF33e44pcJj534LXVhFbHibPbJ5vuLhSSPFAw57kYURv4tzXFL6LSnd78bkjqdmE3USedkbpXJUPA1tdzKfuYSL7PianceqAhwL2UkA/<0;1>/*))#cch6wrnp";
// Parse the descriptor and create the watch only wallet
let descriptor: WolletDescriptor = desc.parse()?;
let mut wollet = WolletBuilder::new(
ElementsNetwork::LiquidTestnet,
descriptor,
).build()?;
// Generate the address
let addr = wollet.address(None)?;
println!("Address: {} (index {})", addr.address(), addr.index());§Sync wallet
full_scan_with_electrum_client};
// Use an Electrum server
let electrum_url = ElectrumUrl::new("elements-testnet.blockstream.info:50002", true, true)?;
let mut electrum_client = ElectrumClient::new(&electrum_url)?;
full_scan_with_electrum_client(&mut wollet, &mut electrum_client)?;
// Print a summary of the wallet transactions
for tx in wollet.transactions()?.into_iter().rev() {
println!("TXID: {}, balance {:?}", tx.txid, tx.balance);
}§Create transaction
// Create a transaction
let recipient = UnvalidatedRecipient {
satoshi: 1000,
address: "tlq1qqgpjea0jcel4tqeln5kyxlrgqx2eh4vw67ecswm54476mddy3n0klrlmty5gn0wsdw4045rtl2y2wdtr4rdu6v93zds6zn8xd".to_string(),
asset: "144c654344aa716d6f3abcc1ca90e5641e4e2a7f633bc09fe3baf64585819a49".to_string(),
};
let pset = wollet
.tx_builder()
.add_unvalidated_recipient(&recipient)?
.finish()?;
// Then pass the PSET to the signer(s) for them to sign.Re-exports§
pub use crate::clients::Capability;pub use crate::clients::History;pub use crate::pegin::fed_peg_script;pub use crate::registry::RegistryAssetData;registrypub use crate::prices::CurrencyCode;pricespub use crate::prices::ExchangeRate;pricespub use crate::prices::ExchangeRates;pricespub use crate::prices::PricesFetcher;pricespub use crate::prices::PricesFetcherBuilder;pricespub use crate::clients::asyncr;pub use crate::clients::blocking;electrumpub use clients::blocking::ElementsRpcClient;elements_rpcpub use age;esplorapub use bitcoincore_rpc;elements_rpcpub use elements_miniscript;pub use elements_miniscript::elements;pub use elements_miniscript::elements::bitcoin;pub use elements_miniscript::elements::bitcoin::hashes;pub use elements_miniscript::elements::bitcoin::secp256k1;
Modules§
- amp0
amp0 - Manage AMP0 wallets.
- amp2
amp2 - Create and use AMP2 wallets.
- clients
- Clients to fetch data from the Blockchain.
- pegin
- Pegin related functions (WIP)
- prices
prices - Prices
- registry
registry - Registry related functions
Structs§
- Address
Result - Value returned from
crate::Wollet::address(), containing the confidentialAddressand the derivation index (the last element in the derivation path) - Asset
Amount - An asset identifier and an amount
- Contract
- A contract defining metadata of an asset such the name and the ticker
- Directory
IdHash - A tagged hash to generate the name of the subdirectory to store cache content
- Download
TxResult - Transactions downloaded and unblinded
- Electrum
Client electrum - A client to issue TCP requests to an electrum server.
- Electrum
Options electrum - Options for the
ElectrumClient::with_options()method. - Encrypted
Store - A
Storewrapper that encrypts values and (optionally) keys using AES-256-GCM-SIV. - External
Utxo - A UTXO owned by another wallet
- Fake
Store - A
Storeimplementation that intentionally persists nothing. - File
Store - A filesystem-backed implementation of
Store. - Issuance
Details - Value returned from
crate::Wollet::issuance()containing details about an issuance - Liquidex
Proposal - LiquiDEX swap proposal
- Memory
Store - A simple in-memory implementation of
Store. - PosConfig
prices - POS configuration structure for encoding/decoding. This represents the configuration parameters for a Point of Sale setup.
- Recipient
- A recipient of a transaction.
- Tip
- Blockchain tip, the highest valid block in the blockchain
- TxBuilder
- A transaction builder
- TxDetails
- Transaction details
- TxOpt
- Options for transaction details
- TxOut
Details - Transaction output details
- TxsOpt
- Options for transaction details
- Unvalidated
- A marker type to indicate an unvalidated
LiquidexProposalproposal - Unvalidated
Recipient - A not-yet validated recipient of a transaction.
- Update
- Passing a wallet to
crate::clients::blocking::BlockchainBackend::full_scan()returns this structure which contains the delta of information to be applied to the wallet to reach the latest status. - Validated
- A marker type to indicate a validated
LiquidexProposalproposal - Wallet
Tx - Value returned by
crate::Wollet::transactions()containing details about a transaction from the perspective of the wallet, for example the net-balance of the transaction for the wallet. - Wallet
TxOut - Details of a wallet transaction output used in
WalletTx - Wollet
- A watch-only wallet defined by a CT descriptor.
- Wollet
Builder - A builder for constructing
Wolletinstances - Wollet
Descriptor - A wrapper that contains only the subset of CT descriptors handled by wollet
- Wollet
TxBuilder - A transaction builder.
Enums§
- Chain
- The chain can be either External or Internal.
- Electrum
Url - An electrum url parsable from string in the following form:
tcp://example.com:50001orssl://example.com:50002 - Elements
Network - The network of the elements blockchain.
- Encrypted
Store Error - Error type for
EncryptedStoreoperations. - Entity
- The entity of an asset, contains the domain of the issuer.
- Error
- Error type for the whole crate.
- UrlError
- Error type when parsing a string to the
url::Urltype.
Statics§
- EC
- The secp256k1 context, created once and reused across the crate since creating it is expensive.
Traits§
- DynStore
- An object-safe key-value storage trait for use with
dyn. - Store
- A generic key-value storage interface.
Functions§
- asset_
ids - The asset id and reissuance token of the input
- full_
scan_ to_ index_ with_ electrum_ client electrum - Like
full_scan_with_electrum_clientbut scans up to a specific derivation index (see [‘BlockchainBackend::full_scan_to_index’] for details) - full_
scan_ with_ electrum_ client electrum - Performs a full blockchain scan using an Electrum client and applies any updates to the wallet.
- issuance_
ids - Compute the asset id and reissuance token id
Type Aliases§
- Blinding
Public Key - The blinding public key used for confidential addresses.
- BoxError
- A boxed error type for use with
DynStore.