From 2527bcea2eef753fb776e1618c7d4b9b79801a3c Mon Sep 17 00:00:00 2001 From: Michael Mallan Date: Tue, 8 Apr 2025 13:06:58 +0100 Subject: [PATCH] fix: timelock parameter is optional The timelock parameter is optional in that it can be omitted, but if present it must have an integer value rather than a value of `null`. --- doc/API.md | 2 +- liana-gui/src/daemon/client/mod.rs | 11 +++++++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/doc/API.md b/doc/API.md index b6ce771e..63bfc62f 100644 --- a/doc/API.md +++ b/doc/API.md @@ -430,7 +430,7 @@ cover the requested feerate. | ---------- | ---------------------- | ----------------------------------------------------------------------------------------- | | `address` | str | The Bitcoin address to sweep the coins to. | | `feerate` | integer | Target feerate for the transaction, in satoshis per virtual byte. | -| `timelock` | int or `null` | Recovery path to be used, identified by the number of blocks after which it is available. | +| `timelock` | int (optional) | Recovery path to be used, identified by the number of blocks after which it is available. | | `outpoints`| list of str (optional) | List of the coins to be recovered, as `txid:vout`. | diff --git a/liana-gui/src/daemon/client/mod.rs b/liana-gui/src/daemon/client/mod.rs index e663e475..d08abc5d 100644 --- a/liana-gui/src/daemon/client/mod.rs +++ b/liana-gui/src/daemon/client/mod.rs @@ -186,10 +186,13 @@ impl Daemon for Lianad { sequence: Option, ) -> Result { // The `outpoints` parameter is omitted, which means all recoverable coins will be used. - let res: CreateRecoveryResult = self.call( - "createrecovery", - Some(vec![json!(address), json!(feerate_vb), json!(sequence)]), - )?; + let mut params = serde_json::Map::new(); + params.insert("address".to_string(), json!(address)); + params.insert("feerate".to_string(), json!(feerate_vb)); + if let Some(sequence) = sequence { + params.insert("timelock".to_string(), json!(sequence)); + } + let res: CreateRecoveryResult = self.call("createrecovery", Some(params))?; Ok(res.psbt) }