File tree Expand file tree Collapse file tree 1 file changed +8
-3
lines changed
vendor/orchestra-event-observer/src/observer Expand file tree Collapse file tree 1 file changed +8
-3
lines changed Original file line number Diff line number Diff line change @@ -646,6 +646,7 @@ pub async fn handle_bitcoin_rpc_call(
646646
647647 let bitcoin_rpc_call = bitcoin_rpc_call. into_inner ( ) . clone ( ) ;
648648 let method = bitcoin_rpc_call. method . clone ( ) ;
649+
649650 let body = rocket:: serde:: json:: serde_json:: to_vec ( & bitcoin_rpc_call) . unwrap ( ) ;
650651
651652 let token = encode ( format ! (
@@ -659,6 +660,7 @@ pub async fn handle_bitcoin_rpc_call(
659660 config. bitcoin_node_rpc_host, config. bitcoin_node_rpc_port
660661 ) )
661662 . header ( "Content-Type" , "application/json" )
663+ . timeout ( std:: time:: Duration :: from_secs ( 5 ) )
662664 . header ( "Authorization" , format ! ( "Basic {}" , token) ) ;
663665
664666 if method == "sendrawtransaction" {
@@ -671,9 +673,12 @@ pub async fn handle_bitcoin_rpc_call(
671673 } ;
672674 }
673675
674- let res = builder. body ( body) . send ( ) . await . unwrap ( ) ;
675-
676- Json ( res. json ( ) . await . unwrap ( ) )
676+ match builder. body ( body) . send ( ) . await {
677+ Ok ( res) => Json ( res. json ( ) . await . unwrap ( ) ) ,
678+ Err ( _) => Json ( json ! ( {
679+ "status" : 500
680+ } ) ) ,
681+ }
677682}
678683
679684#[ post( "/v1/chainhooks" , format = "application/json" , data = "<hook>" ) ]
You can’t perform that action at this time.
0 commit comments