Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion client/src/client_sync/v17/raw_transactions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ macro_rules! impl_client_v17__sign_raw_transaction_with_key {
&self,
tx: &bitcoin::Transaction,
keys: &[bitcoin::PrivateKey],
) -> Result<SignRawTransaction> {
) -> Result<SignRawTransactionWithKey> {
let hex = bitcoin::consensus::encode::serialize_hex(tx);
let keys = keys.iter().map(|k| format!("{}", k)).collect::<Vec<String>>();
self.call("signrawtransactionwithkey", &[hex.into(), into_json(keys)?])
Expand Down
2 changes: 1 addition & 1 deletion client/src/client_sync/v17/wallet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -660,7 +660,7 @@ macro_rules! impl_client_v17__sign_raw_transaction_with_wallet {
pub fn sign_raw_transaction_with_wallet(
&self,
tx: &bitcoin::Transaction,
) -> Result<SignRawTransaction> {
) -> Result<SignRawTransactionWithWallet> {
let hex = bitcoin::consensus::encode::serialize_hex(tx);
self.call("signrawtransactionwithwallet", &[into_json(hex)?])
}
Expand Down
19 changes: 11 additions & 8 deletions integration_test/tests/raw_transactions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -399,9 +399,9 @@ fn raw_transactions__test_mempool_accept__modelled() {
let tx = create_a_raw_transaction(&node);

// Sign (but don't broadcast).
let signed: SignRawTransaction =
let signed: SignRawTransactionWithWallet =
node.client.sign_raw_transaction_with_wallet(&tx).expect("signrawtransactionwithwallet");
let signed_model: mtype::SignRawTransaction =
let signed_model: mtype::SignRawTransactionWithWallet =
signed.into_model().expect("SignRawTransaction into model");
let signed_tx = signed_model.tx;

Expand Down Expand Up @@ -474,10 +474,11 @@ fn create_sign_send(node: &Node) {

// wallet.rs expects this call to exist, if you change it then you'll need to update the test
// `wallet__sign_raw_transaction_with_wallet__modelled`.
let json: SignRawTransaction =
let json: SignRawTransactionWithWallet =
node.client.sign_raw_transaction_with_wallet(&tx).expect("signrawtransactionwithwallet");

let model: Result<mtype::SignRawTransaction, SignRawTransactionError> = json.into_model();
let model: Result<mtype::SignRawTransactionWithWallet, SignRawTransactionError> =
json.into_model();
let sign_raw_transaction = model.unwrap();

// The proves we did everything correctly.
Expand Down Expand Up @@ -533,9 +534,10 @@ fn create_sign_with_key_send(node: &Node) {
let model: mtype::DumpPrivKey = json.into_model().expect("DumpPrivKey");
let key = model.0;

let json: SignRawTransaction =
let json: SignRawTransactionWithKey =
node.client.sign_raw_transaction_with_key(&tx, &[key]).expect("signrawtransactionwithkey");
let model: Result<mtype::SignRawTransaction, SignRawTransactionError> = json.into_model();
let model: Result<mtype::SignRawTransactionWithKey, SignRawTransactionError> =
json.into_model();
let sign_raw_transaction = model.unwrap();

// The proves we did everything correctly.
Expand Down Expand Up @@ -580,12 +582,13 @@ fn create_fund_sign_send(node: &Node) {
let funded = json.transaction().unwrap();

// This method is from the wallet section.
let json: SignRawTransaction = node
let json: SignRawTransactionWithWallet = node
.client
.sign_raw_transaction_with_wallet(&funded)
.expect("signrawtransactionwithwallet");
// This proves we did everything correctly.
let model: Result<mtype::SignRawTransaction, SignRawTransactionError> = json.into_model();
let model: Result<mtype::SignRawTransactionWithWallet, SignRawTransactionError> =
json.into_model();
let sign_raw_transaction = model.unwrap();
let _ =
node.client.send_raw_transaction(&sign_raw_transaction.tx).expect("createrawtransaction");
Expand Down
8 changes: 4 additions & 4 deletions types/src/model/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ pub use self::{
ConvertToPsbt, CreatePsbt, CreateRawTransaction, DecodePsbt, DecodeRawTransaction,
DecodeScript, DescriptorProcessPsbt, FinalizePsbt, FundRawTransaction, GetRawTransaction,
GetRawTransactionVerbose, JoinPsbts, MempoolAcceptance, MempoolAcceptanceFees,
SendRawTransaction, SignFail, SignRawTransaction, SubmitPackage, SubmitPackageTxResult,
SubmitPackageTxResultFees, TestMempoolAccept, UtxoUpdatePsbt,
SendRawTransaction, SignFail, SignRawTransaction, SignRawTransactionWithKey, SubmitPackage,
SubmitPackageTxResult, SubmitPackageTxResultFees, TestMempoolAccept, UtxoUpdatePsbt,
},
util::{
CreateMultisig, DeriveAddresses, DeriveAddressesMultipath, EstimateSmartFee,
Expand All @@ -61,7 +61,7 @@ pub use self::{
ListReceivedByLabel, ListReceivedByLabelItem, ListSinceBlock, ListTransactions,
ListUnspent, ListUnspentItem, ListWallets, LoadWallet, PsbtBumpFee, RescanBlockchain,
ScriptType, Send, SendAll, SendMany, SendManyVerbose, SendToAddress, SignMessage,
SimulateRawTransaction, TransactionCategory, TransactionItem, UnloadWallet,
WalletCreateFundedPsbt, WalletDisplayAddress, WalletProcessPsbt,
SignRawTransactionWithWallet, SimulateRawTransaction, TransactionCategory, TransactionItem,
UnloadWallet, WalletCreateFundedPsbt, WalletDisplayAddress, WalletProcessPsbt,
},
};
6 changes: 6 additions & 0 deletions types/src/model/raw_transactions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,12 @@ pub struct SignRawTransaction {
pub errors: Vec<SignFail>,
}

/// Models the result of JSON-RPC method `signrawtransactionwithkey`.
///
/// **Note:** This is a type alias of [`SignRawTransaction`] because the RPC response
/// shape is identical, and our policy is to have a return type for every RPC method.
pub type SignRawTransactionWithKey = SignRawTransaction;

/// A script verification error. Part of `signrawtransaction`.
#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)]
#[serde(deny_unknown_fields)]
Expand Down
8 changes: 8 additions & 0 deletions types/src/model/wallet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ use bitcoin::{
};
use serde::{Deserialize, Serialize};

use super::SignRawTransaction;

/// The purpose of an address. Part of `getaddressesbylabel`.
#[derive(Clone, Debug, PartialEq, Eq, Deserialize, Serialize)]
pub enum AddressPurpose {
Expand Down Expand Up @@ -828,6 +830,12 @@ pub struct SendToAddress {
#[derive(Clone, Debug, PartialEq, Eq)]
pub struct SignMessage(pub sign_message::MessageSignature);

/// Models the result of JSON-RPC method `signrawtransactionwithwallet`.
///
/// **Note:** This is a type alias of [`SignRawTransaction`] because the RPC response
/// shape is identical, and our policy is to have a return type for every RPC method.
pub type SignRawTransactionWithWallet = SignRawTransaction;

/// Models the result of JSON-RPC method `simulaterawtransaction`.
#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)]
#[serde(deny_unknown_fields)]
Expand Down
7 changes: 4 additions & 3 deletions types/src/v17/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ pub use self::{
GetRawTransaction, GetRawTransactionVerbose, GetRawTransactionVerboseError,
MempoolAcceptance, PsbtInput, PsbtInputError, PsbtOutput, PsbtOutputError,
SendRawTransaction, SignFail, SignFailError, SignRawTransaction, SignRawTransactionError,
TestMempoolAccept,
SignRawTransactionWithKey, TestMempoolAccept,
},
util::{
CreateMultisig, CreateMultisigError, EstimateSmartFee, SignMessageWithPrivKey,
Expand All @@ -283,8 +283,9 @@ pub use self::{
ListReceivedByAddressError, ListReceivedByAddressItem, ListSinceBlock, ListSinceBlockError,
ListTransactions, ListUnspent, ListUnspentItem, ListUnspentItemError, ListWallets,
LoadWallet, LockUnspent, RescanBlockchain, ScriptType, SendMany, SendToAddress, SetTxFee,
SignMessage, TransactionCategory, TransactionItem, TransactionItemError,
WalletCreateFundedPsbt, WalletCreateFundedPsbtError, WalletProcessPsbt,
SignMessage, SignRawTransactionWithWallet, TransactionCategory, TransactionItem,
TransactionItemError, WalletCreateFundedPsbt, WalletCreateFundedPsbtError,
WalletProcessPsbt,
},
zmq::GetZmqNotifications,
};
Expand Down
20 changes: 19 additions & 1 deletion types/src/v17/raw_transactions/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,7 @@ pub struct SendRawTransaction(
pub String,
);

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

/// Result of JSON-RPC method `signrawtransactionwithkey`.
///
/// > signrawtransactionwithkey "hexstring" ["privatekey1",...] ( [{"txid":"id","vout":n,"scriptPubKey":"hex","redeemScript":"hex"},...] sighashtype )
/// >
/// > Sign inputs for raw transaction (serialized, hex-encoded).
/// > The second argument is an array of base58-encoded private
/// > keys that will be the only keys used to sign the transaction.
/// > The third optional argument (may be null) is an array of previous transaction outputs that
/// > this transaction depends on but may not yet be in the block chain.
/// >
/// > Arguments:
/// > 1. "hexstring" (string, required) The transaction hex string
/// > 2. "privkeys" (string, required) A json array of base58-encoded private keys for signing
///
/// **Note:** This is a type alias of [`SignRawTransaction`] because the RPC response
/// shape is identical, and our policy is to have a return type for every RPC method.
pub type SignRawTransactionWithKey = SignRawTransaction;

/// A script verification error. Part of `signrawtransaction`.
#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)]
#[serde(deny_unknown_fields)]
Expand Down
16 changes: 16 additions & 0 deletions types/src/v17/wallet/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ use serde::{Deserialize, Serialize};

// TODO: Remove wildcard, use explicit types.
pub use self::error::*;
use super::SignRawTransaction;

/// Result of JSON-RPC method `abortrescan`.
///
Expand Down Expand Up @@ -961,6 +962,21 @@ pub struct SignMessage(
pub String,
);

/// Result of JSON-RPC method `signrawtransactionwithwallet`.
///
/// > signrawtransactionwithwallet "hexstring" ( [{"txid":"id","vout":n,"scriptPubKey":"hex","redeemScript":"hex"},...] sighashtype )
/// >
/// > Sign inputs for raw transaction (serialized, hex-encoded).
/// > The second optional argument (may be null) is an array of previous transaction outputs that
/// > this transaction depends on but may not yet be in the block chain.
/// >
/// > Arguments:
/// > 1. "hexstring" (string, required) The transaction hex string
///
/// **Note:** This is a type alias of [`SignRawTransaction`] because the RPC response
/// shape is identical, and our policy is to have a return type for every RPC method.
pub type SignRawTransactionWithWallet = SignRawTransaction;

/// Result of the JSON-RPC method `walletcreatefundedpsbt`.
///
/// > walletcreatefundedpsbt [{"txid":"id","vout":n},...] [{"address":amount},{"data":"hex"},...] ( locktime ) ( replaceable ) ( options bip32derivs )
Expand Down
9 changes: 5 additions & 4 deletions types/src/v18/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -281,8 +281,9 @@ pub use crate::v17::{
PsbtScript, RawTransaction, RawTransactionError, RawTransactionInput, RawTransactionOutput,
RescanBlockchain, ScriptType, SendMany, SendRawTransaction, SendToAddress, SetNetworkActive,
SetTxFee, SignFail, SignFailError, SignMessage, SignMessageWithPrivKey, SignRawTransaction,
SignRawTransactionError, Softfork, SoftforkReject, TestMempoolAccept, TransactionCategory,
TransactionItem, TransactionItemError, UploadTarget, ValidateAddress, ValidateAddressError,
VerifyChain, VerifyMessage, VerifyTxOutProof, WalletCreateFundedPsbt,
WalletCreateFundedPsbtError, WalletProcessPsbt, WitnessUtxo,
SignRawTransactionError, SignRawTransactionWithKey, SignRawTransactionWithWallet, Softfork,
SoftforkReject, TestMempoolAccept, TransactionCategory, TransactionItem, TransactionItemError,
UploadTarget, ValidateAddress, ValidateAddressError, VerifyChain, VerifyMessage,
VerifyTxOutProof, WalletCreateFundedPsbt, WalletCreateFundedPsbtError, WalletProcessPsbt,
WitnessUtxo,
};
9 changes: 5 additions & 4 deletions types/src/v19/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -275,10 +275,11 @@ pub use crate::v17::{
LockUnspent, Locked, Logging, NumericError, PruneBlockchain, RawTransactionError,
RawTransactionInput, RawTransactionOutput, RescanBlockchain, ScriptType, SendMany,
SendRawTransaction, SendToAddress, SetNetworkActive, SetTxFee, SignMessage,
SignMessageWithPrivKey, SignRawTransaction, SignRawTransactionError, SoftforkReject,
TestMempoolAccept, TransactionCategory, TransactionItem, TransactionItemError, UploadTarget,
ValidateAddress, ValidateAddressError, VerifyChain, VerifyMessage, VerifyTxOutProof,
WalletCreateFundedPsbt, WalletCreateFundedPsbtError, WalletProcessPsbt, WitnessUtxo,
SignMessageWithPrivKey, SignRawTransaction, SignRawTransactionError, SignRawTransactionWithKey,
SignRawTransactionWithWallet, SoftforkReject, TestMempoolAccept, TransactionCategory,
TransactionItem, TransactionItemError, UploadTarget, ValidateAddress, ValidateAddressError,
VerifyChain, VerifyMessage, VerifyTxOutProof, WalletCreateFundedPsbt,
WalletCreateFundedPsbtError, WalletProcessPsbt, WitnessUtxo,
};
#[doc(inline)]
pub use crate::v18::{
Expand Down
8 changes: 4 additions & 4 deletions types/src/v20/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -270,10 +270,10 @@ pub use crate::{
PruneBlockchain, RawTransactionError, RawTransactionInput, RawTransactionOutput,
RescanBlockchain, ScriptType, SendMany, SendRawTransaction, SendToAddress,
SetNetworkActive, SetTxFee, SignMessage, SignMessageWithPrivKey, SignRawTransaction,
SignRawTransactionError, SoftforkReject, TestMempoolAccept, TransactionCategory,
UploadTarget, ValidateAddress, ValidateAddressError, VerifyChain, VerifyMessage,
VerifyTxOutProof, WalletCreateFundedPsbt, WalletCreateFundedPsbtError, WalletProcessPsbt,
WitnessUtxo,
SignRawTransactionError, SignRawTransactionWithKey, SignRawTransactionWithWallet,
SoftforkReject, TestMempoolAccept, TransactionCategory, UploadTarget, ValidateAddress,
ValidateAddressError, VerifyChain, VerifyMessage, VerifyTxOutProof, WalletCreateFundedPsbt,
WalletCreateFundedPsbtError, WalletProcessPsbt, WitnessUtxo,
},
v18::{
ActiveCommand, AnalyzePsbt, AnalyzePsbtError, AnalyzePsbtInput, AnalyzePsbtInputMissing,
Expand Down
7 changes: 4 additions & 3 deletions types/src/v21/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -286,9 +286,10 @@ pub use crate::{
PruneBlockchain, RawTransactionError, RawTransactionInput, RawTransactionOutput,
RescanBlockchain, ScriptType, SendRawTransaction, SendToAddress, SetNetworkActive,
SetTxFee, SignMessage, SignMessageWithPrivKey, SignRawTransaction, SignRawTransactionError,
SoftforkReject, TransactionCategory, UploadTarget, ValidateAddress, ValidateAddressError,
VerifyChain, VerifyMessage, VerifyTxOutProof, WalletCreateFundedPsbt,
WalletCreateFundedPsbtError, WalletProcessPsbt, WitnessUtxo,
SignRawTransactionWithKey, SignRawTransactionWithWallet, SoftforkReject,
TransactionCategory, UploadTarget, ValidateAddress, ValidateAddressError, VerifyChain,
VerifyMessage, VerifyTxOutProof, WalletCreateFundedPsbt, WalletCreateFundedPsbtError,
WalletProcessPsbt, WitnessUtxo,
},
v18::{
ActiveCommand, AnalyzePsbt, AnalyzePsbtError, AnalyzePsbtInput, AnalyzePsbtInputMissing,
Expand Down
3 changes: 2 additions & 1 deletion types/src/v22/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,8 @@ pub use crate::{
LoadWallet, LockUnspent, Locked, NumericError, PruneBlockchain, RawTransactionError,
RawTransactionInput, RawTransactionOutput, RescanBlockchain, ScriptType,
SendRawTransaction, SendToAddress, SetNetworkActive, SetTxFee, SignMessage,
SignMessageWithPrivKey, SignRawTransaction, SignRawTransactionError, SoftforkReject,
SignMessageWithPrivKey, SignRawTransaction, SignRawTransactionError,
SignRawTransactionWithKey, SignRawTransactionWithWallet, SoftforkReject,
TransactionCategory, UploadTarget, ValidateAddress, ValidateAddressError, VerifyChain,
VerifyMessage, VerifyTxOutProof, WalletCreateFundedPsbt, WalletCreateFundedPsbtError,
WalletProcessPsbt, WitnessUtxo,
Expand Down
3 changes: 2 additions & 1 deletion types/src/v23/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,8 @@ pub use crate::{
LoadWallet, LockUnspent, Locked, NumericError, PruneBlockchain, RawTransactionError,
RawTransactionInput, RawTransactionOutput, RescanBlockchain, ScriptType,
SendRawTransaction, SendToAddress, SetNetworkActive, SetTxFee, SignMessage,
SignMessageWithPrivKey, SignRawTransaction, SignRawTransactionError, SoftforkReject,
SignMessageWithPrivKey, SignRawTransaction, SignRawTransactionError,
SignRawTransactionWithKey, SignRawTransactionWithWallet, SoftforkReject,
TransactionCategory, UploadTarget, ValidateAddress, ValidateAddressError, VerifyChain,
VerifyMessage, VerifyTxOutProof, WalletCreateFundedPsbt, WalletCreateFundedPsbtError,
WalletProcessPsbt, WitnessUtxo,
Expand Down
3 changes: 2 additions & 1 deletion types/src/v24/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,8 @@ pub use crate::{
LoadWallet, LockUnspent, Locked, NumericError, PruneBlockchain, RawTransactionError,
RawTransactionInput, RawTransactionOutput, RescanBlockchain, ScriptType,
SendRawTransaction, SendToAddress, SetNetworkActive, SetTxFee, SignMessage,
SignMessageWithPrivKey, SignRawTransaction, SignRawTransactionError, SoftforkReject,
SignMessageWithPrivKey, SignRawTransaction, SignRawTransactionError,
SignRawTransactionWithKey, SignRawTransactionWithWallet, SoftforkReject,
TransactionCategory, UploadTarget, ValidateAddress, ValidateAddressError, VerifyChain,
VerifyMessage, VerifyTxOutProof, WalletCreateFundedPsbt, WalletCreateFundedPsbtError,
WalletProcessPsbt, WitnessUtxo,
Expand Down
3 changes: 2 additions & 1 deletion types/src/v25/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,8 @@ pub use crate::{
LockUnspent, Locked, NumericError, PruneBlockchain, RawTransactionError,
RawTransactionInput, RawTransactionOutput, RescanBlockchain, ScriptType,
SendRawTransaction, SendToAddress, SetNetworkActive, SetTxFee, SignMessage,
SignMessageWithPrivKey, SignRawTransaction, SignRawTransactionError, SoftforkReject,
SignMessageWithPrivKey, SignRawTransaction, SignRawTransactionError,
SignRawTransactionWithKey, SignRawTransactionWithWallet, SoftforkReject,
TransactionCategory, UploadTarget, ValidateAddress, ValidateAddressError, VerifyChain,
VerifyMessage, VerifyTxOutProof, WalletCreateFundedPsbt, WalletCreateFundedPsbtError,
WalletProcessPsbt, WitnessUtxo,
Expand Down
3 changes: 2 additions & 1 deletion types/src/v26/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,8 @@ pub use crate::{
LockUnspent, Locked, NumericError, PruneBlockchain, RawTransactionError,
RawTransactionInput, RawTransactionOutput, RescanBlockchain, ScriptType,
SendRawTransaction, SendToAddress, SetNetworkActive, SetTxFee, SignMessage,
SignMessageWithPrivKey, SignRawTransaction, SignRawTransactionError, SoftforkReject,
SignMessageWithPrivKey, SignRawTransaction, SignRawTransactionError,
SignRawTransactionWithKey, SignRawTransactionWithWallet, SoftforkReject,
TransactionCategory, UploadTarget, ValidateAddress, ValidateAddressError, VerifyChain,
VerifyMessage, VerifyTxOutProof, WalletCreateFundedPsbt, WalletCreateFundedPsbtError,
WitnessUtxo,
Expand Down
3 changes: 2 additions & 1 deletion types/src/v27/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,8 @@ pub use crate::{
LockUnspent, Locked, NumericError, PruneBlockchain, RawTransactionError,
RawTransactionInput, RawTransactionOutput, RescanBlockchain, ScriptType,
SendRawTransaction, SendToAddress, SetNetworkActive, SetTxFee, SignMessage,
SignMessageWithPrivKey, SignRawTransaction, SignRawTransactionError, SoftforkReject,
SignMessageWithPrivKey, SignRawTransaction, SignRawTransactionError,
SignRawTransactionWithKey, SignRawTransactionWithWallet, SoftforkReject,
TransactionCategory, UploadTarget, ValidateAddress, ValidateAddressError, VerifyChain,
VerifyMessage, VerifyTxOutProof, WalletCreateFundedPsbt, WalletCreateFundedPsbtError,
WitnessUtxo,
Expand Down
Loading