Skip to content

Commit e0f1311

Browse files
committed
Type alias SignRawTransaction
Both `signrawtransactionwithkey` and `signrawtransactionwithwallet` use the type `SignRawTransaction` in types and model. Add aliases for these two RPC methods and a note in the docs explaining why.
1 parent 3565c7f commit e0f1311

File tree

18 files changed

+65
-12
lines changed

18 files changed

+65
-12
lines changed

types/src/model/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ pub use self::{
4444
DecodeScript, DescriptorProcessPsbt, FinalizePsbt, FundRawTransaction, GetRawTransaction,
4545
GetRawTransactionVerbose, JoinPsbts, MempoolAcceptance, MempoolAcceptanceFees,
4646
SendRawTransaction, SignFail, SignRawTransaction, SubmitPackage, SubmitPackageTxResult,
47-
SubmitPackageTxResultFees, TestMempoolAccept, UtxoUpdatePsbt,
47+
SubmitPackageTxResultFees, TestMempoolAccept, UtxoUpdatePsbt, SignRawTransactionWithKey,
4848
},
4949
util::{
5050
CreateMultisig, DeriveAddresses, DeriveAddressesMultipath, EstimateSmartFee,
@@ -62,6 +62,6 @@ pub use self::{
6262
ListUnspent, ListUnspentItem, ListWallets, LoadWallet, PsbtBumpFee, RescanBlockchain,
6363
ScriptType, Send, SendAll, SendMany, SendManyVerbose, SendToAddress, SignMessage,
6464
SimulateRawTransaction, TransactionCategory, TransactionItem, UnloadWallet,
65-
WalletCreateFundedPsbt, WalletDisplayAddress, WalletProcessPsbt,
65+
WalletCreateFundedPsbt, WalletDisplayAddress, WalletProcessPsbt, SignRawTransactionWithWallet,
6666
},
6767
};

types/src/model/raw_transactions.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,12 @@ pub struct SignRawTransaction {
202202
pub errors: Vec<SignFail>,
203203
}
204204

205+
/// Models the result of JSON-RPC method `signrawtransactionwithkey`.
206+
///
207+
/// **Note:** This is a type alias of [`SignRawTransaction`] because the RPC response
208+
/// shape is identical, and our policy is to have a return type for every RPC method.
209+
pub type SignRawTransactionWithKey = SignRawTransaction;
210+
205211
/// A script verification error. Part of `signrawtransaction`.
206212
#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)]
207213
#[serde(deny_unknown_fields)]

types/src/model/wallet.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ use bitcoin::{
1616
};
1717
use serde::{Deserialize, Serialize};
1818

19+
use super::SignRawTransaction;
20+
1921
/// The purpose of an address. Part of `getaddressesbylabel`.
2022
#[derive(Clone, Debug, PartialEq, Eq, Deserialize, Serialize)]
2123
pub enum AddressPurpose {
@@ -828,6 +830,12 @@ pub struct SendToAddress {
828830
#[derive(Clone, Debug, PartialEq, Eq)]
829831
pub struct SignMessage(pub sign_message::MessageSignature);
830832

833+
/// Models the result of JSON-RPC method `signrawtransactionwithwallet`.
834+
///
835+
/// **Note:** This is a type alias of [`SignRawTransaction`] because the RPC response
836+
/// shape is identical, and our policy is to have a return type for every RPC method.
837+
pub type SignRawTransactionWithWallet = SignRawTransaction;
838+
831839
/// Models the result of JSON-RPC method `simulaterawtransaction`.
832840
#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)]
833841
#[serde(deny_unknown_fields)]

types/src/v17/mod.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ pub use self::{
264264
GetRawTransaction, GetRawTransactionVerbose, GetRawTransactionVerboseError,
265265
MempoolAcceptance, PsbtInput, PsbtInputError, PsbtOutput, PsbtOutputError,
266266
SendRawTransaction, SignFail, SignFailError, SignRawTransaction, SignRawTransactionError,
267-
TestMempoolAccept,
267+
TestMempoolAccept, SignRawTransactionWithKey,
268268
},
269269
util::{
270270
CreateMultisig, CreateMultisigError, EstimateSmartFee, SignMessageWithPrivKey,
@@ -285,6 +285,7 @@ pub use self::{
285285
LoadWallet, LockUnspent, RescanBlockchain, ScriptType, SendMany, SendToAddress, SetTxFee,
286286
SignMessage, TransactionCategory, TransactionItem, TransactionItemError,
287287
WalletCreateFundedPsbt, WalletCreateFundedPsbtError, WalletProcessPsbt,
288+
SignRawTransactionWithWallet,
288289
},
289290
zmq::GetZmqNotifications,
290291
};

types/src/v17/raw_transactions/mod.rs

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -396,7 +396,7 @@ pub struct SendRawTransaction(
396396
pub String,
397397
);
398398

399-
/// Result of JSON-RPC method `signrawtransactionwithkey` (and deprecated `signrawtransaction`).
399+
/// Result of JSON-RPC method `signrawtransaction`.
400400
///
401401
/// > signrawtransaction "hexstring" ( [{"txid":"id","vout":n,"scriptPubKey":"hex","redeemScript":"hex"},...] ["privatekey1",...] sighashtype )
402402
/// >
@@ -420,6 +420,24 @@ pub struct SignRawTransaction {
420420
pub errors: Option<Vec<SignFail>>,
421421
}
422422

423+
/// Result of JSON-RPC method `signrawtransactionwithkey`.
424+
///
425+
/// > signrawtransactionwithkey "hexstring" ["privatekey1",...] ( [{"txid":"id","vout":n,"scriptPubKey":"hex","redeemScript":"hex"},...] sighashtype )
426+
/// >
427+
/// > Sign inputs for raw transaction (serialized, hex-encoded).
428+
/// > The second argument is an array of base58-encoded private
429+
/// > keys that will be the only keys used to sign the transaction.
430+
/// > The third optional argument (may be null) is an array of previous transaction outputs that
431+
/// > this transaction depends on but may not yet be in the block chain.
432+
/// >
433+
/// > Arguments:
434+
/// > 1. "hexstring" (string, required) The transaction hex string
435+
/// > 2. "privkeys" (string, required) A json array of base58-encoded private keys for signing
436+
///
437+
/// **Note:** This is a type alias of [`SignRawTransaction`] because the RPC response
438+
/// shape is identical, and our policy is to have a return type for every RPC method.
439+
pub type SignRawTransactionWithKey = SignRawTransaction;
440+
423441
/// A script verification error. Part of `signrawtransaction`.
424442
#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)]
425443
#[serde(deny_unknown_fields)]

types/src/v17/wallet/mod.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ use serde::{Deserialize, Serialize};
1616

1717
// TODO: Remove wildcard, use explicit types.
1818
pub use self::error::*;
19+
use super::SignRawTransaction;
1920

2021
/// Result of JSON-RPC method `abortrescan`.
2122
///
@@ -961,6 +962,21 @@ pub struct SignMessage(
961962
pub String,
962963
);
963964

965+
/// Result of JSON-RPC method `signrawtransactionwithwallet`.
966+
///
967+
/// > signrawtransactionwithwallet "hexstring" ( [{"txid":"id","vout":n,"scriptPubKey":"hex","redeemScript":"hex"},...] sighashtype )
968+
/// >
969+
/// > Sign inputs for raw transaction (serialized, hex-encoded).
970+
/// > The second optional argument (may be null) is an array of previous transaction outputs that
971+
/// > this transaction depends on but may not yet be in the block chain.
972+
/// >
973+
/// > Arguments:
974+
/// > 1. "hexstring" (string, required) The transaction hex string
975+
///
976+
/// **Note:** This is a type alias of [`SignRawTransaction`] because the RPC response
977+
/// shape is identical, and our policy is to have a return type for every RPC method.
978+
pub type SignRawTransactionWithWallet = SignRawTransaction;
979+
964980
/// Result of the JSON-RPC method `walletcreatefundedpsbt`.
965981
///
966982
/// > walletcreatefundedpsbt [{"txid":"id","vout":n},...] [{"address":amount},{"data":"hex"},...] ( locktime ) ( replaceable ) ( options bip32derivs )

types/src/v18/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -285,4 +285,5 @@ pub use crate::v17::{
285285
TransactionItem, TransactionItemError, UploadTarget, ValidateAddress, ValidateAddressError,
286286
VerifyChain, VerifyMessage, VerifyTxOutProof, WalletCreateFundedPsbt,
287287
WalletCreateFundedPsbtError, WalletProcessPsbt, WitnessUtxo,
288+
SignRawTransactionWithKey, SignRawTransactionWithWallet,
288289
};

types/src/v19/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,7 @@ pub use crate::v17::{
279279
TestMempoolAccept, TransactionCategory, TransactionItem, TransactionItemError, UploadTarget,
280280
ValidateAddress, ValidateAddressError, VerifyChain, VerifyMessage, VerifyTxOutProof,
281281
WalletCreateFundedPsbt, WalletCreateFundedPsbtError, WalletProcessPsbt, WitnessUtxo,
282+
SignRawTransactionWithKey, SignRawTransactionWithWallet,
282283
};
283284
#[doc(inline)]
284285
pub use crate::v18::{

types/src/v20/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ pub use crate::{
273273
SignRawTransactionError, SoftforkReject, TestMempoolAccept, TransactionCategory,
274274
UploadTarget, ValidateAddress, ValidateAddressError, VerifyChain, VerifyMessage,
275275
VerifyTxOutProof, WalletCreateFundedPsbt, WalletCreateFundedPsbtError, WalletProcessPsbt,
276-
WitnessUtxo,
276+
WitnessUtxo, SignRawTransactionWithKey, SignRawTransactionWithWallet,
277277
},
278278
v18::{
279279
ActiveCommand, AnalyzePsbt, AnalyzePsbtError, AnalyzePsbtInput, AnalyzePsbtInputMissing,

types/src/v21/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,7 @@ pub use crate::{
289289
SoftforkReject, TransactionCategory, UploadTarget, ValidateAddress, ValidateAddressError,
290290
VerifyChain, VerifyMessage, VerifyTxOutProof, WalletCreateFundedPsbt,
291291
WalletCreateFundedPsbtError, WalletProcessPsbt, WitnessUtxo,
292+
SignRawTransactionWithKey, SignRawTransactionWithWallet,
292293
},
293294
v18::{
294295
ActiveCommand, AnalyzePsbt, AnalyzePsbtError, AnalyzePsbtInput, AnalyzePsbtInputMissing,

0 commit comments

Comments
 (0)