(
client: &AsyncClient,
transaction: &Transaction,
)
| 93 | } |
| 94 | |
| 95 | pub 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 | |
| 114 | pub async fn get_tx_statuses( |
| 115 | client: &AsyncClient, |
no test coverage detected