Skip to content
This repository has been archived by the owner on Aug 28, 2024. It is now read-only.

Commit

Permalink
add more filter on utxo fetch api
Browse files Browse the repository at this point in the history
  • Loading branch information
irnb committed Jul 29, 2024
1 parent 12a7ad3 commit 141215d
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions core/lib/via_btc_client/examples/data_inscription_example.rs
Original file line number Diff line number Diff line change
Expand Up @@ -457,6 +457,7 @@ async fn get_utxos(addr: &Address) -> Vec<(OutPoint, TxOut)> {
// call blockcypher api to get all utxos for the given address
// https://api.blockcypher.com/v1/btc/test3/addrs/tb1qvxglm3jqsawtct65drunhe6uvat2k58dhfugqu/full?limit=200

println!("start fetching utxo");
let url = format!(
"https://api.blockcypher.com/v1/btc/test3/addrs/{}/full?limit=200",
addr
Expand Down Expand Up @@ -499,6 +500,15 @@ async fn get_utxos(addr: &Address) -> Vec<(OutPoint, TxOut)> {
is_valid = false;
}

let vout_related_addresses = vout.get("addresses").unwrap().as_array().unwrap();
for vout_address in vout_related_addresses {
let vout_address = vout_address.as_str().unwrap();
if vout_address != addr.to_string() {
println!("skipping unrelated address output ...");
is_valid = false;
}
}

if value == 0 {
println!("skipping zero value output ...");
is_valid = false;
Expand Down

0 comments on commit 141215d

Please sign in to comment.