Skip to content

Commit

Permalink
Merge branch 'mempool' into mononaut/block-tx-confs
Browse files Browse the repository at this point in the history
  • Loading branch information
softsimon authored Nov 13, 2023
2 parents ae9fc93 + 157dbf2 commit de99ae3
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions src/rest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1025,6 +1025,29 @@ fn handle_request(
json_response(tx.remove(0), ttl)
}
}
(&Method::POST, Some(&INTERNAL_PREFIX), Some(&"txs"), None, None, None) => {
let txid_strings: Vec<String> =
serde_json::from_slice(&body).map_err(|err| HttpError::from(err.to_string()))?;

match txid_strings
.into_iter()
.map(|txid| Txid::from_hex(&txid))
.collect::<Result<Vec<Txid>, _>>()
{
Ok(txids) => {
let txs: Vec<(Transaction, Option<BlockId>)> = txids
.iter()
.filter_map(|txid| {
query
.lookup_txn(txid)
.map(|tx| (tx, query.chain().tx_confirming_block(txid)))
})
.collect();
json_response(prepare_txs(txs, query, config), 0)
}
Err(err) => http_message(StatusCode::BAD_REQUEST, err.to_string(), 0),
}
}
(&Method::GET, Some(&"tx"), Some(hash), Some(out_type @ &"hex"), None, None)
| (&Method::GET, Some(&"tx"), Some(hash), Some(out_type @ &"raw"), None, None) => {
let hash = Txid::from_hex(hash)?;
Expand Down

0 comments on commit de99ae3

Please sign in to comment.