@@ -28,16 +28,16 @@ use dashcore::{
2828 Address , Amount , Block , OutPoint , PrivateKey , ProTxHash , PublicKey , QuorumHash , Transaction ,
2929} ;
3030use dashcore_private:: hex:: display:: DisplayHex ;
31- use hex :: ToHex ;
31+ use dashcore_rpc_json :: dashcore :: bls_sig_utils :: BLSSignature ;
3232use dashcore_rpc_json:: dashcore:: { BlockHash , ChainLock } ;
3333use dashcore_rpc_json:: { ProTxInfo , ProTxListType , QuorumType } ;
34+ use hex:: ToHex ;
3435use log:: Level :: { Debug , Trace , Warn } ;
35- use dashcore_rpc_json:: dashcore:: bls_sig_utils:: BLSSignature ;
3636
3737use crate :: error:: * ;
38- use crate :: Error :: UnexpectedStructure ;
3938use crate :: json;
4039use crate :: queryable;
40+ use crate :: Error :: UnexpectedStructure ;
4141
4242/// Crate-specific Result type, shorthand for `std::result::Result` with our
4343/// crate-specific Error type;
@@ -393,11 +393,17 @@ pub trait RpcApi: Sized {
393393
394394 /// Returns information about the best chainlock.
395395 fn get_best_chain_lock ( & self ) -> Result < ChainLock > {
396- let json:: GetBestChainLockResult { blockhash, height, signature, known_block : _ } = self . call ( "getbestchainlock" , & [ ] ) ?;
396+ let json:: GetBestChainLockResult {
397+ blockhash,
398+ height,
399+ signature,
400+ known_block : _,
401+ } = self . call ( "getbestchainlock" , & [ ] ) ?;
397402
398403 Ok ( ChainLock {
399404 block_height : height,
400- signature : BLSSignature :: try_from ( signature. as_slice ( ) ) . map_err ( |e| UnexpectedStructure ( e. to_string ( ) ) ) ?,
405+ signature : BLSSignature :: try_from ( signature. as_slice ( ) )
406+ . map_err ( |e| UnexpectedStructure ( e. to_string ( ) ) ) ?,
401407 block_hash : blockhash,
402408 } )
403409 }
@@ -421,7 +427,11 @@ pub trait RpcApi: Sized {
421427
422428 fn get_raw_change_address ( & self ) -> Result < Address < NetworkUnchecked > > {
423429 let data: String = self . call ( "getrawchangeaddress" , & [ ] ) ?;
424- let address = Address :: from_str ( & data) . map_err ( |_e| Error :: UnexpectedStructure ( "change address given by core was not an address" . to_string ( ) ) ) ?;
430+ let address = Address :: from_str ( & data) . map_err ( |_e| {
431+ Error :: UnexpectedStructure (
432+ "change address given by core was not an address" . to_string ( ) ,
433+ )
434+ } ) ?;
425435
426436 Ok ( address)
427437 }
@@ -442,7 +452,10 @@ pub trait RpcApi: Sized {
442452 transactions_by_block_hash : BTreeMap < & BlockHash , Vec < & dashcore:: Txid > > ,
443453 ) -> Result < BTreeMap < dashcore:: Txid , Transaction > > {
444454 let mut args = [ into_json ( transactions_by_block_hash) ?, into_json ( false ) ?] ;
445- let list = self . call :: < Vec < ( dashcore:: Txid , Transaction ) > > ( "getrawtransactionmulti" , handle_defaults ( & mut args, & [ null ( ) ] ) ) ?;
455+ let list = self . call :: < Vec < ( dashcore:: Txid , Transaction ) > > (
456+ "getrawtransactionmulti" ,
457+ handle_defaults ( & mut args, & [ null ( ) ] ) ,
458+ ) ?;
446459 Ok ( list. into_iter ( ) . collect ( ) )
447460 }
448461
@@ -512,7 +525,7 @@ pub trait RpcApi: Sized {
512525 . into_iter ( )
513526 . map ( |index| Ok ( into_json ( index. to_string ( ) ) ?) )
514527 . collect :: < Result < Vec < Value > > > ( ) ?;
515- let args = [ indices_json. into ( ) , opt_into_json ( height) ?] ;
528+ let args = [ indices_json. into ( ) , opt_into_json ( height) ?] ;
516529 self . call ( "getassetunlockstatuses" , & args)
517530 }
518531
@@ -1565,12 +1578,12 @@ pub trait RpcApi: Sized {
15651578 /// If the returned height is less than the given chain lock height this means that the chain lock was accepted but we did not yet have the block
15661579 /// If the returned height is equal to the chain lock height given this means that we are at the height of the chain lock
15671580 /// If the returned height is higher that the given chain lock this means that we ignored the chain lock because core had something better.
1568- fn submit_chain_lock (
1569- & self ,
1570- chain_lock : & ChainLock ,
1571- ) -> Result < u32 > {
1572- let mut args =
1573- [ into_json ( hex :: encode ( chain_lock . block_hash ) ) ? , into_json ( hex :: encode ( chain_lock . signature . as_bytes ( ) ) ) ? , into_json ( chain_lock . block_height ) ? ] ;
1581+ fn submit_chain_lock ( & self , chain_lock : & ChainLock ) -> Result < u32 > {
1582+ let mut args = [
1583+ into_json ( hex :: encode ( chain_lock . block_hash ) ) ? ,
1584+ into_json ( hex :: encode ( chain_lock . signature . as_bytes ( ) ) ) ? ,
1585+ into_json ( chain_lock . block_height ) ? ,
1586+ ] ;
15741587 self . call :: < u32 > ( "submitchainlock" , handle_defaults ( & mut args, & [ null ( ) ] ) )
15751588 }
15761589
0 commit comments