Skip to content

Commit e93eae9

Browse files
committed
Make serde renames consistent
Some of the renaming of the rpc returned fields was inconsistent. Go through them all and make them them consistent.
1 parent 6f92d18 commit e93eae9

File tree

22 files changed

+57
-41
lines changed

22 files changed

+57
-41
lines changed

client/src/client_sync/v17/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -262,8 +262,8 @@ pub enum SetBanCommand {
262262
#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)]
263263
pub struct ImportMultiRequest {
264264
/// Descriptor to import. If using descriptor, donot also provide address/scriptPubKey, scripts, or pubkeys.
265-
#[serde(skip_serializing_if = "Option::is_none")]
266-
pub desc: Option<String>, // from core v18 onwards.
265+
#[serde(rename = "desc", skip_serializing_if = "Option::is_none")]
266+
pub descriptor: Option<String>, // from core v18 onwards.
267267
/// Type of scriptPubKey (string for script, json for address). Should not be provided if using descriptor.
268268
#[serde(rename = "scriptPubKey", skip_serializing_if = "Option::is_none")]
269269
pub script_pubkey: Option<ImportMultiScriptPubKey>,

client/src/client_sync/v21/mod.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,8 @@ crate::impl_client_v17__wallet_process_psbt!();
188188
#[serde(deny_unknown_fields)]
189189
pub struct ImportDescriptorsRequest {
190190
/// Descriptor to import.
191-
pub desc: String,
191+
#[serde(rename = "desc")]
192+
pub descriptor: String,
192193
/// Time from which to start rescanning the blockchain for this descriptor, in UNIX epoch time or "now".
193194
pub timestamp: serde_json::Value,
194195
}

integration_test/tests/wallet.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,7 @@ fn wallet__import_descriptors() {
323323
let descriptor = format!("addr({})", address);
324324

325325
let request = ImportDescriptorsRequest {
326-
desc: descriptor,
326+
descriptor,
327327
timestamp: serde_json::Value::String("now".to_string()),
328328
};
329329

@@ -413,14 +413,14 @@ fn wallet__import_multi() {
413413
// NOTE: On v17, use a wallet-generated address (not raw script)
414414
// to ensure import succeeds, since the wallet already knows the key.
415415
let req1 = ImportMultiRequest {
416-
desc: None,
416+
descriptor: None,
417417
script_pubkey: Some(ImportMultiScriptPubKey::Script(dummy_script_hex.to_string())),
418418
timestamp: ImportMultiTimestamp::Now,
419419
};
420420

421421
// Uses an address (valid): success - false, with JSON-RPC error.
422422
let req2 = ImportMultiRequest {
423-
desc: None,
423+
descriptor: None,
424424
script_pubkey: Some(ImportMultiScriptPubKey::Address {
425425
address: addr.to_string(),
426426
}),
@@ -431,7 +431,7 @@ fn wallet__import_multi() {
431431
// on v18 onwards, it will return a watch-only warning.
432432
// NOTE: Works only for v18 onwards, as v17 doesn't support descriptors.
433433
let req3 = ImportMultiRequest {
434-
desc: Some(dummy_desc.to_string()),
434+
descriptor: Some(dummy_desc.to_string()),
435435
script_pubkey: None,
436436
timestamp: ImportMultiTimestamp::Time(1_700_000_000),
437437
};

types/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ pub struct ScriptPubkey {
194194
/// Only returned before in versions prior to 22 or for version 22 onwards if
195195
/// config option `-deprecatedrpc=addresses` is passed.
196196
#[serde(rename = "reqSigs")]
197-
pub req_sigs: Option<i64>,
197+
pub required_signatures: Option<i64>,
198198
/// The type, eg pubkeyhash.
199199
#[serde(rename = "type")]
200200
pub type_: String,

types/src/model/wallet.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -362,7 +362,7 @@ pub struct GetTransaction {
362362
#[serde(deny_unknown_fields)]
363363
pub struct GetTransactionDetail {
364364
/// Only returns true if imported addresses were involved in transaction. v20 and later only.
365-
pub involves_watchonly: Option<bool>,
365+
pub involves_watch_only: Option<bool>,
366366
/// DEPRECATED. The account name involved in the transaction, can be "" for the default account.
367367
pub account: Option<String>, // Docs are wrong, this is not documented as optional.
368368
/// The bitcoin address involved in the transaction.
@@ -787,7 +787,7 @@ pub struct WalletCreateFundedPsbt {
787787
#[serde(default, with = "bitcoin::amount::serde::as_btc")]
788788
pub fee: SignedAmount,
789789
/// The position of the added change output, or -1.
790-
pub change_pos: u32,
790+
pub change_position: u32,
791791
}
792792

793793
/// Models the result of JSON-RPC method `walletprocesspsbt`.

types/src/psbt/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ pub struct PsbtScript {
173173
pub hex: String,
174174
/// The type, eg 'pubkeyhash'.
175175
#[serde(rename = "type")]
176-
pub script_type: String,
176+
pub type_: String,
177177
}
178178

179179
impl PsbtScript {

types/src/v17/raw_transactions/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ pub struct DecodeScriptSegwit {
253253
pub addresses: Option<Vec<String>>,
254254
/// Address of P2SH script wrapping this redeem script (not returned if the script is already a P2SH).
255255
#[serde(rename = "p2sh-segwit")]
256-
pub p2sh_segtwit: Option<String>,
256+
pub p2sh_segwit: Option<String>,
257257
}
258258

259259
/// Result of JSON-RPC method `finalizepsbt`.

types/src/v17/wallet/into.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -390,7 +390,7 @@ impl GetTransactionDetail {
390390
let fee = self.fee.map(|fee| SignedAmount::from_btc(fee).map_err(E::Fee)).transpose()?;
391391

392392
Ok(model::GetTransactionDetail {
393-
involves_watchonly: None, // v20 and later only.
393+
involves_watch_only: None, // v20 and later only.
394394
account: self.account,
395395
address,
396396
category: self.category.into_model(),
@@ -742,8 +742,8 @@ impl WalletCreateFundedPsbt {
742742

743743
let psbt = self.psbt.parse::<Psbt>().map_err(E::Psbt)?;
744744
let fee = SignedAmount::from_btc(self.fee).map_err(E::Fee)?;
745-
let change_pos = crate::to_u32(self.change_pos, "change_pos")?;
746-
Ok(model::WalletCreateFundedPsbt { psbt, fee, change_pos })
745+
let change_position = crate::to_u32(self.change_position, "change_position")?;
746+
Ok(model::WalletCreateFundedPsbt { psbt, fee, change_position })
747747
}
748748
}
749749

types/src/v17/wallet/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1056,7 +1056,7 @@ pub struct WalletCreateFundedPsbt {
10561056
pub fee: f64,
10571057
/// The position of the added change output, or -1.
10581058
#[serde(rename = "changepos")]
1059-
pub change_pos: i64,
1059+
pub change_position: i64,
10601060
}
10611061

10621062
/// Result of the JSON-RPC method `walletprocesspsbt`.

types/src/v20/wallet/into.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ impl GetTransactionDetail {
7272
let fee = self.fee.map(|fee| SignedAmount::from_btc(fee).map_err(E::Fee)).transpose()?;
7373

7474
Ok(model::GetTransactionDetail {
75-
involves_watchonly: self.involves_watchonly,
75+
involves_watch_only: self.involves_watch_only,
7676
account: self.account,
7777
address,
7878
category: self.category.into_model(),

0 commit comments

Comments
 (0)