MCPcopy Create free account
hub / github.com/BitVM/BitVM / broadcast_and_verify

Function broadcast_and_verify

bridge/src/graphs/base.rs:95–112  ·  view source on GitHub ↗
(
    client: &AsyncClient,
    transaction: &Transaction,
)

Source from the content-addressed store, hash-verified

93}
94
95pub async fn broadcast_and_verify(
96 client: &AsyncClient,
97 transaction: &Transaction,
98) -> Result<&'static str, Error> {
99 let txid = transaction.compute_txid();
100
101 if let Ok(Some(_)) = client.get_tx(&txid).await {
102 return Ok("Tx already broadcasted.");
103 }
104
105 let tx_result = client.broadcast(transaction).await;
106
107 match (tx_result, is_confirmed(client, txid).await) {
108 (Ok(_), Ok(false)) | (Ok(_), Err(_)) => Ok("Tx broadcasted successfully."),
109 (Ok(_), Ok(true)) | (Err(_), Ok(true)) => Ok("Tx mined successfully."),
110 (Err(e), _) => Err(Error::Esplora(e)),
111 }
112}
113
114pub async fn get_tx_statuses(
115 client: &AsyncClient,

Callers 1

broadcast_txMethod · 0.85

Calls 1

is_confirmedFunction · 0.85

Tested by

no test coverage detected