|
@ -456,14 +456,11 @@ fn handle_request(req: Request<Body>, query: &Arc<Query>, network: &Network) -> |
|
|
}, |
|
|
}, |
|
|
(&Method::GET, Some(&"tx"), Some(hash), Some(&"outspends"), None) => { |
|
|
(&Method::GET, Some(&"tx"), Some(hash), Some(&"outspends"), None) => { |
|
|
let hash = Sha256dHash::from_hex(hash)?; |
|
|
let hash = Sha256dHash::from_hex(hash)?; |
|
|
// optimize: avoid fetching the entire tx just for the vout count
|
|
|
let tx = query.tx_get(&hash).ok_or(StringError("cannot find tx".to_string()))?; |
|
|
let out_count = query.tx_get(&hash).ok_or(StringError("cannot find tx".to_string()))?.output.len(); |
|
|
let spends: Vec<SpendingValue> = query.find_spending_for_funding_tx(tx)? |
|
|
let mut spends = vec![]; |
|
|
.into_iter() |
|
|
for output_index in 0..out_count { |
|
|
.map(|spend| spend.map_or_else(|| SpendingValue::default(), |spend| SpendingValue::from(spend))) |
|
|
let spend = query.find_spending_by_outpoint((hash, output_index))? |
|
|
.collect(); |
|
|
.map_or_else(|| SpendingValue::default(), |spend| SpendingValue::from(spend)); |
|
|
|
|
|
spends.push(spend) |
|
|
|
|
|
} |
|
|
|
|
|
json_response(spends) |
|
|
json_response(spends) |
|
|
}, |
|
|
}, |
|
|
_ => { |
|
|
_ => { |
|
|