@@ -882,7 +882,60 @@ impl ChainSource {
882882 }
883883 }
884884 } ,
885- Self :: BitcoindRpc { .. } => todo ! ( ) ,
885+ Self :: BitcoindRpc { bitcoind_rpc_client, tx_broadcaster, logger, .. } => {
886+ // While it's a bit unclear when we'd be able to lean on Bitcoin Core >v28
887+ // features, we should eventually switch to use `submitpackage` via the
888+ // `rust-bitcoind-json-rpc` crate rather than just broadcasting individual
889+ // transactions.
890+ let mut receiver = tx_broadcaster. get_broadcast_queue ( ) . await ;
891+ while let Some ( next_package) = receiver. recv ( ) . await {
892+ for tx in & next_package {
893+ let txid = tx. compute_txid ( ) ;
894+ let timeout_fut = tokio:: time:: timeout (
895+ Duration :: from_secs ( TX_BROADCAST_TIMEOUT_SECS ) ,
896+ bitcoind_rpc_client. broadcast_transaction ( tx) ,
897+ ) ;
898+ match timeout_fut. await {
899+ Ok ( res) => match res {
900+ Ok ( id) => {
901+ debug_assert_eq ! ( id, txid) ;
902+ log_trace ! (
903+ logger,
904+ "Successfully broadcast transaction {}" ,
905+ txid
906+ ) ;
907+ } ,
908+ Err ( e) => {
909+ log_error ! (
910+ logger,
911+ "Failed to broadcast transaction {}: {}" ,
912+ txid,
913+ e
914+ ) ;
915+ log_trace ! (
916+ logger,
917+ "Failed broadcast transaction bytes: {}" ,
918+ log_bytes!( tx. encode( ) )
919+ ) ;
920+ } ,
921+ } ,
922+ Err ( e) => {
923+ log_error ! (
924+ logger,
925+ "Failed to broadcast transaction due to timeout {}: {}" ,
926+ txid,
927+ e
928+ ) ;
929+ log_trace ! (
930+ logger,
931+ "Failed broadcast transaction bytes: {}" ,
932+ log_bytes!( tx. encode( ) )
933+ ) ;
934+ } ,
935+ }
936+ }
937+ }
938+ } ,
886939 }
887940 }
888941}
0 commit comments