mirror of
https://github.com/Qortal/piratewallet-light-cli.git
synced 2025-02-07 06:44:11 +00:00
Add historical utxos in notes all cmd
This commit is contained in:
parent
cb44b4a2a6
commit
bee501bae0
@ -11,7 +11,6 @@ pub trait Command {
|
|||||||
}
|
}
|
||||||
|
|
||||||
struct SyncCommand {}
|
struct SyncCommand {}
|
||||||
|
|
||||||
impl Command for SyncCommand {
|
impl Command for SyncCommand {
|
||||||
fn help(&self) {
|
fn help(&self) {
|
||||||
println!("Type sync for syncing");
|
println!("Type sync for syncing");
|
||||||
|
@ -218,6 +218,28 @@ impl LightClient {
|
|||||||
res["spent_notes"] = JsonValue::Array(spent_notes);
|
res["spent_notes"] = JsonValue::Array(spent_notes);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If all notes, also add historical utxos
|
||||||
|
if all_notes {
|
||||||
|
res["spent_utxos"] = JsonValue::Array(self.wallet.txs.read().unwrap().values()
|
||||||
|
.flat_map(|wtx| {
|
||||||
|
wtx.utxos.iter()
|
||||||
|
.filter(|utxo| utxo.spent.is_some())
|
||||||
|
.map(|utxo| {
|
||||||
|
object!{
|
||||||
|
"created_in_block" => wtx.block,
|
||||||
|
"created_in_txid" => format!("{}", utxo.txid),
|
||||||
|
"value" => utxo.value,
|
||||||
|
"scriptkey" => hex::encode(utxo.script.clone()),
|
||||||
|
"is_change" => false, // TODO: Identify notes as change
|
||||||
|
"address" => utxo.address.clone(),
|
||||||
|
"spent" => utxo.spent.map(|spent_txid| format!("{}", spent_txid)),
|
||||||
|
"unconfirmed_spent" => utxo.unconfirmed_spent.map(|spent_txid| format!("{}", spent_txid)),
|
||||||
|
}
|
||||||
|
}).collect::<Vec<JsonValue>>()
|
||||||
|
}).collect::<Vec<JsonValue>>()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
res
|
res
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user