correctly initialize UTXO keychain kind

This commit is contained in:
Riccardo Casatta 2021-06-01 16:19:32 +02:00
parent e1b037a921
commit 81851190f0
No known key found for this signature in database
GPG Key ID: FD986A969E450397

View File

@ -242,17 +242,22 @@ impl Blockchain for RpcBlockchain {
} }
} }
let current_utxos: HashSet<LocalUtxo> = current_utxo let current_utxos: HashSet<_> = current_utxo
.into_iter() .into_iter()
.map(|u| LocalUtxo { .map(|u| {
outpoint: OutPoint::new(u.txid, u.vout), Ok(LocalUtxo {
txout: TxOut { outpoint: OutPoint::new(u.txid, u.vout),
value: u.amount.as_sat(), keychain: db
script_pubkey: u.script_pub_key, .get_path_from_script_pubkey(&u.script_pub_key)?
}, .ok_or(Error::TransactionNotFound)?
keychain: KeychainKind::External, .0,
txout: TxOut {
value: u.amount.as_sat(),
script_pubkey: u.script_pub_key,
},
})
}) })
.collect(); .collect::<Result<_, Error>>()?;
let spent: HashSet<_> = known_utxos.difference(&current_utxos).collect(); let spent: HashSet<_> = known_utxos.difference(&current_utxos).collect();
for s in spent { for s in spent {