(&self, withdrawer_chain_address: &str)
| 1749 | } |
| 1750 | |
| 1751 | async fn get_withdrawer_status(&self, withdrawer_chain_address: &str) -> Vec<Value> { |
| 1752 | join_all( |
| 1753 | self.data |
| 1754 | .peg_out_graphs |
| 1755 | .iter() |
| 1756 | .filter(|&graph| { |
| 1757 | if graph.peg_out_chain_event.is_some() { |
| 1758 | return graph |
| 1759 | .peg_out_chain_event |
| 1760 | .as_ref() |
| 1761 | .unwrap() |
| 1762 | .withdrawer_chain_address |
| 1763 | .eq(withdrawer_chain_address); |
| 1764 | } |
| 1765 | false |
| 1766 | }) |
| 1767 | .map(|graph| async { |
| 1768 | let (tx_json_value, tx_status_result) = match &graph.peg_out_transaction { |
| 1769 | Some(tx) => { |
| 1770 | let txid = tx.tx().compute_txid(); |
| 1771 | let tx_status_result = self.esplora.get_tx_status(&txid).await; |
| 1772 | let tx_status = tx_status_result.as_ref().unwrap_or(&TxStatus { |
| 1773 | confirmed: false, |
| 1774 | block_height: None, |
| 1775 | block_hash: None, |
| 1776 | block_time: None, |
| 1777 | }); |
| 1778 | let tx_json_value = json!({ |
| 1779 | "type": "peg_out", |
| 1780 | "txid": txid, |
| 1781 | "status": { |
| 1782 | "confirmed": tx_status.confirmed, |
| 1783 | "block_height": tx_status.block_height.unwrap_or(0), |
| 1784 | "block_hash": tx_status.block_hash.or(None), |
| 1785 | "block_time": tx_status.block_time.unwrap_or(0), |
| 1786 | } |
| 1787 | }); |
| 1788 | |
| 1789 | (Some(tx_json_value), Some(tx_status_result)) |
| 1790 | } |
| 1791 | None => (Some(json!([])), None), |
| 1792 | }; |
| 1793 | let (peg_out_amount, destination_address) = match &graph.peg_out_chain_event { |
| 1794 | Some(peg_out_chain_event) => ( |
| 1795 | peg_out_chain_event.amount.to_sat(), |
| 1796 | peg_out_chain_event.withdrawer_destination_address.clone(), |
| 1797 | ), |
| 1798 | None => (0, "".to_string()), |
| 1799 | }; |
| 1800 | |
| 1801 | let status = graph.interpret_withdrawer_status(tx_status_result.as_ref()); |
| 1802 | json!({ |
| 1803 | "type": "peg_out", |
| 1804 | "graph_id": graph.id(), |
| 1805 | "status": status.to_string(), |
| 1806 | "amount": peg_out_amount, |
| 1807 | "destination_address": destination_address, |
| 1808 | "txs": tx_json_value, |
no test coverage detected