Skip to content

Commit 9f2be16

Browse files
authored
Merge pull request #524 from jamillambert/0226-scriptpubkey-capitalization
Use consistent capitalization for (Script)PubKey
2 parents 054608c + abd9f78 commit 9f2be16

39 files changed

Lines changed: 155 additions & 155 deletions

File tree

types/src/lib.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -174,11 +174,11 @@ pub fn compact_size_decode(slice: &mut &[u8]) -> u64 {
174174
///
175175
/// This is used by methods in the blockchain section and in the raw transaction section (i.e raw
176176
/// transaction and psbt methods). The shape changed in Core v22 but the new shape is fully
177-
/// backwards compatible so we only provide it not a v0.17 specific type. The `mtype::ScriptPubkey`
177+
/// backwards compatible so we only provide it not a v0.17 specific type. The `mtype::ScriptPubKey`
178178
/// mirrors this design (but with concrete `rust-bitcoin` types).
179179
#[derive(Clone, Debug, PartialEq, Eq, Deserialize, Serialize)]
180180
#[cfg_attr(feature = "serde-deny-unknown-fields", serde(deny_unknown_fields))]
181-
pub struct ScriptPubkey {
181+
pub struct ScriptPubKey {
182182
/// Script assembly.
183183
pub asm: String,
184184
/// Inferred descriptor for the output. v23 and later only.
@@ -204,9 +204,9 @@ pub struct ScriptPubkey {
204204
pub addresses: Option<Vec<String>>,
205205
}
206206

207-
/// Error when converting a `ScriptPubkey` type into the model type.
207+
/// Error when converting a `ScriptPubKey` type into the model type.
208208
#[derive(Debug)]
209-
pub enum ScriptPubkeyError {
209+
pub enum ScriptPubKeyError {
210210
/// Conversion of the `hex` field failed.
211211
Hex(hex::HexToBytesError),
212212
/// Conversion of the `address` field failed.
@@ -215,7 +215,7 @@ pub enum ScriptPubkeyError {
215215
Addresses(address::ParseError),
216216
}
217217

218-
impl fmt::Display for ScriptPubkeyError {
218+
impl fmt::Display for ScriptPubKeyError {
219219
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
220220
match *self {
221221
Self::Hex(ref e) => write_err!(f, "conversion of the `hex` field failed"; e),
@@ -227,7 +227,7 @@ impl fmt::Display for ScriptPubkeyError {
227227
}
228228

229229
#[cfg(feature = "std")]
230-
impl std::error::Error for ScriptPubkeyError {
230+
impl std::error::Error for ScriptPubKeyError {
231231
fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
232232
match *self {
233233
Self::Hex(ref e) => Some(e),
@@ -237,7 +237,7 @@ impl std::error::Error for ScriptPubkeyError {
237237
}
238238
}
239239

240-
impl ScriptPubkey {
240+
impl ScriptPubKey {
241241
fn script_buf(&self) -> Result<ScriptBuf, hex::HexToBytesError> {
242242
ScriptBuf::from_hex(&self.hex)
243243
}
@@ -247,8 +247,8 @@ impl ScriptPubkey {
247247
}
248248

249249
/// Converts version specific type to a version nonspecific, more strongly typed type.
250-
pub fn into_model(self) -> Result<model::ScriptPubkey, ScriptPubkeyError> {
251-
use ScriptPubkeyError as E;
250+
pub fn into_model(self) -> Result<model::ScriptPubKey, ScriptPubKeyError> {
251+
use ScriptPubKeyError as E;
252252

253253
let script_pubkey = ScriptBuf::from_hex(&self.hex).map_err(E::Hex)?;
254254

@@ -264,7 +264,7 @@ impl ScriptPubkey {
264264
})
265265
.transpose()?;
266266

267-
Ok(model::ScriptPubkey {
267+
Ok(model::ScriptPubKey {
268268
script_pubkey,
269269
required_signatures: self.required_signatures,
270270
address,

types/src/model/blockchain.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ use bitcoin::{
1515
};
1616
use serde::{Deserialize, Serialize};
1717

18-
use super::{GetRawTransactionVerbose, ScriptPubkey};
18+
use super::{GetRawTransactionVerbose, ScriptPubKey};
1919

2020
/// Models the result of JSON-RPC method `dumptxoutset`.
2121
#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)]
@@ -202,7 +202,7 @@ pub struct GetBlockVerboseThreePrevout {
202202
/// The value in BTC.
203203
pub value: Amount,
204204
/// The script pubkey.
205-
pub script_pubkey: ScriptPubkey,
205+
pub script_pubkey: ScriptPubKey,
206206
}
207207

208208
/// Models the result of JSON-RPC method `getblockchaininfo`.
@@ -636,7 +636,7 @@ pub struct SpendActivity {
636636
/// The vout of the prevout.
637637
pub prevout_vout: u32,
638638
/// The prev scriptPubKey.
639-
pub prevout_spk: ScriptPubkey,
639+
pub prevout_spk: ScriptPubKey,
640640
}
641641

642642
/// Models a 'receive' activity event. Part of `getdescriptoractivity`
@@ -653,7 +653,7 @@ pub struct ReceiveActivity {
653653
/// The vout of the receiving output.
654654
pub vout: u32,
655655
/// The ScriptPubKey.
656-
pub output_spk: ScriptPubkey,
656+
pub output_spk: ScriptPubKey,
657657
}
658658

659659
/// Models the result of JSON-RPC method `getdifficulty`.

types/src/model/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ pub use self::{
8585
/// transaction and psbt methods).
8686
#[derive(Clone, Debug, PartialEq, Eq, Deserialize, Serialize)]
8787
#[cfg_attr(feature = "serde-deny-unknown-fields", serde(deny_unknown_fields))]
88-
pub struct ScriptPubkey {
88+
pub struct ScriptPubKey {
8989
/// The script_pubkey parsed from hex.
9090
pub script_pubkey: ScriptBuf,
9191
/// Number of required signatures - deprecated in Core v22.

types/src/model/raw_transactions.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ pub struct DecodeRawTransaction(pub Transaction);
9191
/// Models the result of JSON-RPC method `decodescript`.
9292
#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)]
9393
pub struct DecodeScript {
94-
/// The `scriptPubkey`.
94+
/// The `scriptPubKey`.
9595
pub script_pubkey: Option<ScriptBuf>,
9696
/// Inferred descriptor for the script. v23 and later only.
9797
pub descriptor: Option<String>,

types/src/model/wallet.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -171,10 +171,10 @@ pub struct GetAddressInfo {
171171
pub enum ScriptType {
172172
/// Non-standard output script type.
173173
NonStandard,
174-
/// Pubkey output script.
175-
Pubkey,
176-
/// Pubkey hash output script.
177-
PubkeyHash,
174+
/// PubKey output script.
175+
PubKey,
176+
/// PubKey hash output script.
177+
PubKeyHash,
178178
/// Script hash output script.
179179
ScriptHash,
180180
/// Multisig output script.

types/src/psbt/error.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -92,14 +92,14 @@ pub enum RawTransactionOutputError {
9292
/// Conversion of the output `value` field failed.
9393
Value(amount::ParseAmountError),
9494
/// Conversion of the output `script_pubkey` field failed.
95-
ScriptPubkey(hex::HexToBytesError),
95+
ScriptPubKey(hex::HexToBytesError),
9696
}
9797

9898
impl fmt::Display for RawTransactionOutputError {
9999
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
100100
match *self {
101101
Self::Value(ref e) => write_err!(f, "conversion of the output `value` field failed"; e),
102-
Self::ScriptPubkey(ref e) =>
102+
Self::ScriptPubKey(ref e) =>
103103
write_err!(f, "conversion of the output `script_pubkey` field failed"; e),
104104
}
105105
}
@@ -110,7 +110,7 @@ impl std::error::Error for RawTransactionOutputError {
110110
fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
111111
match *self {
112112
Self::Value(ref e) => Some(e),
113-
Self::ScriptPubkey(ref e) => Some(e),
113+
Self::ScriptPubKey(ref e) => Some(e),
114114
}
115115
}
116116
}
@@ -121,14 +121,14 @@ pub enum WitnessUtxoError {
121121
/// Conversion of the `amount` field failed.
122122
Amount(ParseAmountError),
123123
/// Conversion of the `script_pubkey` field failed.
124-
ScriptPubkey(hex::HexToBytesError),
124+
ScriptPubKey(hex::HexToBytesError),
125125
}
126126

127127
impl fmt::Display for WitnessUtxoError {
128128
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
129129
match *self {
130130
Self::Amount(ref e) => write_err!(f, "conversion of the `amount` field failed"; e),
131-
Self::ScriptPubkey(ref e) =>
131+
Self::ScriptPubKey(ref e) =>
132132
write_err!(f, "conversion of the `script_pubkey` field failed"; e),
133133
}
134134
}
@@ -139,7 +139,7 @@ impl std::error::Error for WitnessUtxoError {
139139
fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
140140
match *self {
141141
Self::Amount(ref e) => Some(e),
142-
Self::ScriptPubkey(ref e) => Some(e),
142+
Self::ScriptPubKey(ref e) => Some(e),
143143
}
144144
}
145145
}
@@ -178,7 +178,7 @@ impl std::error::Error for PartialSignatureError {
178178
#[derive(Debug)]
179179
pub enum Bip32DerivError {
180180
/// Conversion of the pubkey failed.
181-
Pubkey(key::ParsePublicKeyError),
181+
PubKey(key::ParsePublicKeyError),
182182
/// Conversion of the `master_fingerprint` field failed.
183183
MasterFingerprint(hex::HexToArrayError),
184184
/// Conversion of the `path` field failed.
@@ -188,7 +188,7 @@ pub enum Bip32DerivError {
188188
impl fmt::Display for Bip32DerivError {
189189
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
190190
match *self {
191-
Self::Pubkey(ref e) => write_err!(f, "conversion of the pubkey failed"; e),
191+
Self::PubKey(ref e) => write_err!(f, "conversion of the pubkey failed"; e),
192192
Self::MasterFingerprint(ref e) =>
193193
write_err!(f, "conversion of the `master_fingerprint` field failed"; e),
194194
Self::Path(ref e) => write_err!(f, "conversion of the `path` field failed"; e),
@@ -200,7 +200,7 @@ impl fmt::Display for Bip32DerivError {
200200
impl std::error::Error for Bip32DerivError {
201201
fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
202202
match *self {
203-
Self::Pubkey(ref e) => Some(e),
203+
Self::PubKey(ref e) => Some(e),
204204
Self::MasterFingerprint(ref e) => Some(e),
205205
Self::Path(ref e) => Some(e),
206206
}

types/src/psbt/mod.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ pub use self::error::{
1515
Bip32DerivError, PartialSignatureError, RawTransactionError, RawTransactionInputError,
1616
RawTransactionOutputError, WitnessUtxoError,
1717
};
18-
use crate::{ScriptPubkey, ScriptSig};
18+
use crate::{ScriptPubKey, ScriptSig};
1919

2020
/// Represents a bitcoin transaction.
2121
///
@@ -147,7 +147,7 @@ pub struct RawTransactionOutput {
147147
pub index: u64,
148148
/// The script pubkey.
149149
#[serde(rename = "scriptPubKey")]
150-
pub script_pubkey: ScriptPubkey,
150+
pub script_pubkey: ScriptPubKey,
151151
}
152152

153153
impl RawTransactionOutput {
@@ -156,7 +156,7 @@ impl RawTransactionOutput {
156156
use RawTransactionOutputError as E;
157157

158158
let value = Amount::from_btc(self.value).map_err(E::Value)?;
159-
let script_pubkey = self.script_pubkey.script_buf().map_err(E::ScriptPubkey)?;
159+
let script_pubkey = self.script_pubkey.script_buf().map_err(E::ScriptPubKey)?;
160160

161161
Ok(TxOut { value, script_pubkey })
162162
}
@@ -171,7 +171,7 @@ pub struct WitnessUtxo {
171171
pub amount: f64,
172172
/// The scriptPubKey.
173173
#[serde(rename = "scriptPubKey")]
174-
pub script_pubkey: ScriptPubkey,
174+
pub script_pubkey: ScriptPubKey,
175175
}
176176

177177
impl WitnessUtxo {
@@ -180,7 +180,7 @@ impl WitnessUtxo {
180180
use WitnessUtxoError as E;
181181

182182
let value = Amount::from_btc(self.amount).map_err(E::Amount)?;
183-
let script_pubkey = self.script_pubkey.script_buf().map_err(E::ScriptPubkey)?;
183+
let script_pubkey = self.script_pubkey.script_buf().map_err(E::ScriptPubKey)?;
184184

185185
Ok(TxOut { value, script_pubkey })
186186
}
@@ -295,7 +295,7 @@ pub fn map_into_bip32_derivation(
295295

296296
let mut map = BTreeMap::default();
297297
for (k, v) in hash_map.iter() {
298-
let pubkey = k.parse::<PublicKey>().map_err(E::Pubkey)?;
298+
let pubkey = k.parse::<PublicKey>().map_err(E::PubKey)?;
299299
let fingerprint =
300300
Fingerprint::from_hex(&v.master_fingerprint).map_err(E::MasterFingerprint)?;
301301
let path = v.path.parse::<DerivationPath>().map_err(E::Path)?;
@@ -314,7 +314,7 @@ pub fn vec_into_bip32_derivation(
314314

315315
let mut map = BTreeMap::default();
316316
for deriv in v.iter() {
317-
let pubkey = deriv.pubkey.parse::<PublicKey>().map_err(E::Pubkey)?;
317+
let pubkey = deriv.pubkey.parse::<PublicKey>().map_err(E::PubKey)?;
318318
let fingerprint =
319319
Fingerprint::from_hex(&deriv.master_fingerprint).map_err(E::MasterFingerprint)?;
320320
let path = deriv.path.parse::<DerivationPath>().map_err(E::Path)?;

types/src/v17/blockchain/error.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -443,7 +443,7 @@ impl From<ParseAmountError> for GetMempoolInfoError {
443443
/// Error when converting a `GetTxOut` type into the model type.
444444
///
445445
/// Note that variants in this type are not named in the usual fashion. The `ScriptBuf` and
446-
/// `Address` variants are named after the functions on [`crate::ScriptPubkey`].
446+
/// `Address` variants are named after the functions on [`crate::ScriptPubKey`].
447447
#[derive(Debug)]
448448
pub enum GetTxOutError {
449449
/// Conversion of numeric type to expected type failed.
@@ -452,9 +452,9 @@ pub enum GetTxOutError {
452452
BestBlock(hex::HexToArrayError),
453453
/// Conversion of the transaction `value` field failed.
454454
Value(amount::ParseAmountError),
455-
/// Conversion of the `ScriptPubkey` hex to a `ScriptBuf` failed.
455+
/// Conversion of the `ScriptPubKey` hex to a `ScriptBuf` failed.
456456
ScriptBuf(hex::HexToBytesError),
457-
/// Conversion of the `ScriptPubkey` `address` field failed.
457+
/// Conversion of the `ScriptPubKey` `address` field failed.
458458
Address(address::ParseError),
459459
}
460460

@@ -466,9 +466,9 @@ impl fmt::Display for GetTxOutError {
466466
write_err!(f, "conversion of the `beast_block` field failed"; e),
467467
Self::Value(ref e) => write_err!(f, "conversion of the `value` field failed"; e),
468468
Self::ScriptBuf(ref e) =>
469-
write_err!(f, "conversion of the `ScriptPubkey` hex to a `ScriptBuf` failed"; e),
469+
write_err!(f, "conversion of the `ScriptPubKey` hex to a `ScriptBuf` failed"; e),
470470
Self::Address(ref e) =>
471-
write_err!(f, "conversion of the `ScriptPubkey` `address` field failed"; e),
471+
write_err!(f, "conversion of the `ScriptPubKey` `address` field failed"; e),
472472
}
473473
}
474474
}

types/src/v17/blockchain/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ use serde::{Deserialize, Serialize};
1313

1414
// TODO: Remove wildcard, use explicit types.
1515
pub use self::error::*;
16-
use crate::{model, ScriptPubkey};
16+
use crate::{model, ScriptPubKey};
1717

1818
/// Result of JSON-RPC method `getbestblockhash`.
1919
///
@@ -628,7 +628,7 @@ pub struct GetTxOut {
628628
pub value: f64,
629629
/// The script pubkey.
630630
#[serde(rename = "scriptPubKey")]
631-
pub script_pubkey: ScriptPubkey,
631+
pub script_pubkey: ScriptPubKey,
632632
/// Coinbase or not.
633633
pub coinbase: bool,
634634
}

types/src/v17/util/error.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ pub enum ValidateAddressError {
4040
/// Conversion of the `address` field failed.
4141
Address(address::ParseError),
4242
/// Conversion of the `script_pubkey` field failed.
43-
ScriptPubkey(hex::HexToBytesError),
43+
ScriptPubKey(hex::HexToBytesError),
4444
/// The `witness_version` field's value was too big for a u8.
4545
WitnessVersionValue(i64),
4646
/// Conversion of the `witness_version` field failed.
@@ -55,7 +55,7 @@ impl fmt::Display for ValidateAddressError {
5555
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
5656
match *self {
5757
Self::Address(ref e) => write!(f, "conversion of the `address` field failed: {}", e),
58-
Self::ScriptPubkey(ref e) =>
58+
Self::ScriptPubKey(ref e) =>
5959
write!(f, "conversion of the `script_pubkey` field failed: {}", e),
6060
Self::WitnessVersionValue(v) => write!(f, "invalid witness version number: {}", v),
6161
Self::WitnessVersion(ref e) =>
@@ -76,7 +76,7 @@ impl std::error::Error for ValidateAddressError {
7676
fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
7777
match *self {
7878
Self::Address(ref e) => Some(e),
79-
Self::ScriptPubkey(ref e) => Some(e),
79+
Self::ScriptPubKey(ref e) => Some(e),
8080
Self::WitnessVersionValue(_) => None,
8181
Self::WitnessVersion(ref e) => Some(e),
8282
Self::WitnessProgramBytes(ref e) => Some(e),

0 commit comments

Comments
 (0)