LWK setup with AMP2
LWK provides Rust wallet operations for Liquid. The page explains AMP2 client initialization, signer creation, xpub validation, and network configuration.
LWK (Liquid Wallet Kit) is the Rust library for Liquid wallet operations. AMP2 uses LWK internally and venues can use it for local wallet management, PSET construction, and signing.
What LWK provides
- Wallet creation from descriptors
- Address derivation
- Transaction construction (
TxBuilder) - PSET signing (
SwSigner) - Chain scanning via Esplora
- Network configuration (testnet, mainnet)
Dependencies
Add these to your Cargo.toml:
[dependencies]
lwk_wollet = "0.7"
lwk_signer = "0.7"
lwk_common = "0.7"Check crates.io for the latest versions.
Initialize the AMP2 client
The Amp2 client connects to an AMP2 server using your keyorigin xpub:
let keyorigin_xpub = "[b805d768/87h/1h/0h]tpubDCYEgnLyCH2okSittQNNB8JHLwPgmoEAoKcMrJDHP9dFVamsadPAFJQ77C1htgR8ksie3VksLXoryng9AUaPZSF8FwTwEv6CaHp8j2YCrds";
let amp_url = "https://amp.enterprise.blockstream.com/";
let amp2 = Amp2::new(keyorigin_xpub.to_string(), amp_url.to_string()).unwrap();Choosing the right URL
| Network | URL | Derivation path |
|---|---|---|
| Testnet | https://amp.enterprise.blockstream.com/ | 87h/1h/0h |
| Mainnet | Provided during onboarding | 87h/0h/0h |
The xpub derivation path must match the target network. Testnet uses coin type 1, mainnet uses coin type 0.
Create a software signer
If you need to sign PSETs locally (for venue initiated transfers):
use lwk_signer::SwSigner;
use lwk_common::Bip;
let signer = SwSigner::new("your twelve or twenty four mnemonic words here", false).unwrap();
let my_xpub = signer.keyorigin_xpub(&Bip::new_bip84()).unwrap();The false parameter means testnet. Set true for mainnet.
Validate xpub/network alignment
Before registering wallets, verify that your xpub matches the target network:
// Testnet xpubs start with "tpub"
assert!(keyorigin_xpub.contains("tpub"));
// Mainnet xpubs start with "xpub"
// assert!(keyorigin_xpub.contains("xpub"));Mismatched xpub/network combinations will produce invalid descriptors that AMP2 rejects.
Network configuration
LWK uses ElementsNetwork to configure chain parameters:
let network = amp2.elements_network(); // Returns testnet or mainnet based on URLUse this when constructing transactions with TxBuilder to ensure correct fee handling and address encoding.
Next steps
- Wallet Registration: register a descriptor and get a WID
- Signing PSETs: build and sign transactions
- Environments: testnet vs. mainnet details
Investor and venue guide overview
The guide supports wallet teams, brokers, exchanges, and venues that integrate AMP2-managed assets. The page explains interaction models, capabilities, and guide structure.
Wallet registration
Wallet registration creates a wallet entry in AMP2 and returns a wallet ID. The page explains descriptor construction, registration behavior, wallet strategy, and next steps.