mirror of
https://github.com/Qortal/piratewallet-light-cli.git
synced 2025-11-02 05:07:01 +00:00
Add spendable to notes listing
This commit is contained in:
@@ -818,6 +818,8 @@ impl LightClient {
|
|||||||
let mut spent_notes : Vec<JsonValue> = vec![];
|
let mut spent_notes : Vec<JsonValue> = vec![];
|
||||||
let mut pending_notes: Vec<JsonValue> = vec![];
|
let mut pending_notes: Vec<JsonValue> = vec![];
|
||||||
|
|
||||||
|
let anchor_height: i32 = self.wallet.read().unwrap().get_anchor_height() as i32;
|
||||||
|
|
||||||
{
|
{
|
||||||
// Collect Sapling notes
|
// Collect Sapling notes
|
||||||
let wallet = self.wallet.read().unwrap();
|
let wallet = self.wallet.read().unwrap();
|
||||||
@@ -834,6 +836,7 @@ impl LightClient {
|
|||||||
"value" => nd.note.value,
|
"value" => nd.note.value,
|
||||||
"is_change" => nd.is_change,
|
"is_change" => nd.is_change,
|
||||||
"address" => LightWallet::note_address(self.config.hrp_sapling_address(), nd),
|
"address" => LightWallet::note_address(self.config.hrp_sapling_address(), nd),
|
||||||
|
"spendable" => wtx.block <= anchor_height && nd.spent.is_none() && nd.unconfirmed_spent.is_none(),
|
||||||
"spent" => nd.spent.map(|spent_txid| format!("{}", spent_txid)),
|
"spent" => nd.spent.map(|spent_txid| format!("{}", spent_txid)),
|
||||||
"spent_at_height" => nd.spent_at_height.map(|h| format!("{}", h)),
|
"spent_at_height" => nd.spent_at_height.map(|h| format!("{}", h)),
|
||||||
"unconfirmed_spent" => nd.unconfirmed_spent.map(|spent_txid| format!("{}", spent_txid)),
|
"unconfirmed_spent" => nd.unconfirmed_spent.map(|spent_txid| format!("{}", spent_txid)),
|
||||||
|
|||||||
@@ -733,6 +733,14 @@ impl LightWallet {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Get the height of the anchor block
|
||||||
|
pub fn get_anchor_height(&self) -> u32 {
|
||||||
|
match self.get_target_height_and_anchor_offset() {
|
||||||
|
Some((height, anchor_offset)) => height - anchor_offset as u32 - 1,
|
||||||
|
None => return 0,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub fn memo_str(memo: &Option<Memo>) -> Option<String> {
|
pub fn memo_str(memo: &Option<Memo>) -> Option<String> {
|
||||||
match memo {
|
match memo {
|
||||||
Some(memo) => {
|
Some(memo) => {
|
||||||
@@ -1003,10 +1011,7 @@ impl LightWallet {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn spendable_zbalance(&self, addr: Option<String>) -> u64 {
|
pub fn spendable_zbalance(&self, addr: Option<String>) -> u64 {
|
||||||
let anchor_height = match self.get_target_height_and_anchor_offset() {
|
let anchor_height = self.get_anchor_height();
|
||||||
Some((height, anchor_offset)) => height - anchor_offset as u32 - 1,
|
|
||||||
None => return 0,
|
|
||||||
};
|
|
||||||
|
|
||||||
self.txs
|
self.txs
|
||||||
.read()
|
.read()
|
||||||
|
|||||||
Reference in New Issue
Block a user