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`.
This commit is contained in:
Michael Mallan 2025-04-08 13:06:58 +01:00
parent d4151d88d6
commit 2527bcea2e
No known key found for this signature in database
GPG Key ID: 5177CDCEDB0EABEB
2 changed files with 8 additions and 5 deletions

View File

@ -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`. |

View File

@ -186,10 +186,13 @@ impl<C: Client + Send + Sync + Debug> Daemon for Lianad<C> {
sequence: Option<u16>,
) -> Result<Psbt, DaemonError> {
// 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)
}