Skip to main content

Crate lwk_wollet

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 = 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;registry
pub use crate::prices::CurrencyCode;prices
pub use crate::prices::ExchangeRate;prices
pub use crate::prices::ExchangeRates;prices
pub use crate::prices::PricesFetcher;prices
pub use crate::prices::PricesFetcherBuilder;prices
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§

amp0amp0
Manage AMP0 wallets.
amp2amp2
Create and use AMP2 wallets.
clients
Clients to fetch data from the Blockchain.
pegin
Pegin related functions (WIP)
pricesprices
Prices
registryregistry
Registry related functions

Structs§

AddressResult
Value returned from crate::Wollet::address(), containing the confidential Address and the derivation index (the last element in the derivation path)
AssetAmount
An asset identifier and an amount
Contract
A contract defining metadata of an asset such the name and the ticker
DirectoryIdHash
A tagged hash to generate the name of the subdirectory to store cache content
DownloadTxResult
Transactions downloaded and unblinded
ElectrumClientelectrum
A client to issue TCP requests to an electrum server.
ElectrumOptionselectrum
Options for the ElectrumClient::with_options() method.
EncryptedStore
A Store wrapper that encrypts values and (optionally) keys using AES-256-GCM-SIV.
ExternalUtxo
A UTXO owned by another wallet
FakeStore
A Store implementation that intentionally persists nothing.
FileStore
A filesystem-backed implementation of Store.
IssuanceDetails
Value returned from crate::Wollet::issuance() containing details about an issuance
LiquidexProposal
LiquiDEX swap proposal
MemoryStore
A simple in-memory implementation of Store.
PosConfigprices
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
TxOutDetails
Transaction output details
TxsOpt
Options for transaction details
Unvalidated
A marker type to indicate an unvalidated LiquidexProposal proposal
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.
Validated
A marker type to indicate a validated LiquidexProposal proposal
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.
WolletBuilder
A builder for constructing Wollet instances
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.
ElectrumUrl
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.
EncryptedStoreError
Error type for EncryptedStore operations.
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::Url type.

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_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
The blinding public key used for confidential addresses.
BoxError
A boxed error type for use with DynStore.