Skip to content

Commit d65d26c

Browse files
committed
Add missing return fields to createmultisig
One of the methods, `createmultisig` was missing a field in v20. It is missing another field in v23. Add all of the missing fields and update the models, into function and reexports accordingly. Redefinitions of the types and into functions are copies of the v17 versions with the missing field added.
1 parent 414ba10 commit d65d26c

File tree

16 files changed

+147
-18
lines changed

16 files changed

+147
-18
lines changed

types/src/model/util.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ pub struct CreateMultisig {
1616
pub address: Address<NetworkUnchecked>,
1717
/// The string value of the hex-encoded redemption script.
1818
pub redeem_script: ScriptBuf,
19+
/// The descriptor for this multisig. v0.20 and later only.
20+
pub descriptor: Option<String>,
21+
/// Any warnings resulting from the creation of this multisig. v23 and later only.
22+
pub warnings: Option<Vec<String>>,
1923
}
2024

2125
/// Models the result of JSON-RPC method `estimatesmartfee`.

types/src/v17/util/into.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ impl CreateMultisig {
1717
let address = self.address.parse::<Address<_>>().map_err(E::Address)?;
1818
let redeem_script = ScriptBuf::from_hex(&self.redeem_script).map_err(E::RedeemScript)?;
1919

20-
Ok(model::CreateMultisig { address, redeem_script })
20+
Ok(model::CreateMultisig { address, redeem_script, descriptor: None, warnings: None })
2121
}
2222
}
2323

types/src/v20/mod.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,18 +228,20 @@
228228
// JSON-RPC types by API section.
229229
mod control;
230230
mod network;
231+
mod util;
231232

232233
#[doc(inline)]
233234
pub use self::{
234235
control::Logging,
235236
network::{Banned, ListBanned},
237+
util::CreateMultisig,
236238
};
237239
#[doc(inline)]
238240
pub use crate::{
239241
v17::{
240242
AbortRescan, AddMultisigAddress, AddMultisigAddressError, AddedNode, AddedNodeAddress,
241243
AddressInformation, BumpFee, BumpFeeError, ChainTips, ChainTipsError, ChainTipsStatus,
242-
CombinePsbt, CombineRawTransaction, ConvertToPsbt, CreateMultisig, CreateMultisigError,
244+
CombinePsbt, CombineRawTransaction, ConvertToPsbt, CreateMultisigError,
243245
CreatePsbt, CreateRawTransaction, CreateWallet, DecodePsbt, DecodePsbtError,
244246
DecodeRawTransaction, DecodeScript, DecodeScriptError, DumpPrivKey, DumpWallet,
245247
EncryptWallet, EstimateSmartFee, FinalizePsbt, FinalizePsbtError, FundRawTransaction,

types/src/v20/util/into.rs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// SPDX-License-Identifier: CC0-1.0
2+
3+
use bitcoin::{Address, ScriptBuf};
4+
5+
use super::{CreateMultisig, CreateMultisigError};
6+
use crate::model;
7+
8+
impl CreateMultisig {
9+
/// Converts version specific type to a version nonspecific, more strongly typed type.
10+
pub fn into_model(self) -> Result<model::CreateMultisig, CreateMultisigError> {
11+
use CreateMultisigError as E;
12+
13+
let address = self.address.parse::<Address<_>>().map_err(E::Address)?;
14+
let redeem_script = ScriptBuf::from_hex(&self.redeem_script).map_err(E::RedeemScript)?;
15+
16+
Ok(model::CreateMultisig {
17+
address,
18+
redeem_script,
19+
descriptor: Some(self.descriptor),
20+
warnings: None,
21+
})
22+
}
23+
}

types/src/v20/util/mod.rs

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
// SPDX-License-Identifier: CC0-1.0
2+
3+
//! The JSON-RPC API for Bitcoin Core `v0.20` - util.
4+
//!
5+
//! Types for methods found under the `== Util ==` section of the API docs.
6+
7+
mod into;
8+
9+
use serde::{Deserialize, Serialize};
10+
11+
pub use super::CreateMultisigError;
12+
13+
/// Result of JSON-RPC method `createmultisig`.
14+
///
15+
/// > createmultisig nrequired ["key",...] ( "address_type" )
16+
/// >
17+
/// > Creates a multi-signature address with n signature of m keys required.
18+
/// > It returns a json object with the address and redeemScript.
19+
/// >
20+
/// > Arguments:
21+
/// > 1. nrequired (numeric, required) The number of required signatures out of the n keys.
22+
/// > 2. "keys" (string, required) A json array of hex-encoded public keys
23+
/// > [
24+
/// > "key" (string) The hex-encoded public key
25+
/// > ,...
26+
/// > ]
27+
#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)]
28+
pub struct CreateMultisig {
29+
/// The value of the new multisig address.
30+
pub address: String,
31+
/// The string value of the hex-encoded redemption script.
32+
#[serde(rename = "redeemScript")]
33+
pub redeem_script: String,
34+
/// The descriptor for this multisig.
35+
pub descriptor: String,
36+
}

types/src/v21/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ pub use crate::{
242242
v17::{
243243
AbortRescan, AddMultisigAddress, AddMultisigAddressError, AddedNode, AddedNodeAddress,
244244
AddressInformation, BumpFee, BumpFeeError, ChainTips, ChainTipsError, ChainTipsStatus,
245-
CombinePsbt, CombineRawTransaction, ConvertToPsbt, CreateMultisig, CreateMultisigError,
245+
CombinePsbt, CombineRawTransaction, ConvertToPsbt, CreateMultisigError,
246246
CreatePsbt, CreateRawTransaction, CreateWallet, DecodePsbt, DecodePsbtError,
247247
DecodeRawTransaction, DecodeScript, DecodeScriptError, DumpPrivKey, DumpWallet,
248248
EncryptWallet, EstimateSmartFee, FinalizePsbt, FinalizePsbtError, FundRawTransaction,
@@ -287,5 +287,5 @@ pub use crate::{
287287
MempoolEntry, MempoolEntryError, MempoolEntryFees, MempoolEntryFeesError, PeerInfo,
288288
Softfork, SoftforkType,
289289
},
290-
v20::{Banned, ListBanned, Logging},
290+
v20::{Banned, CreateMultisig, ListBanned, Logging},
291291
};

types/src/v22/mod.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ pub use crate::{
256256
v17::{
257257
AbortRescan, AddMultisigAddress, AddMultisigAddressError, AddedNode, AddedNodeAddress,
258258
AddressInformation, BumpFee, BumpFeeError, ChainTips, ChainTipsError, ChainTipsStatus,
259-
CombinePsbt, CombineRawTransaction, ConvertToPsbt, CreateMultisig, CreateMultisigError,
259+
CombinePsbt, CombineRawTransaction, ConvertToPsbt, CreateMultisigError,
260260
CreatePsbt, CreateRawTransaction, CreateWallet, DecodePsbt, DecodePsbtError,
261261
DecodeRawTransaction, DecodeScript, DecodeScriptError, DumpPrivKey, DumpWallet,
262262
EncryptWallet, EstimateSmartFee, FinalizePsbt, FinalizePsbtError, FundRawTransaction,
@@ -301,6 +301,7 @@ pub use crate::{
301301
MempoolEntry, MempoolEntryError, MempoolEntryFees, MempoolEntryFeesError, PeerInfo,
302302
Softfork, SoftforkType,
303303
},
304+
v20::CreateMultisig,
304305
v21::{GetMempoolEntry, UnloadWallet},
305306
ScriptPubkey,
306307
};

types/src/v23/mod.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,20 +238,22 @@
238238
// JSON-RPC types by API section.
239239
mod blockchain;
240240
mod raw_transactions;
241+
mod util;
241242

242243
#[doc(inline)]
243244
pub use self::{
244245
blockchain::{GetMempoolEntry, SaveMempool},
245246
raw_transactions::{
246247
DecodePsbt, DecodePsbtError, GlobalXpub, Proprietary, PsbtInput, PsbtOutput,
247248
},
249+
util::CreateMultisig,
248250
};
249251
#[doc(inline)]
250252
pub use crate::{
251253
v17::{
252254
AbortRescan, AddMultisigAddress, AddMultisigAddressError, AddedNode, AddedNodeAddress,
253255
AddressInformation, BumpFee, BumpFeeError, ChainTips, ChainTipsError, ChainTipsStatus,
254-
CombinePsbt, CombineRawTransaction, ConvertToPsbt, CreateMultisig, CreateMultisigError,
256+
CombinePsbt, CombineRawTransaction, ConvertToPsbt, CreateMultisigError,
255257
CreatePsbt, CreateRawTransaction, CreateWallet, DecodeRawTransaction, DecodeScript,
256258
DecodeScriptError, DumpPrivKey, DumpWallet, EncryptWallet, EstimateSmartFee, FinalizePsbt,
257259
FinalizePsbtError, FundRawTransaction, FundRawTransactionError, Generate,

types/src/v23/util/into.rs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// SPDX-License-Identifier: CC0-1.0
2+
3+
use bitcoin::{Address, ScriptBuf};
4+
5+
use super::{CreateMultisig, CreateMultisigError};
6+
use crate::model;
7+
8+
impl CreateMultisig {
9+
/// Converts version specific type to a version nonspecific, more strongly typed type.
10+
pub fn into_model(self) -> Result<model::CreateMultisig, CreateMultisigError> {
11+
use CreateMultisigError as E;
12+
13+
let address = self.address.parse::<Address<_>>().map_err(E::Address)?;
14+
let redeem_script = ScriptBuf::from_hex(&self.redeem_script).map_err(E::RedeemScript)?;
15+
16+
Ok(model::CreateMultisig {
17+
address,
18+
redeem_script,
19+
descriptor: Some(self.descriptor),
20+
warnings: self.warnings,
21+
})
22+
}
23+
}

types/src/v23/util/mod.rs

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
// SPDX-License-Identifier: CC0-1.0
2+
3+
//! The JSON-RPC API for Bitcoin Core `v0.20` - util.
4+
//!
5+
//! Types for methods found under the `== Util ==` section of the API docs.
6+
7+
mod into;
8+
9+
use serde::{Deserialize, Serialize};
10+
11+
pub use super::CreateMultisigError;
12+
13+
/// Result of JSON-RPC method `createmultisig`.
14+
///
15+
/// > createmultisig nrequired ["key",...] ( "address_type" )
16+
/// >
17+
/// > Creates a multi-signature address with n signature of m keys required.
18+
/// > It returns a json object with the address and redeemScript.
19+
/// >
20+
/// > Arguments:
21+
/// > 1. nrequired (numeric, required) The number of required signatures out of the n keys.
22+
/// > 2. "keys" (string, required) A json array of hex-encoded public keys
23+
/// > [
24+
/// > "key" (string) The hex-encoded public key
25+
/// > ,...
26+
/// > ]
27+
#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)]
28+
pub struct CreateMultisig {
29+
/// The value of the new multisig address.
30+
pub address: String,
31+
/// The string value of the hex-encoded redemption script.
32+
#[serde(rename = "redeemScript")]
33+
pub redeem_script: String,
34+
/// The descriptor for this multisig.
35+
pub descriptor: String,
36+
/// Any warnings resulting from the creation of this multisig.
37+
pub warnings: Option<Vec<String>>,
38+
}

0 commit comments

Comments
 (0)