diff --git a/rust-lightclient/src/commands.rs b/rust-lightclient/src/commands.rs index e24876d..1364531 100644 --- a/rust-lightclient/src/commands.rs +++ b/rust-lightclient/src/commands.rs @@ -11,7 +11,6 @@ pub trait Command { } struct SyncCommand {} - impl Command for SyncCommand { fn help(&self) { println!("Type sync for syncing"); diff --git a/rust-lightclient/src/lightclient.rs b/rust-lightclient/src/lightclient.rs index f7cede6..e2ef70f 100644 --- a/rust-lightclient/src/lightclient.rs +++ b/rust-lightclient/src/lightclient.rs @@ -218,6 +218,28 @@ impl LightClient { 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::>() + }).collect::>() + ); + } + res }