diff --git a/src/query.rs b/src/query.rs index 5eb20d1..44f8973 100644 --- a/src/query.rs +++ b/src/query.rs @@ -18,14 +18,14 @@ pub struct Query<'a> { pub struct FundingOutput { pub txn_id: Sha256dHash, - pub height: u32, + pub height: i32, pub output_index: usize, pub value: u64, } pub struct SpendingInput { pub txn_id: Sha256dHash, - pub height: u32, + pub height: i32, pub input_index: usize, } @@ -37,7 +37,7 @@ pub struct Status { struct TxnHeight { txn: Transaction, - height: u32, + height: i32, } fn merklize(left: Sha256dHash, right: Sha256dHash) -> Sha256dHash { @@ -63,7 +63,10 @@ impl<'a> Query<'a> { let txid: Sha256dHash = deserialize(&key.txid).unwrap(); let txn: Transaction = self.get_tx(&txid); let height: u32 = bincode::deserialize(&row.value).unwrap(); - txns.push(TxnHeight { txn, height }) + txns.push(TxnHeight { + txn, + height: height as i32, + }) } } txns diff --git a/src/rpc.rs b/src/rpc.rs index 8f8a9b6..b0ed416 100644 --- a/src/rpc.rs +++ b/src/rpc.rs @@ -25,15 +25,15 @@ fn hash_from_value(val: Option<&Value>) -> Result { Ok(script_hash) } -fn history_from_status(status: &Status) -> Vec<(u32, Sha256dHash)> { - let mut txns_map = HashMap::::new(); +fn history_from_status(status: &Status) -> Vec<(i32, Sha256dHash)> { + let mut txns_map = HashMap::::new(); for f in &status.funding { txns_map.insert(f.txn_id, f.height); } for s in &status.spending { txns_map.insert(s.txn_id, s.height); } - let mut txns: Vec<(u32, Sha256dHash)> = + let mut txns: Vec<(i32, Sha256dHash)> = txns_map.into_iter().map(|item| (item.1, item.0)).collect(); txns.sort(); txns