-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Exclude inscribed utxos when calculating wallet balance (#1341)
- Loading branch information
Showing
2 changed files
with
36 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,24 @@ | ||
use super::*; | ||
use std::collections::BTreeSet; | ||
|
||
pub(crate) fn run(options: Options) -> Result { | ||
println!( | ||
"{}", | ||
options | ||
.bitcoin_rpc_client_for_wallet_command(false)? | ||
.get_balances()? | ||
.mine | ||
.trusted | ||
.to_sat() | ||
); | ||
let index = Index::open(&options)?; | ||
index.update()?; | ||
|
||
let inscription_outputs = index | ||
.get_inscriptions(None)? | ||
.keys() | ||
.map(|satpoint| satpoint.outpoint) | ||
.collect::<BTreeSet<OutPoint>>(); | ||
|
||
let mut balance = 0; | ||
for (outpoint, amount) in get_unspent_outputs(&options)? { | ||
if !inscription_outputs.contains(&outpoint) { | ||
balance += amount.to_sat() | ||
} | ||
} | ||
|
||
println!("{}", balance); | ||
|
||
Ok(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters