@@ -18,7 +18,7 @@ use std::path::Path;
1818
1919use bitcoin:: address:: { Address , NetworkChecked } ;
2020use bitcoin:: { sign_message, Amount , Block , BlockHash , PublicKey , Txid } ;
21- use serde:: { Deserialize , Serialize } ;
21+ use serde:: { Deserialize , Serialize , Serializer } ;
2222
2323use crate :: client_sync:: into_json;
2424use crate :: types:: v17:: * ;
@@ -128,6 +128,7 @@ crate::impl_client_v17__get_transaction!();
128128crate :: impl_client_v17__get_unconfirmed_balance!( ) ;
129129crate :: impl_client_v17__get_wallet_info!( ) ;
130130crate :: impl_client_v17__import_address!( ) ;
131+ crate :: impl_client_v17__import_multi!( ) ;
131132crate :: impl_client_v17__import_privkey!( ) ;
132133crate :: impl_client_v17__import_pruned_funds!( ) ;
133134crate :: impl_client_v17__import_pubkey!( ) ;
@@ -247,3 +248,48 @@ pub enum SetBanCommand {
247248 Add ,
248249 Remove ,
249250}
251+
252+ /// Args for the `importmulti` method
253+ #[ derive( Clone , Debug , Deserialize , PartialEq , Serialize ) ]
254+ pub struct ImportMultiRequest {
255+ /// Descriptor to import. If using descriptor, donot also provide address/scriptPubKey, scripts, or pubkeys.
256+ #[ serde( skip_serializing_if = "Option::is_none" ) ]
257+ pub desc : Option < String > , // from core v18 onwards.
258+ /// Type of scriptPubKey (string for script, json for address). Should not be provided if using descriptor.
259+ #[ serde( rename = "scriptPubKey" , skip_serializing_if = "Option::is_none" ) ]
260+ pub script_pub_key : Option < ImportMultiScriptPubKey > ,
261+ /// Creation time of the key expressed in UNIX epoch time, or the string "now" to substitute the current synced blockchain time.
262+ pub timestamp : ImportMultiTimestamp ,
263+ }
264+
265+ /// `scriptPubKey` can be a string for script or json for address.
266+ #[ derive( Clone , Debug , Deserialize , PartialEq , Serialize ) ]
267+ #[ serde( untagged) ]
268+ pub enum ImportMultiScriptPubKey {
269+ /// The script.
270+ Script ( String ) ,
271+ /// The address.
272+ Address { address : String } ,
273+ }
274+
275+ /// `timestamp` can be a number (UNIX epoch time) or the string `"now"`
276+ #[ derive( Clone , Debug , Deserialize , PartialEq ) ]
277+ #[ serde( untagged) ]
278+ pub enum ImportMultiTimestamp {
279+ /// The string "now".
280+ Now ,
281+ /// The UNIX timestamp.
282+ Time ( u64 ) ,
283+ }
284+
285+ impl Serialize for ImportMultiTimestamp {
286+ fn serialize < S > ( & self , serializer : S ) -> std:: result:: Result < S :: Ok , S :: Error >
287+ where
288+ S : Serializer ,
289+ {
290+ match self {
291+ ImportMultiTimestamp :: Now => serializer. serialize_str ( "now" ) ,
292+ ImportMultiTimestamp :: Time ( t) => serializer. serialize_u64 ( * t) ,
293+ }
294+ }
295+ }
0 commit comments