@@ -12,7 +12,9 @@ use std::{
1212
1313use corepc_types:: {
1414 bitcoin:: {
15- Block , BlockHash , Transaction , Txid , block:: Header , consensus:: encode:: deserialize_hex,
15+ Block , BlockHash , Transaction , Txid ,
16+ block:: Header ,
17+ consensus:: encode:: { deserialize_hex, serialize_hex} ,
1618 } ,
1719 model, v30,
1820} ;
@@ -226,6 +228,21 @@ impl Client {
226228 self . call :: < String > ( Rpc :: GetRawTransaction , & [ json ! ( txid) ] )
227229 . and_then ( |tx_hex| deserialize_hex ( & tx_hex) . map_err ( Error :: DecodeHex ) )
228230 }
231+
232+ /// Submits a raw transaction to the network.
233+ ///
234+ /// # Arguments
235+ ///
236+ /// * `tx`: The transaction to broadcast.
237+ ///
238+ /// # Returns
239+ ///
240+ /// The transaction ID (`Txid`) of the broadcasted transaction.
241+ pub fn send_raw_transaction ( & self , tx : & Transaction ) -> Result < Txid , Error > {
242+ let hex_tx = serialize_hex ( tx) ;
243+ let txid: Txid = self . call ( Rpc :: SendRawTransaction , & [ json ! ( hex_tx) ] ) ?;
244+ Ok ( txid)
245+ }
229246}
230247
231248#[ cfg( feature = "29_0" ) ]
@@ -265,6 +282,16 @@ impl Client {
265282 self . call ( Rpc :: GetBlock , & [ json ! ( block_hash) , json ! ( 1 ) ] ) ?;
266283 block_info. into_model ( ) . map_err ( Error :: model)
267284 }
285+
286+ /// Retrieves information about the blockchain state.
287+ ///
288+ /// # Returns
289+ ///
290+ /// State information as a `GetBlockchainInfo` struct.
291+ pub fn get_blockchain_info ( & self ) -> Result < model:: GetBlockchainInfo , Error > {
292+ let info: v30:: GetBlockchainInfo = self . call ( Rpc :: GetBlockchainInfo , & [ ] ) ?;
293+ info. into_model ( ) . map_err ( Error :: model)
294+ }
268295}
269296
270297#[ cfg( test) ]
0 commit comments