Skip to main content

Context

Client-wide setup: the wallet and the chain parameters the SDK needs.

Build one SwapContext at startup and pass it to every swap method that touches keys or the chain. The swap already knows its own chain, so the caller never chooses anything per call; the context supplies what a swap cannot know by itself.

Liquid swaps additionally need the network's genesis block hash and its policy asset (L-BTC). Read both from your own chain source, never from the swap server: the genesis hash is committed in every taproot signature the wallet produces, and the policy asset decides what a transaction pays its fee in, so a server that supplied them could make the user sign transactions that never confirm. A context built without them serves Bitcoin swaps only; Liquid methods on it throw.

Classes​

SwapContext​

The wallet and chain parameters shared by every swap of one client.

Constructors​

Constructor​
new SwapContext(wallet: Wallet, liquid?: LiquidParams): SwapContext;
Parameters​
ParameterTypeDescription
walletWalletWallet whose keys sign this client's swaps.
liquid?LiquidParamsLiquid chain parameters. Omit for a Bitcoin-only client.
Returns​

SwapContext

Properties​

PropertyModifierTypeDescription
innerreadonlySwapContextUnderlying wasm context. Exposed so swap helpers can forward it.

Accessors​

network​
Get Signature​
get network(): string;

Network this client operates on, from the wallet.

Returns​

string

Interfaces​

LiquidParams​

Liquid chain parameters. Both come from your own chain source, never from the swap server - see the module docs.

Properties​

PropertyTypeDescription
genesisHashstringGenesis block hash of the Liquid network, hex-encoded.
policyAssetstringPolicy (fee) asset id of the Liquid network, hex-encoded. L-BTC.