Crate lwk_wollet

Source
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:

§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 = Wollet::new(
    ElementsNetwork::LiquidTestnet,
    NoPersist::new(), // Do not persist data
    descriptor,
)?;

// 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::clients::asyncr;
pub use crate::clients::blocking;electrum
pub use clients::blocking::ElementsRpcClient;elements_rpc
pub use age;esplora
pub use bitcoincore_rpc;elements_rpc
pub 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§

amp2amp2
Create and use AMP2 wallets.
clients
Clients to fetch data from the Blockchain.
pegin
Pegin related functions (WIP)

Structs§

AddressResult
Value returned from crate::Wollet::address(), containing the confidential Address and the derivation index (the last element in the derivation path)
Contract
A contract defining metadata of an asset such the name and the ticker
DownloadTxResult
Transactions downloaded and unblinded
ElectrumClientelectrum and non-WebAssembly
A client to issue TCP requests to an electrum server.
ElectrumOptionselectrum and non-WebAssembly
Options for the ElectrumClient::with_options() method.
ExternalUtxo
A UTXO owned by another wallet
FsPersister
A file system persister that writes encrypted incremental updates
IssuanceDetails
Value returned from crate::Wollet::issuance() containing details about an issuance
NoPersist
Implementation of a Persister which persist nothing.
Recipient
A recipient of a transaction.
Tip
Blockchain tip
TxBuilder
A transaction builder
UnvalidatedRecipient
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.
WalletTx
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.
WalletTxOut
Details of a wallet transaction output used in WalletTx
Wollet
A watch-only wallet defined by a CT descriptor.
WolletDescriptor
A wrapper that contains only the subset of CT descriptors handled by wollet
WolletTxBuilder
A transaction builder.

Enums§

Chain
The chain can be either External or Internal.
ElectrumUrlelectrum and non-WebAssembly
An electrum url parsable from string in the following form: tcp://example.com:50001 or ssl://example.com:50002
ElementsNetwork
The network of the elements blockchain.
Entity
The entity of an asset, contains the domain of the issuer.
Error
Error type for the whole crate.
PersistError
Error type for the Persister trait.
UrlErrorelectrum and non-WebAssembly
Error type when parsing a string to the ElectrumUrl type.

Statics§

EC
The secp256k1 context, created once and reused across the crate since creating it is expensive.

Traits§

Persister
Trait for persisting updates.

Functions§

asset_ids
The asset id and reissuance token of the input
full_scan_to_index_with_electrum_clientelectrum
Like full_scan_with_electrum_client but scans up to a specific derivation index (see [‘BlockchainBackend::full_scan_to_index’] for details)
full_scan_with_electrum_clientelectrum
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§

BlindingPublicKey