Update the Wallet

The fact that Wollet does have access to internet is a deliberate choice.

Update the Wallet

The fact that Wollet does have access to internet is a deliberate choice.
This allows Wollet to work offline, where they can generate addresses.

The connection is handled by a specific component, a Blockchain Client.
Blockchain clients connect to the specified server a fetch the wallet data from the blockchain.

LWK currently support 3 types of servers:

  • Electrum Servers
  • Esplora Servers
  • Waterfalls Servers

To delve into their differences and strength points see our dedicated section.

Create a Client

In this guide we will use an EsploraClient.

You can create a new client with EsploraClient::new(), specifying the URL of the service.

Scan the Blockchain

Given a Wollet you can call EsploraClient::full_scan(),
which performs a series of network calls that scan the blockchain to find transactions relevant for the wallet.

EsploraClient::full_scan() has a stopping mechanisms that relies on BIP44 GAP LIMIT.
This might not fit every use cases.
In case you have large sequences of consecutive unused addresses you can use
EsploraClient::full_scan_to_index().

Apply the Update

EsploraClient::full_scan() fetches, parses, (locally) unblind and serialized the fetched data in returned value, an Update.
The Update can be applied to the Wollet using Wollet::apply_update().

After applying the update the wollet data will include the new transaction downloaded,
for instance more transactions can be returned and balance can increase (or decrease).

use lwk_wollet::clients::blocking::EsploraClient;
// let url = "https://blockstream.info/liquidtestnet/api";
// let url = "https://blockstream.info/liquid/api";

let mut client = EsploraClient::new(&url, network)?;

if let Some(update) = client.full_scan(&wollet)? {
    wollet.apply_update(update)?;
}
url = "https://blockstream.info/liquidtestnet/api"
client = EsploraClient(url, network)

update = client.full_scan(wollet)
wollet.apply_update(update)
const url = "https://waterfalls.liquidwebwallet.org/liquidtestnet/api";
const client = new lwk.WaterfallsClient(network, url);

const update = await client.fullScan(wollet);
if (update) {
    wollet.applyUpdate(update);
}
	url := "https://blockstream.info/liquidtestnet/api"
	client, err := lwk.NewEsploraClient(url, network)
	if err != nil {
		log.Fatal(err)
	}

	update, err := client.FullScan(wollet)
	if err != nil {
		log.Fatal(err)
	}
	if update != nil {
		if err := wollet.ApplyUpdate(*update); err != nil {
			log.Fatal(err)
		}
	}

Next: Create a transaction


Did this page help you?

The Liquid Network is a Bitcoin layer-2 enabling the issuance of security tokens and other digital assets.

© 2023 Liquid Network
All rights reserved.

Feedback and Content Requests

We'd be happy to hear your suggestions on how we can improve this site.

BuildOnL2 Community

The official BuildOnL2 community lives
at community.liquid.net. Join us and build the future of Bitcoin on Liquid.

Telegram

Community-driven telegram group where
most of the Liquid developers hang out.
Go to t.me/liquid_devel to join.