we expect unspent outputs but play it safe (#517)

This commit is contained in:
Antioch Peverell 2020-09-14 12:17:12 +01:00 committed by GitHub
parent 073c63aa16
commit 8077d01004
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -321,7 +321,8 @@ impl NodeClient for HTTPNodeClient {
let params = json!([start_index, end_index, max_outputs, Some(true)]); let params = json!([start_index, end_index, max_outputs, Some(true)]);
let res = self.send_json_request::<OutputListing>("get_unspent_outputs", &params)?; let res = self.send_json_request::<OutputListing>("get_unspent_outputs", &params)?;
for out in res.outputs { // We asked for unspent outputs via the api but defensively filter out spent outputs just in case.
for out in res.outputs.into_iter().filter(|out| out.spent == false) {
let is_coinbase = match out.output_type { let is_coinbase = match out.output_type {
api::OutputType::Coinbase => true, api::OutputType::Coinbase => true,
api::OutputType::Transaction => false, api::OutputType::Transaction => false,