File tree Expand file tree Collapse file tree 2 files changed +24
-0
lines changed Expand file tree Collapse file tree 2 files changed +24
-0
lines changed Original file line number Diff line number Diff line change @@ -1155,6 +1155,27 @@ pub trait RpcApi: Sized {
1155
1155
self . call ( "uptime" , & [ ] )
1156
1156
}
1157
1157
1158
+ /// Submit a block
1159
+ fn submit_block ( & self , block : & bitcoin:: Block ) -> Result < ( ) > {
1160
+ let block_hex: String = bitcoin:: consensus:: encode:: serialize_hex ( block) ;
1161
+ self . submit_block_hex ( & block_hex)
1162
+ }
1163
+
1164
+ /// Submit a raw block
1165
+ fn submit_block_bytes ( & self , block_bytes : & [ u8 ] ) -> Result < ( ) > {
1166
+ let block_hex: String = block_bytes. to_hex ( ) ;
1167
+ self . submit_block_hex ( & block_hex)
1168
+ }
1169
+
1170
+ /// Submit a block as a hex string
1171
+ fn submit_block_hex ( & self , block_hex : & str ) -> Result < ( ) > {
1172
+ match self . call ( "submitblock" , & [ into_json ( & block_hex) ?] ) {
1173
+ Ok ( serde_json:: Value :: Null ) => Ok ( ( ) ) ,
1174
+ Ok ( res) => Err ( Error :: ReturnedError ( res. to_string ( ) ) ) ,
1175
+ Err ( err) => Err ( err. into ( ) ) ,
1176
+ }
1177
+ }
1178
+
1158
1179
fn scan_tx_out_set_blocking (
1159
1180
& self ,
1160
1181
descriptors : & [ json:: ScanTxOutRequest ] ,
Original file line number Diff line number Diff line change @@ -29,6 +29,8 @@ pub enum Error {
29
29
InvalidCookieFile ,
30
30
/// The JSON result had an unexpected structure.
31
31
UnexpectedStructure ,
32
+ /// The daemon returned an error string.
33
+ ReturnedError ( String ) ,
32
34
}
33
35
34
36
impl From < jsonrpc:: error:: Error > for Error {
@@ -85,6 +87,7 @@ impl fmt::Display for Error {
85
87
Error :: InvalidAmount ( ref e) => write ! ( f, "invalid amount: {}" , e) ,
86
88
Error :: InvalidCookieFile => write ! ( f, "invalid cookie file" ) ,
87
89
Error :: UnexpectedStructure => write ! ( f, "the JSON result had an unexpected structure" ) ,
90
+ Error :: ReturnedError ( ref s) => write ! ( f, "the daemon returned an error string: {}" , s) ,
88
91
}
89
92
}
90
93
}
You can’t perform that action at this time.
0 commit comments