Skip to content

Commit 9c6e5e4

Browse files
committed
Add appropriate type for v17 and v18
1 parent b05f196 commit 9c6e5e4

File tree

15 files changed

+66
-33
lines changed

15 files changed

+66
-33
lines changed

integration_test/tests/wallet.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -385,8 +385,10 @@ fn wallet__import_multi() {
385385

386386
let json: ImportMulti = node.client.import_multi(&[req1, req2, req3]).expect("importmulti");
387387

388-
// checks(result): req2 contain error & req3 contain warnings
388+
// checks(result): req2 contain error & req3 contain warnings (for v18 upwards).
389389
assert!(json.0[1].error.is_some());
390+
// v17 bitcoin-rpc doesn't have the warnings field.
391+
#[cfg(not(feature = "v17"))]
390392
assert!(json.0[2].warnings.is_some());
391393
}
392394

types/src/v17/wallet/mod.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -569,8 +569,6 @@ pub struct ImportMulti(pub Vec<ImportMultiEntry>);
569569
pub struct ImportMultiEntry {
570570
/// The success.
571571
pub success: bool,
572-
/// The warnings.
573-
pub warnings: Option<Vec<String>>,
574572
/// The error.
575573
pub error: Option<JsonRpcError>,
576574
}

types/src/v18/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ pub use self::{
242242
util::{DeriveAddresses, GetDescriptorInfo},
243243
wallet::{
244244
GetReceivedByLabel, ListReceivedByLabel, ListReceivedByLabelError, ListUnspent,
245-
ListUnspentItem, ListWalletDir, ListWalletDirWallet,
245+
ListUnspentItem, ListWalletDir, ListWalletDirWallet, ImportMulti, ImportMultiEntry, JsonRpcError,
246246
},
247247
};
248248
#[doc(inline)]
@@ -268,7 +268,7 @@ pub use crate::v17::{
268268
GetRawTransactionVerbose, GetRawTransactionVerboseError, GetReceivedByAddress, GetTransaction,
269269
GetTransactionDetail, GetTransactionDetailError, GetTransactionError, GetTxOut, GetTxOutError,
270270
GetTxOutSetInfo, GetTxOutSetInfoError, GetUnconfirmedBalance, GetWalletInfo,
271-
GetWalletInfoError, GetZmqNotifications, ImportMulti, ImportMultiEntry, JsonRpcError,
271+
GetWalletInfoError, GetZmqNotifications,
272272
ListAddressGroupings, ListAddressGroupingsError, ListAddressGroupingsItem, ListBanned,
273273
ListLabels, ListLockUnspent, ListLockUnspentItem, ListLockUnspentItemError,
274274
ListReceivedByAddress, ListReceivedByAddressError, ListReceivedByAddressItem, ListSinceBlock,

types/src/v18/wallet/mod.rs

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,45 @@ pub use self::error::ListReceivedByLabelError;
1919
#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)]
2020
pub struct GetReceivedByLabel(pub f64);
2121

22+
/// Result of JSON-RPC method `importmulti`.
23+
///
24+
/// > importmulti requests ( options )
25+
/// >
26+
/// > Arguments:
27+
/// > 1. requests (json array, required) Data to be imported
28+
/// > [
29+
/// > { (json object)
30+
/// > "desc": "str", (string, optional) Descriptor to import. If using descriptor, do not also provide address/scriptPubKey, scripts, or pubkeys
31+
/// > "scriptPubKey": "script" | { "address":"address" }, (string / json, required) Type of scriptPubKey (string for script, json for address). Should not be provided if using a descriptor
32+
/// > "timestamp": timestamp | "now", (integer / string, required) Creation time of the key expressed in UNIX epoch time,or the string "now" to substitute the current synced blockchain time. The timestamp of the oldest key will determine how far back blockchain rescans need to begin for missing wallet transactions. "now" can be specified to bypass scanning, for keys which are known to never have been used, and 0 can be specified to scan the entire blockchain. Blocks up to 2 hours before the earliest key creation time of all keys being imported by the importmulti call will be scanned.
33+
/// > },
34+
/// > ...
35+
/// > ]
36+
#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)]
37+
pub struct ImportMulti(pub Vec<ImportMultiEntry>);
38+
39+
/// Represents a single entry in the importmulti result array.
40+
#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)]
41+
pub struct ImportMultiEntry {
42+
/// The success.
43+
pub success: bool,
44+
/// The warnings.
45+
pub warnings: Option<Vec<String>>,
46+
/// The error.
47+
pub error: Option<JsonRpcError>,
48+
}
49+
50+
/// Represents the error object in a JSON-RPC error response.
51+
#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)]
52+
pub struct JsonRpcError {
53+
/// The error code.
54+
pub code: i32,
55+
/// The error message.
56+
pub message: String,
57+
/// The error data.
58+
pub data: Option<serde_json::Value>, // Can hold arbitrary extra information
59+
}
60+
2261
/// Result of the JSON-RPC method `listreceivedbylabel`.
2362
///
2463
/// > listreceivedbylabel ( minconf include_empty include_watchonly )

types/src/v19/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ pub use crate::v17::{
266266
GetRawTransactionVerboseError, GetReceivedByAddress, GetTransaction, GetTransactionDetail,
267267
GetTransactionDetailError, GetTransactionError, GetTxOut, GetTxOutError, GetTxOutSetInfo,
268268
GetTxOutSetInfoError, GetUnconfirmedBalance, GetWalletInfo, GetWalletInfoError,
269-
GetZmqNotifications, ImportMulti, ImportMultiEntry, JsonRpcError, ListAddressGroupings,
269+
GetZmqNotifications, ListAddressGroupings,
270270
ListAddressGroupingsError, ListAddressGroupingsItem, ListBanned, ListLabels, ListLockUnspent,
271271
ListLockUnspentItem, ListLockUnspentItemError, ListReceivedByAddress,
272272
ListReceivedByAddressError, ListReceivedByAddressItem, ListSinceBlock, ListSinceBlockError,
@@ -284,5 +284,5 @@ pub use crate::v18::{
284284
ActiveCommand, AnalyzePsbt, AnalyzePsbtError, AnalyzePsbtInput, AnalyzePsbtInputMissing,
285285
AnalyzePsbtInputMissingError, DeriveAddresses, GetNodeAddresses, GetReceivedByLabel, JoinPsbts,
286286
ListReceivedByLabel, ListReceivedByLabelError, ListUnspent, ListUnspentItem, ListWalletDir,
287-
ListWalletDirWallet, NodeAddress, UtxoUpdatePsbt,
287+
ListWalletDirWallet, NodeAddress, UtxoUpdatePsbt, ImportMulti, ImportMultiEntry, JsonRpcError,
288288
};

types/src/v20/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ pub use crate::{
256256
GetRawTransactionVerboseError, GetReceivedByAddress, GetTransaction, GetTransactionDetail,
257257
GetTransactionDetailError, GetTransactionError, GetTxOut, GetTxOutError, GetTxOutSetInfo,
258258
GetTxOutSetInfoError, GetUnconfirmedBalance, GetWalletInfo, GetWalletInfoError,
259-
GetZmqNotifications, ImportMulti, ImportMultiEntry, JsonRpcError, ListAddressGroupings,
259+
GetZmqNotifications, ListAddressGroupings,
260260
ListAddressGroupingsError, ListAddressGroupingsItem, ListLabels, ListLockUnspent,
261261
ListLockUnspentItem, ListLockUnspentItemError, ListReceivedByAddress,
262262
ListReceivedByAddressError, ListReceivedByAddressItem, ListSinceBlock, ListSinceBlockError,
@@ -274,7 +274,7 @@ pub use crate::{
274274
ActiveCommand, AnalyzePsbt, AnalyzePsbtError, AnalyzePsbtInput, AnalyzePsbtInputMissing,
275275
AnalyzePsbtInputMissingError, DeriveAddresses, GetNodeAddresses, GetReceivedByLabel,
276276
JoinPsbts, ListReceivedByLabel, ListReceivedByLabelError, ListUnspent, ListUnspentItem,
277-
ListWalletDir, ListWalletDirWallet, NodeAddress, UtxoUpdatePsbt,
277+
ListWalletDir, ListWalletDirWallet, NodeAddress, UtxoUpdatePsbt, ImportMulti, ImportMultiEntry, JsonRpcError,
278278
},
279279
v19::{
280280
Bip9SoftforkInfo, Bip9SoftforkStatistics, Bip9SoftforkStatus, GetBalances, GetBalancesMine,

types/src/v21/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ pub use crate::{
259259
GetRawTransactionVerboseError, GetReceivedByAddress, GetTransaction, GetTransactionDetail,
260260
GetTransactionDetailError, GetTransactionError, GetTxOut, GetTxOutError, GetTxOutSetInfo,
261261
GetTxOutSetInfoError, GetUnconfirmedBalance, GetWalletInfo, GetWalletInfoError,
262-
GetZmqNotifications, ImportMulti, ImportMultiEntry, JsonRpcError, ListAddressGroupings,
262+
GetZmqNotifications, ListAddressGroupings,
263263
ListAddressGroupingsError, ListAddressGroupingsItem, ListLabels, ListLockUnspent,
264264
ListLockUnspentItem, ListLockUnspentItemError, ListReceivedByAddress,
265265
ListReceivedByAddressError, ListReceivedByAddressItem, ListSinceBlock, ListSinceBlockError,
@@ -277,7 +277,7 @@ pub use crate::{
277277
ActiveCommand, AnalyzePsbt, AnalyzePsbtError, AnalyzePsbtInput, AnalyzePsbtInputMissing,
278278
AnalyzePsbtInputMissingError, DeriveAddresses, GetNodeAddresses, GetReceivedByLabel,
279279
JoinPsbts, ListReceivedByLabel, ListReceivedByLabelError, ListUnspent, ListUnspentItem,
280-
ListWalletDir, ListWalletDirWallet, NodeAddress, UtxoUpdatePsbt,
280+
ListWalletDir, ListWalletDirWallet, NodeAddress, UtxoUpdatePsbt, ImportMulti, ImportMultiEntry, JsonRpcError,
281281
},
282282
v19::{
283283
Bip9SoftforkInfo, Bip9SoftforkStatistics, Bip9SoftforkStatus, GetBalances, GetBalancesMine,

types/src/v22/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ pub use crate::{
273273
GetRawTransactionVerboseError, GetReceivedByAddress, GetTransaction, GetTransactionDetail,
274274
GetTransactionDetailError, GetTransactionError, GetTxOut, GetTxOutError, GetTxOutSetInfo,
275275
GetTxOutSetInfoError, GetUnconfirmedBalance, GetWalletInfo, GetWalletInfoError,
276-
GetZmqNotifications, ImportMulti, ImportMultiEntry, JsonRpcError, ListAddressGroupings,
276+
GetZmqNotifications, ListAddressGroupings,
277277
ListAddressGroupingsError, ListAddressGroupingsItem, ListLabels, ListLockUnspent,
278278
ListLockUnspentItem, ListLockUnspentItemError, ListReceivedByAddress,
279279
ListReceivedByAddressError, ListReceivedByAddressItem, ListSinceBlock, ListSinceBlockError,
@@ -291,7 +291,7 @@ pub use crate::{
291291
ActiveCommand, AnalyzePsbt, AnalyzePsbtError, AnalyzePsbtInput, AnalyzePsbtInputMissing,
292292
AnalyzePsbtInputMissingError, DeriveAddresses, GetNodeAddresses, GetReceivedByLabel,
293293
JoinPsbts, ListReceivedByLabel, ListReceivedByLabelError, ListUnspent, ListUnspentItem,
294-
ListWalletDir, ListWalletDirWallet, NodeAddress, UtxoUpdatePsbt,
294+
ListWalletDir, ListWalletDirWallet, NodeAddress, UtxoUpdatePsbt, ImportMulti, ImportMultiEntry, JsonRpcError,
295295
},
296296
v19::{
297297
Bip9SoftforkInfo, Bip9SoftforkStatistics, Bip9SoftforkStatus, GetBalances, GetBalancesMine,

types/src/v23/mod.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -267,8 +267,7 @@ pub use crate::{
267267
GetRawTransactionVerbose, GetRawTransactionVerboseError, GetReceivedByAddress,
268268
GetTransaction, GetTransactionDetail, GetTransactionDetailError, GetTransactionError,
269269
GetTxOut, GetTxOutError, GetTxOutSetInfo, GetTxOutSetInfoError, GetUnconfirmedBalance,
270-
GetWalletInfo, GetWalletInfoError, GetZmqNotifications, ImportMulti, ImportMultiEntry,
271-
JsonRpcError, ListAddressGroupings, ListAddressGroupingsError, ListAddressGroupingsItem,
270+
GetWalletInfo, GetWalletInfoError, GetZmqNotifications, ListAddressGroupings, ListAddressGroupingsError, ListAddressGroupingsItem,
272271
ListLabels, ListLockUnspent, ListLockUnspentItem, ListLockUnspentItemError,
273272
ListReceivedByAddress, ListReceivedByAddressError, ListReceivedByAddressItem,
274273
ListSinceBlock, ListSinceBlockError, ListSinceBlockTransaction,
@@ -285,7 +284,7 @@ pub use crate::{
285284
ActiveCommand, AnalyzePsbt, AnalyzePsbtError, AnalyzePsbtInput, AnalyzePsbtInputMissing,
286285
AnalyzePsbtInputMissingError, DeriveAddresses, GetNodeAddresses, GetReceivedByLabel,
287286
JoinPsbts, ListReceivedByLabel, ListReceivedByLabelError, ListUnspent, ListUnspentItem,
288-
ListWalletDir, ListWalletDirWallet, NodeAddress, UtxoUpdatePsbt,
287+
ListWalletDir, ListWalletDirWallet, NodeAddress, UtxoUpdatePsbt, ImportMulti, ImportMultiEntry, JsonRpcError,
289288
},
290289
v19::{
291290
Bip9SoftforkInfo, Bip9SoftforkStatistics, Bip9SoftforkStatus, GetBalances, GetBalancesMine,

types/src/v24/mod.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -272,8 +272,7 @@ pub use crate::{
272272
GetRawTransactionVerbose, GetRawTransactionVerboseError, GetReceivedByAddress,
273273
GetTransaction, GetTransactionDetail, GetTransactionDetailError, GetTransactionError,
274274
GetTxOut, GetTxOutError, GetTxOutSetInfo, GetTxOutSetInfoError, GetUnconfirmedBalance,
275-
GetWalletInfo, GetWalletInfoError, GetZmqNotifications, ImportMulti, ImportMultiEntry,
276-
JsonRpcError, ListAddressGroupings, ListAddressGroupingsError, ListAddressGroupingsItem,
275+
GetWalletInfo, GetWalletInfoError, GetZmqNotifications, ListAddressGroupings, ListAddressGroupingsError, ListAddressGroupingsItem,
277276
ListLabels, ListLockUnspent, ListLockUnspentItem, ListLockUnspentItemError,
278277
ListReceivedByAddress, ListReceivedByAddressError, ListReceivedByAddressItem,
279278
ListSinceBlock, ListSinceBlockError, ListSinceBlockTransaction,
@@ -290,7 +289,7 @@ pub use crate::{
290289
ActiveCommand, AnalyzePsbt, AnalyzePsbtError, AnalyzePsbtInput, AnalyzePsbtInputMissing,
291290
AnalyzePsbtInputMissingError, DeriveAddresses, GetNodeAddresses, GetReceivedByLabel,
292291
JoinPsbts, ListReceivedByLabel, ListReceivedByLabelError, ListUnspent, ListUnspentItem,
293-
ListWalletDir, ListWalletDirWallet, NodeAddress, UtxoUpdatePsbt,
292+
ListWalletDir, ListWalletDirWallet, NodeAddress, UtxoUpdatePsbt, ImportMulti, ImportMultiEntry, JsonRpcError,
294293
},
295294
v19::{
296295
Bip9SoftforkInfo, Bip9SoftforkStatistics, Bip9SoftforkStatus, GetBalances, GetBalancesMine,

0 commit comments

Comments
 (0)