bitcoind: add the timestamp to the 'listdescriptors' entry

This commit is contained in:
Antoine Poinsot 2022-11-14 14:13:48 +01:00
parent 3c75e2e944
commit 337f422283
No known key found for this signature in database
GPG Key ID: E13FC145CD3F4304
2 changed files with 14 additions and 3 deletions

View File

@ -472,8 +472,18 @@ impl BitcoinD {
.try_into()
.expect("Range is always an array of size 2")
});
let timestamp = elem
.get("timestamp")
.and_then(Json::as_u64)
.expect("A valid timestamp is always present")
.try_into()
.expect("timestamp must fit");
ListDescEntry { desc, range }
ListDescEntry {
desc,
range,
timestamp,
}
})
.collect()
}
@ -894,6 +904,7 @@ fn roundup_progress(progress: f64) -> f64 {
pub struct ListDescEntry {
pub desc: String,
pub range: Option<[u32; 2]>,
pub timestamp: u32,
}
/// A 'received' entry in the 'listsinceblock' result.

View File

@ -516,10 +516,10 @@ mod tests {
let net_resp = [
"HTTP/1.1 200\n\r\n{\"jsonrpc\":\"2.0\",\"id\":1,\"result\":{\"descriptors\":[{\"desc\":\"".as_bytes(),
receive_desc.as_bytes(),
"\"},".as_bytes(),
"\",\"timestamp\":0},".as_bytes(),
"{\"desc\":\"".as_bytes(),
change_desc.as_bytes(),
"\"}]}}\n".as_bytes(),
"\",\"timestamp\":1}]}}\n".as_bytes(),
]
.concat();
let (mut stream, _) = server.accept().unwrap();