@@ -780,7 +780,60 @@ impl ChainSource {
780780 }
781781 }
782782 } ,
783- Self :: BitcoindRpc { .. } => todo ! ( ) ,
783+ Self :: BitcoindRpc { bitcoind_rpc_client, tx_broadcaster, logger, .. } => {
784+ // While it's a bit unclear when we'd be able to lean on Bitcoin Core >v28
785+ // features, we should eventually switch to use `submitpackage` via the
786+ // `rust-bitcoind-json-rpc` crate rather than just broadcasting individual
787+ // transactions.
788+ let mut receiver = tx_broadcaster. get_broadcast_queue ( ) . await ;
789+ while let Some ( next_package) = receiver. recv ( ) . await {
790+ for tx in & next_package {
791+ let txid = tx. compute_txid ( ) ;
792+ let timeout_fut = tokio:: time:: timeout (
793+ Duration :: from_secs ( TX_BROADCAST_TIMEOUT_SECS ) ,
794+ bitcoind_rpc_client. broadcast_transaction ( tx) ,
795+ ) ;
796+ match timeout_fut. await {
797+ Ok ( res) => match res {
798+ Ok ( id) => {
799+ debug_assert_eq ! ( id, txid) ;
800+ log_trace ! (
801+ logger,
802+ "Successfully broadcast transaction {}" ,
803+ txid
804+ ) ;
805+ } ,
806+ Err ( e) => {
807+ log_error ! (
808+ logger,
809+ "Failed to broadcast transaction {}: {}" ,
810+ txid,
811+ e
812+ ) ;
813+ log_trace ! (
814+ logger,
815+ "Failed broadcast transaction bytes: {}" ,
816+ log_bytes!( tx. encode( ) )
817+ ) ;
818+ } ,
819+ } ,
820+ Err ( e) => {
821+ log_error ! (
822+ logger,
823+ "Failed to broadcast transaction due to timeout {}: {}" ,
824+ txid,
825+ e
826+ ) ;
827+ log_trace ! (
828+ logger,
829+ "Failed broadcast transaction bytes: {}" ,
830+ log_bytes!( tx. encode( ) )
831+ ) ;
832+ } ,
833+ }
834+ }
835+ }
836+ } ,
784837 }
785838 }
786839}
0 commit comments