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()
.map(|u| LocalUtxo {
outpoint: OutPoint::new(u.txid, u.vout),
txout: TxOut {
value: u.amount.as_sat(),
script_pubkey: u.script_pub_key,
},
keychain: KeychainKind::External,
.map(|u| {
Ok(LocalUtxo {
outpoint: OutPoint::new(u.txid, u.vout),
keychain: db
.get_path_from_script_pubkey(&u.script_pub_key)?
.ok_or(Error::TransactionNotFound)?
.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();
for s in spent {