diff --git a/types/src/v18/mod.rs b/types/src/v18/mod.rs index 9177f138..74d24acf 100644 --- a/types/src/v18/mod.rs +++ b/types/src/v18/mod.rs @@ -256,36 +256,37 @@ pub use self::{ #[doc(inline)] pub use crate::v17::{ AbortRescan, AddMultisigAddress, AddMultisigAddressError, AddedNode, AddedNodeAddress, - AddressInformation, Banned, Bip32Deriv, Bip9Softfork, Bip9SoftforkStatus, BumpFee, - BumpFeeError, ChainTips, ChainTipsError, ChainTipsStatus, CombinePsbt, CombineRawTransaction, - ConvertToPsbt, CreateMultisig, CreateMultisigError, CreatePsbt, CreateRawTransaction, - CreateWallet, DecodePsbt, DecodePsbtError, DecodeRawTransaction, DecodeScript, - DecodeScriptError, DumpPrivKey, DumpWallet, EncryptWallet, EstimateSmartFee, FinalizePsbt, - FinalizePsbtError, FundRawTransaction, FundRawTransactionError, Generate, GenerateToAddress, - GetAddedNodeInfo, GetAddressInfoEmbeddedError, GetAddressInfoLabel, GetAddressesByLabel, - GetBalance, GetBestBlockHash, GetBlockCount, GetBlockHash, GetBlockHeader, GetBlockHeaderError, - GetBlockHeaderVerbose, GetBlockHeaderVerboseError, GetBlockStats, GetBlockStatsError, - GetBlockTemplate, GetBlockTemplateError, GetBlockVerboseOne, GetBlockVerboseOneError, - GetBlockVerboseZero, GetBlockchainInfo, GetBlockchainInfoError, GetChainTips, GetChainTxStats, - GetChainTxStatsError, GetConnectionCount, GetDifficulty, GetMemoryInfoStats, GetMempoolInfo, - GetMempoolInfoError, GetMiningInfo, GetNetTotals, GetNetworkInfo, GetNetworkInfoAddress, - GetNetworkInfoError, GetNetworkInfoNetwork, GetNewAddress, GetRawChangeAddress, - GetRawTransaction, GetRawTransactionVerbose, GetRawTransactionVerboseError, - GetReceivedByAddress, GetTransaction, GetTransactionDetail, GetTransactionDetailError, - GetTransactionError, GetTxOut, GetTxOutError, GetTxOutSetInfo, GetTxOutSetInfoError, - GetUnconfirmedBalance, GetWalletInfoError, ListAddressGroupings, ListAddressGroupingsError, - ListAddressGroupingsItem, ListBanned, ListLabels, ListLockUnspent, ListLockUnspentItem, - ListLockUnspentItemError, ListReceivedByAddressError, ListSinceBlock, ListSinceBlockError, - ListTransactions, ListUnspentItemError, ListWallets, LoadWallet, LockUnspent, Locked, Logging, - MapMempoolEntryError, MempoolAcceptance, MempoolEntryError, MempoolEntryFees, - MempoolEntryFeesError, NumericError, PruneBlockchain, PsbtInput, PsbtOutput, PsbtScript, - RawTransaction, RawTransactionError, RawTransactionInput, RawTransactionOutput, - RescanBlockchain, ScriptType, SendMany, SendRawTransaction, SendToAddress, SetNetworkActive, - SetTxFee, SignFail, SignFailError, SignMessage, SignMessageWithPrivKey, SignRawTransaction, - SignRawTransactionError, SignRawTransactionWithKey, SignRawTransactionWithWallet, Softfork, - SoftforkReject, TestMempoolAccept, TransactionCategory, TransactionItem, TransactionItemError, - UploadTarget, ValidateAddress, ValidateAddressError, VerifyChain, VerifyMessage, - VerifyTxOutProof, WaitForBlock, WaitForBlockError, WaitForBlockHeight, WaitForBlockHeightError, - WaitForNewBlock, WaitForNewBlockError, WalletCreateFundedPsbt, WalletCreateFundedPsbtError, - WalletProcessPsbt, WitnessUtxo, + AddressInformation, Banned, Bip32Deriv, Bip32DerivError, Bip9Softfork, Bip9SoftforkStatus, + BumpFee, BumpFeeError, ChainTips, ChainTipsError, ChainTipsStatus, CombinePsbt, + CombineRawTransaction, ConvertToPsbt, CreateMultisig, CreateMultisigError, CreatePsbt, + CreateRawTransaction, CreateWallet, DecodePsbt, DecodePsbtError, DecodeRawTransaction, + DecodeScript, DecodeScriptError, DumpPrivKey, DumpWallet, EncryptWallet, EstimateSmartFee, + FinalizePsbt, FinalizePsbtError, FundRawTransaction, FundRawTransactionError, Generate, + GenerateToAddress, GetAddedNodeInfo, GetAddressInfoEmbeddedError, GetAddressInfoLabel, + GetAddressesByLabel, GetBalance, GetBestBlockHash, GetBlockCount, GetBlockHash, GetBlockHeader, + GetBlockHeaderError, GetBlockHeaderVerbose, GetBlockHeaderVerboseError, GetBlockStats, + GetBlockStatsError, GetBlockTemplate, GetBlockTemplateError, GetBlockVerboseOne, + GetBlockVerboseOneError, GetBlockVerboseZero, GetBlockchainInfo, GetBlockchainInfoError, + GetChainTips, GetChainTxStats, GetChainTxStatsError, GetConnectionCount, GetDifficulty, + GetMemoryInfoStats, GetMempoolInfo, GetMempoolInfoError, GetMiningInfo, GetNetTotals, + GetNetworkInfo, GetNetworkInfoAddress, GetNetworkInfoError, GetNetworkInfoNetwork, + GetNewAddress, GetRawChangeAddress, GetRawTransaction, GetRawTransactionVerbose, + GetRawTransactionVerboseError, GetReceivedByAddress, GetTransaction, GetTransactionDetail, + GetTransactionDetailError, GetTransactionError, GetTxOut, GetTxOutError, GetTxOutSetInfo, + GetTxOutSetInfoError, GetUnconfirmedBalance, GetWalletInfoError, ListAddressGroupings, + ListAddressGroupingsError, ListAddressGroupingsItem, ListBanned, ListLabels, ListLockUnspent, + ListLockUnspentItem, ListLockUnspentItemError, ListReceivedByAddressError, ListSinceBlock, + ListSinceBlockError, ListTransactions, ListUnspentItemError, ListWallets, LoadWallet, + LockUnspent, Locked, Logging, MapMempoolEntryError, MempoolAcceptance, MempoolEntryError, + MempoolEntryFees, MempoolEntryFeesError, NumericError, PartialSignatureError, PruneBlockchain, + PsbtInput, PsbtOutput, PsbtScript, RawTransaction, RawTransactionError, RawTransactionInput, + RawTransactionOutput, RescanBlockchain, ScriptType, SendMany, SendRawTransaction, + SendToAddress, SetNetworkActive, SetTxFee, SignFail, SignFailError, SignMessage, + SignMessageWithPrivKey, SignRawTransaction, SignRawTransactionError, SignRawTransactionWithKey, + SignRawTransactionWithWallet, Softfork, SoftforkReject, TestMempoolAccept, TransactionCategory, + TransactionItem, TransactionItemError, UploadTarget, ValidateAddress, ValidateAddressError, + VerifyChain, VerifyMessage, VerifyTxOutProof, WaitForBlock, WaitForBlockError, + WaitForBlockHeight, WaitForBlockHeightError, WaitForNewBlock, WaitForNewBlockError, + WalletCreateFundedPsbt, WalletCreateFundedPsbtError, WalletProcessPsbt, WitnessUtxo, + WitnessUtxoError, }; diff --git a/types/src/v19/mod.rs b/types/src/v19/mod.rs index 26378399..213b75ce 100644 --- a/types/src/v19/mod.rs +++ b/types/src/v19/mod.rs @@ -252,8 +252,8 @@ pub use self::{ #[doc(inline)] pub use crate::v17::{ AbortRescan, AddMultisigAddress, AddMultisigAddressError, AddedNode, AddedNodeAddress, - AddressInformation, Banned, Bip125Replaceable, BumpFee, BumpFeeError, ChainTips, - ChainTipsError, ChainTipsStatus, CombinePsbt, CombineRawTransaction, ConvertToPsbt, + AddressInformation, Banned, Bip125Replaceable, Bip32DerivError, BumpFee, BumpFeeError, + ChainTips, ChainTipsError, ChainTipsStatus, CombinePsbt, CombineRawTransaction, ConvertToPsbt, CreateMultisig, CreateMultisigError, CreatePsbt, CreateRawTransaction, CreateWallet, DecodePsbt, DecodePsbtError, DecodeRawTransaction, DecodeScript, DecodeScriptError, DumpPrivKey, DumpWallet, EncryptWallet, EstimateSmartFee, FinalizePsbt, FinalizePsbtError, @@ -272,15 +272,16 @@ pub use crate::v17::{ ListBanned, ListLabels, ListLockUnspent, ListLockUnspentItem, ListLockUnspentItemError, ListReceivedByAddressError, ListSinceBlock, ListSinceBlockError, ListTransactions, ListUnspentItemError, ListWallets, LoadWallet, LockUnspent, Locked, Logging, NumericError, - PruneBlockchain, RawTransactionError, RawTransactionInput, RawTransactionOutput, - RescanBlockchain, ScriptType, SendMany, SendRawTransaction, SendToAddress, SetNetworkActive, - SetTxFee, SignMessage, SignMessageWithPrivKey, SignRawTransaction, SignRawTransactionError, - SignRawTransactionWithKey, SignRawTransactionWithWallet, SoftforkReject, TestMempoolAccept, - TransactionCategory, TransactionItem, TransactionItemError, UploadTarget, ValidateAddress, - ValidateAddressError, VerifyChain, VerifyMessage, VerifyTxOutProof, WaitForBlock, - WaitForBlockError, WaitForBlockHeight, WaitForBlockHeightError, WaitForNewBlock, - WaitForNewBlockError, WalletCreateFundedPsbt, WalletCreateFundedPsbtError, WalletProcessPsbt, - WitnessUtxo, + PartialSignatureError, PruneBlockchain, RawTransactionError, RawTransactionInput, + RawTransactionOutput, RescanBlockchain, ScriptType, SendMany, SendRawTransaction, + SendToAddress, SetNetworkActive, SetTxFee, SignMessage, SignMessageWithPrivKey, + SignRawTransaction, SignRawTransactionError, SignRawTransactionWithKey, + SignRawTransactionWithWallet, SoftforkReject, TestMempoolAccept, TransactionCategory, + TransactionItem, TransactionItemError, UploadTarget, ValidateAddress, ValidateAddressError, + VerifyChain, VerifyMessage, VerifyTxOutProof, WaitForBlock, WaitForBlockError, + WaitForBlockHeight, WaitForBlockHeightError, WaitForNewBlock, WaitForNewBlockError, + WalletCreateFundedPsbt, WalletCreateFundedPsbtError, WalletProcessPsbt, WitnessUtxo, + WitnessUtxoError, }; #[doc(inline)] pub use crate::v18::{ diff --git a/types/src/v20/mod.rs b/types/src/v20/mod.rs index 137ce467..bf9a684b 100644 --- a/types/src/v20/mod.rs +++ b/types/src/v20/mod.rs @@ -248,33 +248,34 @@ pub use self::{ pub use crate::{ v17::{ AbortRescan, AddMultisigAddressError, AddedNode, AddedNodeAddress, AddressInformation, - Bip125Replaceable, BumpFee, BumpFeeError, ChainTips, ChainTipsError, ChainTipsStatus, - CombinePsbt, CombineRawTransaction, ConvertToPsbt, CreateMultisigError, CreatePsbt, - CreateRawTransaction, CreateWallet, DecodePsbt, DecodePsbtError, DecodeRawTransaction, - DecodeScript, DecodeScriptError, DumpPrivKey, DumpWallet, EncryptWallet, EstimateSmartFee, - FinalizePsbt, FinalizePsbtError, FundRawTransaction, FundRawTransactionError, Generate, - GenerateToAddress, GetAddedNodeInfo, GetAddressInfoEmbeddedError, GetAddressesByLabel, - GetBalance, GetBestBlockHash, GetBlockCount, GetBlockHash, GetBlockHeader, - GetBlockHeaderError, GetBlockHeaderVerbose, GetBlockHeaderVerboseError, GetBlockStats, - GetBlockStatsError, GetBlockTemplate, GetBlockTemplateError, GetBlockVerboseOne, - GetBlockVerboseOneError, GetBlockVerboseZero, GetChainTips, GetChainTxStatsError, - GetConnectionCount, GetDifficulty, GetMemoryInfoStats, GetMempoolInfoError, GetMiningInfo, - GetNetTotals, GetNetworkInfoAddress, GetNetworkInfoError, GetNetworkInfoNetwork, - GetNewAddress, GetRawChangeAddress, GetRawTransaction, GetRawTransactionVerbose, - GetRawTransactionVerboseError, GetReceivedByAddress, GetTransactionDetailError, - GetTransactionError, GetTxOut, GetTxOutError, GetTxOutSetInfo, GetTxOutSetInfoError, - GetUnconfirmedBalance, GetWalletInfoError, ListAddressGroupings, ListAddressGroupingsError, + Bip125Replaceable, Bip32DerivError, BumpFee, BumpFeeError, ChainTips, ChainTipsError, + ChainTipsStatus, CombinePsbt, CombineRawTransaction, ConvertToPsbt, CreateMultisigError, + CreatePsbt, CreateRawTransaction, CreateWallet, DecodePsbt, DecodePsbtError, + DecodeRawTransaction, DecodeScript, DecodeScriptError, DumpPrivKey, DumpWallet, + EncryptWallet, EstimateSmartFee, FinalizePsbt, FinalizePsbtError, FundRawTransaction, + FundRawTransactionError, Generate, GenerateToAddress, GetAddedNodeInfo, + GetAddressInfoEmbeddedError, GetAddressesByLabel, GetBalance, GetBestBlockHash, + GetBlockCount, GetBlockHash, GetBlockHeader, GetBlockHeaderError, GetBlockHeaderVerbose, + GetBlockHeaderVerboseError, GetBlockStats, GetBlockStatsError, GetBlockTemplate, + GetBlockTemplateError, GetBlockVerboseOne, GetBlockVerboseOneError, GetBlockVerboseZero, + GetChainTips, GetChainTxStatsError, GetConnectionCount, GetDifficulty, GetMemoryInfoStats, + GetMempoolInfoError, GetMiningInfo, GetNetTotals, GetNetworkInfoAddress, + GetNetworkInfoError, GetNetworkInfoNetwork, GetNewAddress, GetRawChangeAddress, + GetRawTransaction, GetRawTransactionVerbose, GetRawTransactionVerboseError, + GetReceivedByAddress, GetTransactionDetailError, GetTransactionError, GetTxOut, + GetTxOutError, GetTxOutSetInfo, GetTxOutSetInfoError, GetUnconfirmedBalance, + GetWalletInfoError, ListAddressGroupings, ListAddressGroupingsError, ListAddressGroupingsItem, ListLabels, ListLockUnspent, ListLockUnspentItem, ListLockUnspentItemError, ListReceivedByAddressError, ListUnspentItemError, ListWallets, - LoadWallet, LockUnspent, Locked, NumericError, PruneBlockchain, RawTransactionError, - RawTransactionInput, RawTransactionOutput, RescanBlockchain, ScriptType, SendMany, - SendRawTransaction, SendToAddress, SetNetworkActive, SetTxFee, SignMessage, - SignMessageWithPrivKey, SignRawTransaction, SignRawTransactionError, + LoadWallet, LockUnspent, Locked, NumericError, PartialSignatureError, PruneBlockchain, + RawTransactionError, RawTransactionInput, RawTransactionOutput, RescanBlockchain, + ScriptType, SendMany, SendRawTransaction, SendToAddress, SetNetworkActive, SetTxFee, + SignMessage, SignMessageWithPrivKey, SignRawTransaction, SignRawTransactionError, SignRawTransactionWithKey, SignRawTransactionWithWallet, SoftforkReject, TestMempoolAccept, TransactionCategory, UploadTarget, ValidateAddress, ValidateAddressError, VerifyChain, VerifyMessage, VerifyTxOutProof, WaitForBlock, WaitForBlockError, WaitForBlockHeight, WaitForBlockHeightError, WaitForNewBlock, WaitForNewBlockError, WalletCreateFundedPsbt, - WalletCreateFundedPsbtError, WalletProcessPsbt, WitnessUtxo, + WalletCreateFundedPsbtError, WalletProcessPsbt, WitnessUtxo, WitnessUtxoError, }, v18::{ ActiveCommand, AnalyzePsbt, AnalyzePsbtError, AnalyzePsbtInput, AnalyzePsbtInputMissing, diff --git a/types/src/v21/mod.rs b/types/src/v21/mod.rs index 066ff55c..bf50b431 100644 --- a/types/src/v21/mod.rs +++ b/types/src/v21/mod.rs @@ -264,8 +264,8 @@ pub use self::{ pub use crate::{ v17::{ AbortRescan, AddMultisigAddressError, AddedNode, AddedNodeAddress, AddressInformation, - BumpFee, BumpFeeError, ChainTips, ChainTipsError, ChainTipsStatus, CombinePsbt, - CombineRawTransaction, ConvertToPsbt, CreateMultisigError, CreatePsbt, + Bip32DerivError, BumpFee, BumpFeeError, ChainTips, ChainTipsError, ChainTipsStatus, + CombinePsbt, CombineRawTransaction, ConvertToPsbt, CreateMultisigError, CreatePsbt, CreateRawTransaction, CreateWallet, DecodePsbt, DecodePsbtError, DecodeRawTransaction, DecodeScript, DecodeScriptError, DumpPrivKey, DumpWallet, EncryptWallet, EstimateSmartFee, FinalizePsbt, FinalizePsbtError, FundRawTransaction, FundRawTransactionError, Generate, @@ -282,15 +282,15 @@ pub use crate::{ GetUnconfirmedBalance, GetWalletInfoError, ListAddressGroupings, ListAddressGroupingsError, ListAddressGroupingsItem, ListLabels, ListLockUnspent, ListLockUnspentItem, ListLockUnspentItemError, ListReceivedByAddressError, ListUnspentItemError, ListWallets, - LoadWallet, LockUnspent, Locked, NumericError, PruneBlockchain, RawTransactionError, - RawTransactionInput, RawTransactionOutput, RescanBlockchain, ScriptType, - SendRawTransaction, SendToAddress, SetNetworkActive, SetTxFee, SignMessage, + LoadWallet, LockUnspent, Locked, NumericError, PartialSignatureError, PruneBlockchain, + RawTransactionError, RawTransactionInput, RawTransactionOutput, RescanBlockchain, + ScriptType, SendRawTransaction, SendToAddress, SetNetworkActive, SetTxFee, SignMessage, SignMessageWithPrivKey, SignRawTransaction, SignRawTransactionError, SignRawTransactionWithKey, SignRawTransactionWithWallet, SoftforkReject, TransactionCategory, UploadTarget, ValidateAddress, ValidateAddressError, VerifyChain, VerifyMessage, VerifyTxOutProof, WaitForBlock, WaitForBlockError, WaitForBlockHeight, WaitForBlockHeightError, WaitForNewBlock, WaitForNewBlockError, WalletCreateFundedPsbt, - WalletCreateFundedPsbtError, WalletProcessPsbt, WitnessUtxo, + WalletCreateFundedPsbtError, WalletProcessPsbt, WitnessUtxo, WitnessUtxoError, }, v18::{ ActiveCommand, AnalyzePsbt, AnalyzePsbtError, AnalyzePsbtInput, AnalyzePsbtInputMissing, diff --git a/types/src/v22/mod.rs b/types/src/v22/mod.rs index 91bcaab5..6c345fea 100644 --- a/types/src/v22/mod.rs +++ b/types/src/v22/mod.rs @@ -266,8 +266,8 @@ pub use self::{ pub use crate::{ v17::{ AbortRescan, AddMultisigAddressError, AddedNode, AddedNodeAddress, AddressInformation, - BumpFee, BumpFeeError, ChainTips, ChainTipsError, ChainTipsStatus, CombinePsbt, - CombineRawTransaction, ConvertToPsbt, CreateMultisigError, CreatePsbt, + Bip32DerivError, BumpFee, BumpFeeError, ChainTips, ChainTipsError, ChainTipsStatus, + CombinePsbt, CombineRawTransaction, ConvertToPsbt, CreateMultisigError, CreatePsbt, CreateRawTransaction, CreateWallet, DecodePsbt, DecodePsbtError, DecodeRawTransaction, DumpPrivKey, DumpWallet, EncryptWallet, EstimateSmartFee, FinalizePsbt, FinalizePsbtError, FundRawTransaction, FundRawTransactionError, Generate, GenerateToAddress, GetAddedNodeInfo, @@ -284,15 +284,15 @@ pub use crate::{ GetWalletInfoError, ListAddressGroupings, ListAddressGroupingsError, ListAddressGroupingsItem, ListLabels, ListLockUnspent, ListLockUnspentItem, ListLockUnspentItemError, ListReceivedByAddressError, ListUnspentItemError, ListWallets, - LoadWallet, LockUnspent, Locked, NumericError, PruneBlockchain, RawTransactionError, - RawTransactionInput, RawTransactionOutput, RescanBlockchain, ScriptType, - SendRawTransaction, SendToAddress, SetNetworkActive, SetTxFee, SignMessage, + LoadWallet, LockUnspent, Locked, NumericError, PartialSignatureError, PruneBlockchain, + RawTransactionError, RawTransactionInput, RawTransactionOutput, RescanBlockchain, + ScriptType, SendRawTransaction, SendToAddress, SetNetworkActive, SetTxFee, SignMessage, SignMessageWithPrivKey, SignRawTransaction, SignRawTransactionError, SignRawTransactionWithKey, SignRawTransactionWithWallet, SoftforkReject, TransactionCategory, UploadTarget, ValidateAddress, ValidateAddressError, VerifyChain, VerifyMessage, VerifyTxOutProof, WaitForBlock, WaitForBlockError, WaitForBlockHeight, WaitForBlockHeightError, WaitForNewBlock, WaitForNewBlockError, WalletCreateFundedPsbt, - WalletCreateFundedPsbtError, WalletProcessPsbt, WitnessUtxo, + WalletCreateFundedPsbtError, WalletProcessPsbt, WitnessUtxo, WitnessUtxoError, }, v18::{ ActiveCommand, AnalyzePsbt, AnalyzePsbtError, AnalyzePsbtInput, AnalyzePsbtInputMissing, diff --git a/types/src/v23/mod.rs b/types/src/v23/mod.rs index 9779728a..fde22b3d 100644 --- a/types/src/v23/mod.rs +++ b/types/src/v23/mod.rs @@ -254,8 +254,8 @@ pub use self::{ control::Logging, network::{GetPeerInfo, PeerInfo}, raw_transactions::{ - DecodePsbt, DecodePsbtError, DecodeScript, DecodeScriptError, GlobalXpub, Proprietary, - PsbtInput, PsbtOutput, + DecodePsbt, DecodePsbtError, DecodeScript, DecodeScriptError, GlobalXpub, GlobalXpubError, + Proprietary, PsbtInput, PsbtInputError, PsbtOutput, PsbtOutputError, }, util::CreateMultisig, wallet::{ @@ -268,11 +268,11 @@ pub use self::{ pub use crate::{ v17::{ AbortRescan, AddMultisigAddressError, AddedNode, AddedNodeAddress, AddressInformation, - Bip125Replaceable, BumpFee, BumpFeeError, ChainTips, ChainTipsError, ChainTipsStatus, - CombinePsbt, CombineRawTransaction, ConvertToPsbt, CreateMultisigError, CreatePsbt, - CreateRawTransaction, CreateWallet, DecodeRawTransaction, DumpPrivKey, DumpWallet, - EncryptWallet, EstimateSmartFee, FinalizePsbt, FinalizePsbtError, FundRawTransaction, - FundRawTransactionError, Generate, GenerateToAddress, GetAddedNodeInfo, + Bip125Replaceable, Bip32DerivError, BumpFee, BumpFeeError, ChainTips, ChainTipsError, + ChainTipsStatus, CombinePsbt, CombineRawTransaction, ConvertToPsbt, CreateMultisigError, + CreatePsbt, CreateRawTransaction, CreateWallet, DecodeRawTransaction, DumpPrivKey, + DumpWallet, EncryptWallet, EstimateSmartFee, FinalizePsbt, FinalizePsbtError, + FundRawTransaction, FundRawTransactionError, Generate, GenerateToAddress, GetAddedNodeInfo, GetAddressInfoEmbeddedError, GetAddressesByLabel, GetBalance, GetBestBlockHash, GetBlockCount, GetBlockHash, GetBlockHeader, GetBlockHeaderError, GetBlockHeaderVerbose, GetBlockHeaderVerboseError, GetBlockStats, GetBlockStatsError, GetBlockTemplate, @@ -286,14 +286,15 @@ pub use crate::{ ListAddressGroupingsError, ListAddressGroupingsItem, ListLabels, ListLockUnspent, ListLockUnspentItem, ListLockUnspentItemError, ListReceivedByAddressError, ListUnspentItemError, ListWallets, LoadWallet, LockUnspent, Locked, NumericError, - PruneBlockchain, RawTransactionError, RawTransactionInput, RawTransactionOutput, - RescanBlockchain, ScriptType, SendRawTransaction, SendToAddress, SetNetworkActive, - SetTxFee, SignMessage, SignMessageWithPrivKey, SignRawTransaction, SignRawTransactionError, - SignRawTransactionWithKey, SignRawTransactionWithWallet, SoftforkReject, - TransactionCategory, UploadTarget, ValidateAddress, ValidateAddressError, VerifyChain, - VerifyMessage, VerifyTxOutProof, WaitForBlock, WaitForBlockError, WaitForBlockHeight, - WaitForBlockHeightError, WaitForNewBlock, WaitForNewBlockError, WalletCreateFundedPsbt, - WalletCreateFundedPsbtError, WalletProcessPsbt, WitnessUtxo, + PartialSignatureError, PruneBlockchain, RawTransactionError, RawTransactionInput, + RawTransactionOutput, RescanBlockchain, ScriptType, SendRawTransaction, SendToAddress, + SetNetworkActive, SetTxFee, SignMessage, SignMessageWithPrivKey, SignRawTransaction, + SignRawTransactionError, SignRawTransactionWithKey, SignRawTransactionWithWallet, + SoftforkReject, TransactionCategory, UploadTarget, ValidateAddress, ValidateAddressError, + VerifyChain, VerifyMessage, VerifyTxOutProof, WaitForBlock, WaitForBlockError, + WaitForBlockHeight, WaitForBlockHeightError, WaitForNewBlock, WaitForNewBlockError, + WalletCreateFundedPsbt, WalletCreateFundedPsbtError, WalletProcessPsbt, WitnessUtxo, + WitnessUtxoError, }, v18::{ ActiveCommand, AnalyzePsbt, AnalyzePsbtError, AnalyzePsbtInput, AnalyzePsbtInputMissing, diff --git a/types/src/v23/raw_transactions/error.rs b/types/src/v23/raw_transactions/error.rs index d9eec75f..e9e7f3c9 100644 --- a/types/src/v23/raw_transactions/error.rs +++ b/types/src/v23/raw_transactions/error.rs @@ -4,8 +4,8 @@ use core::fmt; use bitcoin::{address, bip32, hex, sighash}; +use super::{Bip32DerivError, PartialSignatureError, RawTransactionError, WitnessUtxoError}; use crate::error::write_err; -use crate::v17::{Bip32DerivError, PartialSignatureError, RawTransactionError, WitnessUtxoError}; /// Error when converting a `DecodePsbt` type into the model type. #[derive(Debug)] diff --git a/types/src/v23/raw_transactions/mod.rs b/types/src/v23/raw_transactions/mod.rs index c2604495..18ac7ca7 100644 --- a/types/src/v23/raw_transactions/mod.rs +++ b/types/src/v23/raw_transactions/mod.rs @@ -14,8 +14,11 @@ use serde::{Deserialize, Serialize}; use crate::ScriptSig; #[rustfmt::skip] // Keep public re-exports separate. -pub use self::error::{DecodePsbtError, DecodeScriptError, GlobalXpubError, PsbtInputError, PsbtOutputError}; +pub use self::error::{ + DecodePsbtError, DecodeScriptError, GlobalXpubError, PsbtInputError, PsbtOutputError +}; // Re-export types that appear in the public API of this module. +pub use super::{Bip32DerivError, PartialSignatureError, RawTransactionError, WitnessUtxoError}; pub use crate::psbt::{Bip32Deriv, PsbtScript, RawTransaction, WitnessUtxo}; /// Result of JSON-RPC method `decodepsbt`. diff --git a/types/src/v24/mod.rs b/types/src/v24/mod.rs index 50be7bbe..708e0378 100644 --- a/types/src/v24/mod.rs +++ b/types/src/v24/mod.rs @@ -254,8 +254,10 @@ pub use self::{ }, network::{GetPeerInfo, PeerInfo}, raw_transactions::{ - DecodePsbt, DecodePsbtError, GlobalXpub, Proprietary, PsbtInput, PsbtOutput, - TaprootBip32Deriv, TaprootLeaf, TaprootScript, TaprootScriptPathSig, + ControlBlocksError, DecodePsbt, DecodePsbtError, GlobalXpub, GlobalXpubError, Proprietary, + PsbtInput, PsbtInputError, PsbtOutput, PsbtOutputError, TaprootBip32Deriv, + TaprootBip32DerivsError, TaprootLeaf, TaprootLeafError, TaprootScript, TaprootScriptError, + TaprootScriptPathSig, TaprootScriptPathSigError, }, wallet::{ GetTransaction, GetTransactionDetail, GetTransactionError, ListSinceBlock, @@ -267,11 +269,11 @@ pub use self::{ pub use crate::{ v17::{ AbortRescan, AddMultisigAddressError, AddedNode, AddedNodeAddress, AddressInformation, - Bip125Replaceable, BumpFee, BumpFeeError, ChainTips, ChainTipsError, ChainTipsStatus, - CombinePsbt, CombineRawTransaction, ConvertToPsbt, CreateMultisigError, CreatePsbt, - CreateRawTransaction, CreateWallet, DecodeRawTransaction, DumpPrivKey, DumpWallet, - EncryptWallet, EstimateSmartFee, FinalizePsbt, FinalizePsbtError, FundRawTransaction, - FundRawTransactionError, Generate, GenerateToAddress, GetAddedNodeInfo, + Bip125Replaceable, Bip32DerivError, BumpFee, BumpFeeError, ChainTips, ChainTipsError, + ChainTipsStatus, CombinePsbt, CombineRawTransaction, ConvertToPsbt, CreateMultisigError, + CreatePsbt, CreateRawTransaction, CreateWallet, DecodeRawTransaction, DumpPrivKey, + DumpWallet, EncryptWallet, EstimateSmartFee, FinalizePsbt, FinalizePsbtError, + FundRawTransaction, FundRawTransactionError, Generate, GenerateToAddress, GetAddedNodeInfo, GetAddressInfoEmbeddedError, GetAddressesByLabel, GetBalance, GetBestBlockHash, GetBlockCount, GetBlockHash, GetBlockHeader, GetBlockHeaderError, GetBlockHeaderVerbose, GetBlockHeaderVerboseError, GetBlockStats, GetBlockStatsError, GetBlockTemplate, @@ -285,14 +287,15 @@ pub use crate::{ ListAddressGroupingsError, ListAddressGroupingsItem, ListLabels, ListLockUnspent, ListLockUnspentItem, ListLockUnspentItemError, ListReceivedByAddressError, ListUnspentItemError, ListWallets, LoadWallet, LockUnspent, Locked, NumericError, - PruneBlockchain, RawTransactionError, RawTransactionInput, RawTransactionOutput, - RescanBlockchain, ScriptType, SendRawTransaction, SendToAddress, SetNetworkActive, - SetTxFee, SignMessage, SignMessageWithPrivKey, SignRawTransaction, SignRawTransactionError, - SignRawTransactionWithKey, SignRawTransactionWithWallet, SoftforkReject, - TransactionCategory, UploadTarget, ValidateAddress, ValidateAddressError, VerifyChain, - VerifyMessage, VerifyTxOutProof, WaitForBlock, WaitForBlockError, WaitForBlockHeight, - WaitForBlockHeightError, WaitForNewBlock, WaitForNewBlockError, WalletCreateFundedPsbt, - WalletCreateFundedPsbtError, WalletProcessPsbt, WitnessUtxo, + PartialSignatureError, PruneBlockchain, RawTransactionError, RawTransactionInput, + RawTransactionOutput, RescanBlockchain, ScriptType, SendRawTransaction, SendToAddress, + SetNetworkActive, SetTxFee, SignMessage, SignMessageWithPrivKey, SignRawTransaction, + SignRawTransactionError, SignRawTransactionWithKey, SignRawTransactionWithWallet, + SoftforkReject, TransactionCategory, UploadTarget, ValidateAddress, ValidateAddressError, + VerifyChain, VerifyMessage, VerifyTxOutProof, WaitForBlock, WaitForBlockError, + WaitForBlockHeight, WaitForBlockHeightError, WaitForNewBlock, WaitForNewBlockError, + WalletCreateFundedPsbt, WalletCreateFundedPsbtError, WalletProcessPsbt, WitnessUtxo, + WitnessUtxoError, }, v18::{ ActiveCommand, AnalyzePsbt, AnalyzePsbtError, AnalyzePsbtInput, AnalyzePsbtInputMissing, diff --git a/types/src/v24/raw_transactions/error.rs b/types/src/v24/raw_transactions/error.rs index 0b2352bc..490c86ba 100644 --- a/types/src/v24/raw_transactions/error.rs +++ b/types/src/v24/raw_transactions/error.rs @@ -5,8 +5,8 @@ use core::fmt; use bitcoin::taproot::{IncompleteBuilderError, TaprootBuilderError, TaprootError}; use bitcoin::{bip32, hex, secp256k1, sighash}; +use super::{Bip32DerivError, PartialSignatureError, RawTransactionError, WitnessUtxoError}; use crate::error::write_err; -use crate::v17::{Bip32DerivError, PartialSignatureError, RawTransactionError, WitnessUtxoError}; /// Error when converting a `DecodePsbt` type into the model type. #[derive(Debug)] diff --git a/types/src/v24/raw_transactions/mod.rs b/types/src/v24/raw_transactions/mod.rs index f5a4233e..60aa463e 100644 --- a/types/src/v24/raw_transactions/mod.rs +++ b/types/src/v24/raw_transactions/mod.rs @@ -14,8 +14,12 @@ use serde::{Deserialize, Serialize}; use crate::ScriptSig; #[rustfmt::skip] // Keep public re-exports separate. -pub use self::error::{DecodePsbtError, GlobalXpubError, PsbtInputError, PsbtOutputError, TaprootScriptPathSigError, TaprootScriptError, TaprootBip32DerivsError, ControlBlocksError, TaprootLeafError}; +pub use self::error::{ + DecodePsbtError, GlobalXpubError, PsbtInputError, PsbtOutputError, TaprootScriptPathSigError, + TaprootScriptError, TaprootBip32DerivsError, ControlBlocksError, TaprootLeafError +}; // Re-export types that appear in the public API of this module. +pub use super::{Bip32DerivError, PartialSignatureError, RawTransactionError, WitnessUtxoError}; pub use crate::psbt::{Bip32Deriv, PsbtScript, RawTransaction, WitnessUtxo}; /// Result of JSON-RPC method `decodepsbt`. diff --git a/types/src/v25/mod.rs b/types/src/v25/mod.rs index 24132b7d..7d1f05e8 100644 --- a/types/src/v25/mod.rs +++ b/types/src/v25/mod.rs @@ -262,8 +262,8 @@ pub use self::{ pub use crate::{ v17::{ AbortRescan, AddMultisigAddressError, AddedNode, AddedNodeAddress, AddressInformation, - BumpFee, BumpFeeError, ChainTips, ChainTipsError, ChainTipsStatus, CombinePsbt, - CombineRawTransaction, ConvertToPsbt, CreateMultisigError, CreatePsbt, + Bip32DerivError, BumpFee, BumpFeeError, ChainTips, ChainTipsError, ChainTipsStatus, + CombinePsbt, CombineRawTransaction, ConvertToPsbt, CreateMultisigError, CreatePsbt, CreateRawTransaction, DecodeRawTransaction, DumpPrivKey, DumpWallet, EncryptWallet, EstimateSmartFee, FinalizePsbt, FinalizePsbtError, FundRawTransaction, FundRawTransactionError, Generate, GenerateToAddress, GetAddedNodeInfo, @@ -279,15 +279,16 @@ pub use crate::{ GetTxOutSetInfoError, GetUnconfirmedBalance, GetWalletInfoError, ListAddressGroupings, ListAddressGroupingsError, ListAddressGroupingsItem, ListLabels, ListLockUnspent, ListLockUnspentItem, ListLockUnspentItemError, ListReceivedByAddressError, - ListUnspentItemError, ListWallets, LockUnspent, Locked, NumericError, PruneBlockchain, - RawTransactionError, RawTransactionInput, RawTransactionOutput, RescanBlockchain, - ScriptType, SendRawTransaction, SendToAddress, SetNetworkActive, SetTxFee, SignMessage, - SignMessageWithPrivKey, SignRawTransaction, SignRawTransactionError, - SignRawTransactionWithKey, SignRawTransactionWithWallet, SoftforkReject, - TransactionCategory, UploadTarget, ValidateAddress, ValidateAddressError, VerifyChain, - VerifyMessage, VerifyTxOutProof, WaitForBlock, WaitForBlockError, WaitForBlockHeight, - WaitForBlockHeightError, WaitForNewBlock, WaitForNewBlockError, WalletCreateFundedPsbt, - WalletCreateFundedPsbtError, WalletProcessPsbt, WitnessUtxo, + ListUnspentItemError, ListWallets, LockUnspent, Locked, NumericError, + PartialSignatureError, PruneBlockchain, RawTransactionError, RawTransactionInput, + RawTransactionOutput, RescanBlockchain, ScriptType, SendRawTransaction, SendToAddress, + SetNetworkActive, SetTxFee, SignMessage, SignMessageWithPrivKey, SignRawTransaction, + SignRawTransactionError, SignRawTransactionWithKey, SignRawTransactionWithWallet, + SoftforkReject, TransactionCategory, UploadTarget, ValidateAddress, ValidateAddressError, + VerifyChain, VerifyMessage, VerifyTxOutProof, WaitForBlock, WaitForBlockError, + WaitForBlockHeight, WaitForBlockHeightError, WaitForNewBlock, WaitForNewBlockError, + WalletCreateFundedPsbt, WalletCreateFundedPsbtError, WalletProcessPsbt, WitnessUtxo, + WitnessUtxoError, }, v18::{ ActiveCommand, AnalyzePsbt, AnalyzePsbtError, AnalyzePsbtInput, AnalyzePsbtInputMissing, @@ -319,13 +320,15 @@ pub use crate::{ GetDeploymentInfoError, GetWalletInfo, GetWalletInfoScanning, RestoreWallet, SaveMempool, }, v24::{ - DecodePsbt, DecodePsbtError, GetMempoolAncestors, GetMempoolAncestorsVerbose, - GetMempoolDescendants, GetMempoolDescendantsVerbose, GetMempoolEntry, GetMempoolInfo, - GetPeerInfo, GetRawMempoolVerbose, GetTransaction, GetTransactionDetail, - GetTransactionError, GetTxSpendingPrevout, GetTxSpendingPrevoutError, GlobalXpub, - ListSinceBlock, ListSinceBlockError, ListTransactions, ListUnspent, ListUnspentItem, - MempoolEntry, MigrateWallet, PeerInfo, Proprietary, PsbtInput, PsbtOutput, SendAll, - SendAllError, SimulateRawTransaction, TaprootBip32Deriv, TaprootLeaf, TaprootScript, - TaprootScriptPathSig, TransactionItem, TransactionItemError, + ControlBlocksError, DecodePsbt, DecodePsbtError, GetMempoolAncestors, + GetMempoolAncestorsVerbose, GetMempoolDescendants, GetMempoolDescendantsVerbose, + GetMempoolEntry, GetMempoolInfo, GetPeerInfo, GetRawMempoolVerbose, GetTransaction, + GetTransactionDetail, GetTransactionError, GetTxSpendingPrevout, GetTxSpendingPrevoutError, + GlobalXpub, GlobalXpubError, ListSinceBlock, ListSinceBlockError, ListTransactions, + ListUnspent, ListUnspentItem, MempoolEntry, MigrateWallet, PeerInfo, Proprietary, + PsbtInput, PsbtInputError, PsbtOutput, PsbtOutputError, SendAll, SendAllError, + SimulateRawTransaction, TaprootBip32Deriv, TaprootBip32DerivsError, TaprootLeaf, + TaprootLeafError, TaprootScript, TaprootScriptError, TaprootScriptPathSig, + TaprootScriptPathSigError, TransactionItem, TransactionItemError, }, }; diff --git a/types/src/v26/mod.rs b/types/src/v26/mod.rs index be48a17f..44b13190 100644 --- a/types/src/v26/mod.rs +++ b/types/src/v26/mod.rs @@ -280,10 +280,10 @@ pub use self::{ pub use crate::{ v17::{ AbortRescan, AddMultisigAddressError, AddedNode, AddedNodeAddress, AddressInformation, - Bip125Replaceable, BumpFee, BumpFeeError, ChainTips, ChainTipsError, ChainTipsStatus, - CombinePsbt, CombineRawTransaction, ConvertToPsbt, CreateMultisigError, CreatePsbt, - CreateRawTransaction, DecodeRawTransaction, DumpPrivKey, DumpWallet, EncryptWallet, - EstimateSmartFee, FinalizePsbt, FinalizePsbtError, FundRawTransaction, + Bip125Replaceable, Bip32DerivError, BumpFee, BumpFeeError, ChainTips, ChainTipsError, + ChainTipsStatus, CombinePsbt, CombineRawTransaction, ConvertToPsbt, CreateMultisigError, + CreatePsbt, CreateRawTransaction, DecodeRawTransaction, DumpPrivKey, DumpWallet, + EncryptWallet, EstimateSmartFee, FinalizePsbt, FinalizePsbtError, FundRawTransaction, FundRawTransactionError, Generate, GenerateToAddress, GetAddedNodeInfo, GetAddressInfoEmbeddedError, GetAddressesByLabel, GetBalance, GetBestBlockHash, GetBlockCount, GetBlockHash, GetBlockHeader, GetBlockHeaderError, GetBlockHeaderVerbose, @@ -297,15 +297,15 @@ pub use crate::{ GetUnconfirmedBalance, ListAddressGroupings, ListAddressGroupingsError, ListAddressGroupingsItem, ListLabels, ListLockUnspent, ListLockUnspentItem, ListLockUnspentItemError, ListReceivedByAddressError, ListUnspentItemError, ListWallets, - LockUnspent, Locked, NumericError, PruneBlockchain, RawTransactionError, - RawTransactionInput, RawTransactionOutput, RescanBlockchain, ScriptType, - SendRawTransaction, SendToAddress, SetNetworkActive, SetTxFee, SignMessage, + LockUnspent, Locked, NumericError, PartialSignatureError, PruneBlockchain, + RawTransactionError, RawTransactionInput, RawTransactionOutput, RescanBlockchain, + ScriptType, SendRawTransaction, SendToAddress, SetNetworkActive, SetTxFee, SignMessage, SignMessageWithPrivKey, SignRawTransaction, SignRawTransactionError, SignRawTransactionWithKey, SignRawTransactionWithWallet, SoftforkReject, TransactionCategory, UploadTarget, ValidateAddress, ValidateAddressError, VerifyChain, VerifyMessage, VerifyTxOutProof, WaitForBlock, WaitForBlockError, WaitForBlockHeight, WaitForBlockHeightError, WaitForNewBlock, WaitForNewBlockError, WalletCreateFundedPsbt, - WalletCreateFundedPsbtError, WitnessUtxo, + WalletCreateFundedPsbtError, WitnessUtxo, WitnessUtxoError, }, v18::{ ActiveCommand, AnalyzePsbt, AnalyzePsbtError, AnalyzePsbtInput, AnalyzePsbtInputMissing, @@ -336,13 +336,15 @@ pub use crate::{ GetDeploymentInfoError, RestoreWallet, SaveMempool, }, v24::{ - DecodePsbt, DecodePsbtError, GetMempoolAncestors, GetMempoolAncestorsVerbose, - GetMempoolDescendants, GetMempoolDescendantsVerbose, GetMempoolEntry, GetMempoolInfo, - GetRawMempoolVerbose, GetTransactionDetail, GetTxSpendingPrevout, - GetTxSpendingPrevoutError, GlobalXpub, ListSinceBlock, ListSinceBlockError, - ListTransactions, ListUnspent, ListUnspentItem, MempoolEntry, MigrateWallet, Proprietary, - PsbtInput, PsbtOutput, SendAll, SendAllError, SimulateRawTransaction, TaprootBip32Deriv, - TaprootLeaf, TaprootScript, TaprootScriptPathSig, TransactionItem, TransactionItemError, + ControlBlocksError, DecodePsbt, DecodePsbtError, GetMempoolAncestors, + GetMempoolAncestorsVerbose, GetMempoolDescendants, GetMempoolDescendantsVerbose, + GetMempoolEntry, GetMempoolInfo, GetRawMempoolVerbose, GetTransactionDetail, + GetTxSpendingPrevout, GetTxSpendingPrevoutError, GlobalXpub, GlobalXpubError, + ListSinceBlock, ListSinceBlockError, ListTransactions, ListUnspent, ListUnspentItem, + MempoolEntry, MigrateWallet, Proprietary, PsbtInput, PsbtInputError, PsbtOutput, + PsbtOutputError, SendAll, SendAllError, SimulateRawTransaction, TaprootBip32Deriv, + TaprootBip32DerivsError, TaprootLeaf, TaprootLeafError, TaprootScript, TaprootScriptError, + TaprootScriptPathSig, TaprootScriptPathSigError, TransactionItem, TransactionItemError, }, v25::{ GenerateBlock, GenerateBlockError, GetBlockStats, ListDescriptors, MempoolAcceptance, diff --git a/types/src/v27/mod.rs b/types/src/v27/mod.rs index 7a80045b..fb59253e 100644 --- a/types/src/v27/mod.rs +++ b/types/src/v27/mod.rs @@ -256,8 +256,8 @@ pub use self::mining::{GetPrioritisedTransactions, PrioritisedTransaction}; pub use crate::{ v17::{ AbortRescan, AddMultisigAddressError, AddedNode, AddedNodeAddress, AddressInformation, - BumpFee, BumpFeeError, ChainTips, ChainTipsError, ChainTipsStatus, CombinePsbt, - CombineRawTransaction, ConvertToPsbt, CreateMultisigError, CreatePsbt, + Bip32DerivError, BumpFee, BumpFeeError, ChainTips, ChainTipsError, ChainTipsStatus, + CombinePsbt, CombineRawTransaction, ConvertToPsbt, CreateMultisigError, CreatePsbt, CreateRawTransaction, DecodeRawTransaction, DumpPrivKey, DumpWallet, EncryptWallet, EstimateSmartFee, FinalizePsbt, FinalizePsbtError, FundRawTransaction, FundRawTransactionError, Generate, GenerateToAddress, GetAddedNodeInfo, @@ -273,15 +273,15 @@ pub use crate::{ GetUnconfirmedBalance, ListAddressGroupings, ListAddressGroupingsError, ListAddressGroupingsItem, ListLabels, ListLockUnspent, ListLockUnspentItem, ListLockUnspentItemError, ListReceivedByAddressError, ListUnspentItemError, ListWallets, - LockUnspent, Locked, NumericError, PruneBlockchain, RawTransactionError, - RawTransactionInput, RawTransactionOutput, RescanBlockchain, ScriptType, - SendRawTransaction, SendToAddress, SetNetworkActive, SetTxFee, SignMessage, + LockUnspent, Locked, NumericError, PartialSignatureError, PruneBlockchain, + RawTransactionError, RawTransactionInput, RawTransactionOutput, RescanBlockchain, + ScriptType, SendRawTransaction, SendToAddress, SetNetworkActive, SetTxFee, SignMessage, SignMessageWithPrivKey, SignRawTransaction, SignRawTransactionError, SignRawTransactionWithKey, SignRawTransactionWithWallet, SoftforkReject, TransactionCategory, UploadTarget, ValidateAddress, ValidateAddressError, VerifyChain, VerifyMessage, VerifyTxOutProof, WaitForBlock, WaitForBlockError, WaitForBlockHeight, WaitForBlockHeightError, WaitForNewBlock, WaitForNewBlockError, WalletCreateFundedPsbt, - WalletCreateFundedPsbtError, WitnessUtxo, + WalletCreateFundedPsbtError, WitnessUtxo, WitnessUtxoError, }, v18::{ ActiveCommand, AnalyzePsbt, AnalyzePsbtError, AnalyzePsbtInput, AnalyzePsbtInputMissing, @@ -312,13 +312,15 @@ pub use crate::{ GetDeploymentInfoError, RestoreWallet, SaveMempool, }, v24::{ - DecodePsbt, DecodePsbtError, GetMempoolAncestors, GetMempoolAncestorsVerbose, - GetMempoolDescendants, GetMempoolDescendantsVerbose, GetMempoolEntry, GetMempoolInfo, - GetRawMempoolVerbose, GetTransactionDetail, GetTxSpendingPrevout, - GetTxSpendingPrevoutError, GlobalXpub, ListSinceBlock, ListSinceBlockError, - ListTransactions, ListUnspent, ListUnspentItem, MempoolEntry, MigrateWallet, Proprietary, - PsbtInput, PsbtOutput, SendAll, SendAllError, SimulateRawTransaction, TaprootBip32Deriv, - TaprootLeaf, TaprootScript, TaprootScriptPathSig, TransactionItem, TransactionItemError, + ControlBlocksError, DecodePsbt, DecodePsbtError, GetMempoolAncestors, + GetMempoolAncestorsVerbose, GetMempoolDescendants, GetMempoolDescendantsVerbose, + GetMempoolEntry, GetMempoolInfo, GetRawMempoolVerbose, GetTransactionDetail, + GetTxSpendingPrevout, GetTxSpendingPrevoutError, GlobalXpub, GlobalXpubError, + ListSinceBlock, ListSinceBlockError, ListTransactions, ListUnspent, ListUnspentItem, + MempoolEntry, MigrateWallet, Proprietary, PsbtInput, PsbtInputError, PsbtOutput, + PsbtOutputError, SendAll, SendAllError, SimulateRawTransaction, TaprootBip32Deriv, + TaprootBip32DerivsError, TaprootLeaf, TaprootLeafError, TaprootScript, TaprootScriptError, + TaprootScriptPathSig, TaprootScriptPathSigError, TransactionItem, TransactionItemError, }, v25::{ GenerateBlock, GenerateBlockError, GetBlockStats, ListDescriptors, MempoolAcceptance, diff --git a/types/src/v28/mod.rs b/types/src/v28/mod.rs index 302784e8..3f468280 100644 --- a/types/src/v28/mod.rs +++ b/types/src/v28/mod.rs @@ -277,10 +277,10 @@ pub use self::{ pub use crate::{ v17::{ AbortRescan, AddMultisigAddressError, AddedNode, AddedNodeAddress, AddressInformation, - Bip125Replaceable, BumpFee, BumpFeeError, ChainTips, ChainTipsError, ChainTipsStatus, - CombinePsbt, CombineRawTransaction, ConvertToPsbt, CreateMultisigError, CreatePsbt, - CreateRawTransaction, DecodeRawTransaction, DumpPrivKey, DumpWallet, EncryptWallet, - EstimateSmartFee, FinalizePsbt, FinalizePsbtError, FundRawTransaction, + Bip125Replaceable, Bip32DerivError, BumpFee, BumpFeeError, ChainTips, ChainTipsError, + ChainTipsStatus, CombinePsbt, CombineRawTransaction, ConvertToPsbt, CreateMultisigError, + CreatePsbt, CreateRawTransaction, DecodeRawTransaction, DumpPrivKey, DumpWallet, + EncryptWallet, EstimateSmartFee, FinalizePsbt, FinalizePsbtError, FundRawTransaction, FundRawTransactionError, Generate, GenerateToAddress, GetAddedNodeInfo, GetAddressInfoEmbeddedError, GetAddressesByLabel, GetBalance, GetBestBlockHash, GetBlockCount, GetBlockHash, GetBlockHeader, GetBlockHeaderError, GetBlockHeaderVerbose, @@ -294,15 +294,15 @@ pub use crate::{ GetUnconfirmedBalance, ListAddressGroupings, ListAddressGroupingsError, ListAddressGroupingsItem, ListLabels, ListLockUnspent, ListLockUnspentItem, ListLockUnspentItemError, ListReceivedByAddressError, ListUnspentItemError, ListWallets, - LockUnspent, Locked, NumericError, PruneBlockchain, RawTransactionError, - RawTransactionInput, RawTransactionOutput, RescanBlockchain, ScriptType, - SendRawTransaction, SendToAddress, SetNetworkActive, SetTxFee, SignMessage, + LockUnspent, Locked, NumericError, PartialSignatureError, PruneBlockchain, + RawTransactionError, RawTransactionInput, RawTransactionOutput, RescanBlockchain, + ScriptType, SendRawTransaction, SendToAddress, SetNetworkActive, SetTxFee, SignMessage, SignMessageWithPrivKey, SignRawTransaction, SignRawTransactionError, SignRawTransactionWithKey, SignRawTransactionWithWallet, SoftforkReject, TransactionCategory, UploadTarget, ValidateAddress, ValidateAddressError, VerifyChain, VerifyMessage, VerifyTxOutProof, WaitForBlock, WaitForBlockError, WaitForBlockHeight, WaitForBlockHeightError, WaitForNewBlock, WaitForNewBlockError, WalletCreateFundedPsbt, - WalletCreateFundedPsbtError, WitnessUtxo, + WalletCreateFundedPsbtError, WitnessUtxo, WitnessUtxoError, }, v18::{ ActiveCommand, AnalyzePsbt, AnalyzePsbtError, AnalyzePsbtInput, AnalyzePsbtInputMissing, @@ -332,13 +332,14 @@ pub use crate::{ RestoreWallet, SaveMempool, }, v24::{ - DecodePsbt, DecodePsbtError, GetMempoolAncestors, GetMempoolAncestorsVerbose, - GetMempoolDescendants, GetMempoolDescendantsVerbose, GetMempoolEntry, GetMempoolInfo, - GetRawMempoolVerbose, GetTransactionDetail, GetTxSpendingPrevout, - GetTxSpendingPrevoutError, GlobalXpub, ListUnspent, ListUnspentItem, MempoolEntry, - MigrateWallet, Proprietary, PsbtInput, PsbtOutput, SendAll, SendAllError, - SimulateRawTransaction, TaprootBip32Deriv, TaprootLeaf, TaprootScript, - TaprootScriptPathSig, + ControlBlocksError, DecodePsbt, DecodePsbtError, GetMempoolAncestors, + GetMempoolAncestorsVerbose, GetMempoolDescendants, GetMempoolDescendantsVerbose, + GetMempoolEntry, GetMempoolInfo, GetRawMempoolVerbose, GetTransactionDetail, + GetTxSpendingPrevout, GetTxSpendingPrevoutError, GlobalXpub, GlobalXpubError, ListUnspent, + ListUnspentItem, MempoolEntry, MigrateWallet, Proprietary, PsbtInput, PsbtInputError, + PsbtOutput, PsbtOutputError, SendAll, SendAllError, SimulateRawTransaction, + TaprootBip32Deriv, TaprootBip32DerivsError, TaprootLeaf, TaprootLeafError, TaprootScript, + TaprootScriptError, TaprootScriptPathSig, TaprootScriptPathSigError, }, v25::{ GenerateBlock, GenerateBlockError, GetBlockStats, ListDescriptors, MempoolAcceptance, diff --git a/types/src/v29/mod.rs b/types/src/v29/mod.rs index a2e5a6ca..6ca062c5 100644 --- a/types/src/v29/mod.rs +++ b/types/src/v29/mod.rs @@ -272,8 +272,8 @@ pub use self::{ pub use crate::{ v17::{ AbortRescan, AddMultisigAddressError, AddedNode, AddedNodeAddress, AddressInformation, - BumpFee, BumpFeeError, ChainTips, ChainTipsError, ChainTipsStatus, CombinePsbt, - CombineRawTransaction, ConvertToPsbt, CreateMultisigError, CreatePsbt, + Bip32DerivError, BumpFee, BumpFeeError, ChainTips, ChainTipsError, ChainTipsStatus, + CombinePsbt, CombineRawTransaction, ConvertToPsbt, CreateMultisigError, CreatePsbt, CreateRawTransaction, DecodeRawTransaction, DumpPrivKey, DumpWallet, EncryptWallet, EstimateSmartFee, FinalizePsbt, FinalizePsbtError, FundRawTransaction, FundRawTransactionError, Generate, GenerateToAddress, GetAddedNodeInfo, @@ -287,15 +287,15 @@ pub use crate::{ GetUnconfirmedBalance, ListAddressGroupings, ListAddressGroupingsError, ListAddressGroupingsItem, ListLabels, ListLockUnspent, ListLockUnspentItem, ListLockUnspentItemError, ListReceivedByAddressError, ListUnspentItemError, ListWallets, - LockUnspent, Locked, NumericError, PruneBlockchain, RawTransactionError, - RawTransactionInput, RawTransactionOutput, RescanBlockchain, ScriptType, - SendRawTransaction, SendToAddress, SetNetworkActive, SetTxFee, SignMessage, + LockUnspent, Locked, NumericError, PartialSignatureError, PruneBlockchain, + RawTransactionError, RawTransactionInput, RawTransactionOutput, RescanBlockchain, + ScriptType, SendRawTransaction, SendToAddress, SetNetworkActive, SetTxFee, SignMessage, SignMessageWithPrivKey, SignRawTransaction, SignRawTransactionError, SignRawTransactionWithKey, SignRawTransactionWithWallet, TransactionCategory, UploadTarget, ValidateAddress, ValidateAddressError, VerifyChain, VerifyMessage, VerifyTxOutProof, WaitForBlock, WaitForBlockError, WaitForBlockHeight, WaitForBlockHeightError, WaitForNewBlock, WaitForNewBlockError, WalletCreateFundedPsbt, WalletCreateFundedPsbtError, - WitnessUtxo, + WitnessUtxo, WitnessUtxoError, }, v18::{ ActiveCommand, AnalyzePsbt, AnalyzePsbtError, AnalyzePsbtInput, AnalyzePsbtInputMissing, @@ -325,13 +325,14 @@ pub use crate::{ RestoreWallet, SaveMempool, }, v24::{ - DecodePsbt, DecodePsbtError, GetMempoolAncestors, GetMempoolAncestorsVerbose, - GetMempoolDescendants, GetMempoolDescendantsVerbose, GetMempoolEntry, GetMempoolInfo, - GetRawMempoolVerbose, GetTransactionDetail, GetTxSpendingPrevout, - GetTxSpendingPrevoutError, GlobalXpub, ListUnspent, ListUnspentItem, MempoolEntry, - MigrateWallet, Proprietary, PsbtInput, PsbtOutput, SendAll, SendAllError, - SimulateRawTransaction, TaprootBip32Deriv, TaprootLeaf, TaprootScript, - TaprootScriptPathSig, + ControlBlocksError, DecodePsbt, DecodePsbtError, GetMempoolAncestors, + GetMempoolAncestorsVerbose, GetMempoolDescendants, GetMempoolDescendantsVerbose, + GetMempoolEntry, GetMempoolInfo, GetRawMempoolVerbose, GetTransactionDetail, + GetTxSpendingPrevout, GetTxSpendingPrevoutError, GlobalXpub, GlobalXpubError, ListUnspent, + ListUnspentItem, MempoolEntry, MigrateWallet, Proprietary, PsbtInput, PsbtInputError, + PsbtOutput, PsbtOutputError, SendAll, SendAllError, SimulateRawTransaction, + TaprootBip32Deriv, TaprootBip32DerivsError, TaprootLeaf, TaprootLeafError, TaprootScript, + TaprootScriptError, TaprootScriptPathSig, TaprootScriptPathSigError, }, v25::{ GenerateBlock, GenerateBlockError, GetBlockStats, ListDescriptors, MempoolAcceptanceError, diff --git a/types/src/v30/mod.rs b/types/src/v30/mod.rs index 0aedbd27..ff6d7d79 100644 --- a/types/src/v30/mod.rs +++ b/types/src/v30/mod.rs @@ -128,7 +128,7 @@ //! | converttopsbt | version + model | | //! | createpsbt | version + model | | //! | createrawtransaction | version + model | | -//! | decodepsbt | version + model | TODO | +//! | decodepsbt | version + model | Musig not modelled: not in rust-bitcoin| //! | descriptorprocesspsbt | returns boolean | | //! | decoderawtransaction | version + model | | //! | decodescript | version + model | | @@ -244,38 +244,46 @@ mod blockchain; mod mining; +mod raw_transactions; #[doc(inline)] pub use self::{ blockchain::GetMempoolInfo, mining::{GetMiningInfo, GetMiningInfoError}, + raw_transactions::{ + ControlBlocksError, DecodePsbt, DecodePsbtError, GlobalXpub, Proprietary, PsbtInput, + PsbtInputError, PsbtOutput, PsbtOutputError, TaprootBip32Deriv, TaprootBip32DerivsError, + TaprootLeaf, TaprootLeafError, TaprootScript, TaprootScriptError, TaprootScriptPathSig, + TaprootScriptPathSigError, + }, }; #[doc(inline)] pub use crate::{ v17::{ - AbortRescan, AddedNode, AddedNodeAddress, AddressInformation, BumpFee, BumpFeeError, - ChainTips, ChainTipsError, ChainTipsStatus, CombinePsbt, CombineRawTransaction, - ConvertToPsbt, CreateMultisigError, CreatePsbt, CreateRawTransaction, DecodeRawTransaction, - EncryptWallet, EstimateSmartFee, FinalizePsbt, FinalizePsbtError, FundRawTransaction, - FundRawTransactionError, Generate, GenerateToAddress, GetAddedNodeInfo, - GetAddressInfoEmbeddedError, GetAddressesByLabel, GetBalance, GetBestBlockHash, - GetBlockCount, GetBlockHash, GetBlockStatsError, GetBlockTemplate, GetBlockTemplateError, - GetBlockVerboseZero, GetChainTips, GetChainTxStatsError, GetConnectionCount, GetDifficulty, - GetMemoryInfoStats, GetMempoolInfoError, GetNetTotals, GetNetworkInfoAddress, - GetNetworkInfoError, GetNetworkInfoNetwork, GetNewAddress, GetRawChangeAddress, - GetRawMempool, GetRawTransaction, GetRawTransactionVerbose, GetRawTransactionVerboseError, + AbortRescan, AddedNode, AddedNodeAddress, AddressInformation, Bip32DerivError, BumpFee, + BumpFeeError, ChainTips, ChainTipsError, ChainTipsStatus, CombinePsbt, + CombineRawTransaction, ConvertToPsbt, CreateMultisigError, CreatePsbt, + CreateRawTransaction, DecodeRawTransaction, EncryptWallet, EstimateSmartFee, FinalizePsbt, + FinalizePsbtError, FundRawTransaction, FundRawTransactionError, Generate, + GenerateToAddress, GetAddedNodeInfo, GetAddressInfoEmbeddedError, GetAddressesByLabel, + GetBalance, GetBestBlockHash, GetBlockCount, GetBlockHash, GetBlockStatsError, + GetBlockTemplate, GetBlockTemplateError, GetBlockVerboseZero, GetChainTips, + GetChainTxStatsError, GetConnectionCount, GetDifficulty, GetMemoryInfoStats, + GetMempoolInfoError, GetNetTotals, GetNetworkInfoAddress, GetNetworkInfoError, + GetNetworkInfoNetwork, GetNewAddress, GetRawChangeAddress, GetRawMempool, + GetRawTransaction, GetRawTransactionVerbose, GetRawTransactionVerboseError, GetReceivedByAddress, GetTransactionDetailError, GetTxOut, GetTxOutError, ListAddressGroupings, ListAddressGroupingsError, ListAddressGroupingsItem, ListLabels, ListLockUnspent, ListLockUnspentItem, ListLockUnspentItemError, ListReceivedByAddressError, - ListUnspentItemError, ListWallets, LockUnspent, Locked, NumericError, PruneBlockchain, - RawTransactionError, RawTransactionInput, RawTransactionOutput, RescanBlockchain, - ScriptType, SendRawTransaction, SendToAddress, SetNetworkActive, SetTxFee, SignMessage, - SignMessageWithPrivKey, SignRawTransaction, SignRawTransactionError, - SignRawTransactionWithKey, SignRawTransactionWithWallet, TransactionCategory, UploadTarget, - ValidateAddress, ValidateAddressError, VerifyChain, VerifyMessage, VerifyTxOutProof, - WaitForBlock, WaitForBlockError, WaitForBlockHeight, WaitForBlockHeightError, - WaitForNewBlock, WaitForNewBlockError, WalletCreateFundedPsbt, WalletCreateFundedPsbtError, - WitnessUtxo, + ListUnspentItemError, ListWallets, LockUnspent, Locked, NumericError, + PartialSignatureError, PruneBlockchain, RawTransactionError, RawTransactionInput, + RawTransactionOutput, RescanBlockchain, ScriptType, SendRawTransaction, SendToAddress, + SetNetworkActive, SetTxFee, SignMessage, SignMessageWithPrivKey, SignRawTransaction, + SignRawTransactionError, SignRawTransactionWithKey, SignRawTransactionWithWallet, + TransactionCategory, UploadTarget, ValidateAddress, ValidateAddressError, VerifyChain, + VerifyMessage, VerifyTxOutProof, WaitForBlock, WaitForBlockError, WaitForBlockHeight, + WaitForBlockHeightError, WaitForNewBlock, WaitForNewBlockError, WalletCreateFundedPsbt, + WalletCreateFundedPsbtError, WitnessUtxo, WitnessUtxoError, }, v18::{ ActiveCommand, AnalyzePsbt, AnalyzePsbtError, AnalyzePsbtInput, AnalyzePsbtInputMissing, @@ -304,12 +312,10 @@ pub use crate::{ GetDeploymentInfo, GetDeploymentInfoError, RestoreWallet, SaveMempool, }, v24::{ - DecodePsbt, DecodePsbtError, GetMempoolAncestors, GetMempoolAncestorsVerbose, - GetMempoolDescendants, GetMempoolDescendantsVerbose, GetMempoolEntry, GetRawMempoolVerbose, - GetTransactionDetail, GetTxSpendingPrevout, GetTxSpendingPrevoutError, GlobalXpub, - ListUnspent, ListUnspentItem, MempoolEntry, MigrateWallet, Proprietary, PsbtInput, - PsbtOutput, SendAll, SendAllError, SimulateRawTransaction, TaprootBip32Deriv, TaprootLeaf, - TaprootScript, TaprootScriptPathSig, + GetMempoolAncestors, GetMempoolAncestorsVerbose, GetMempoolDescendants, + GetMempoolDescendantsVerbose, GetMempoolEntry, GetRawMempoolVerbose, GetTransactionDetail, + GetTxSpendingPrevout, GetTxSpendingPrevoutError, ListUnspent, ListUnspentItem, + MempoolEntry, MigrateWallet, SendAll, SendAllError, SimulateRawTransaction, }, v25::{ GenerateBlock, GenerateBlockError, GetBlockStats, ListDescriptors, MempoolAcceptanceError, diff --git a/types/src/v30/raw_transactions/error.rs b/types/src/v30/raw_transactions/error.rs new file mode 100644 index 00000000..490c86ba --- /dev/null +++ b/types/src/v30/raw_transactions/error.rs @@ -0,0 +1,465 @@ +// SPDX-License-Identifier: CC0-1.0 + +use core::fmt; + +use bitcoin::taproot::{IncompleteBuilderError, TaprootBuilderError, TaprootError}; +use bitcoin::{bip32, hex, secp256k1, sighash}; + +use super::{Bip32DerivError, PartialSignatureError, RawTransactionError, WitnessUtxoError}; +use crate::error::write_err; + +/// Error when converting a `DecodePsbt` type into the model type. +#[derive(Debug)] +pub enum DecodePsbtError { + /// Conversion of the `tx` field failed. + Tx(RawTransactionError), + /// Conversion of the `global_xpubs` field failed. + GlobalXpubs(GlobalXpubError), + /// Conversion of the `proprietary` field failed. + Proprietary(hex::HexToBytesError), + /// Conversion of one the map items in the `unknown` field failed. + Unknown(hex::HexToBytesError), + /// Conversion of one of the PSBT inputs failed. + Inputs(PsbtInputError), + /// Conversion of one of the PSBT outputs failed. + Outputs(PsbtOutputError), +} + +impl fmt::Display for DecodePsbtError { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + match *self { + Self::Tx(ref e) => write_err!(f, "conversion of raw transaction data field failed"; e), + Self::GlobalXpubs(ref e) => + write_err!(f, "conversion of one the map items in the `global_xbubs` field failed"; e), + Self::Proprietary(ref e) => + write_err!(f, "conversion of one the map items in the `proprietray` field failed"; e), + Self::Unknown(ref e) => + write_err!(f, "conversion of one the map items in the `unknown` field failed"; e), + Self::Inputs(ref e) => write_err!(f, "conversion of one of the PSBT inputs failed"; e), + Self::Outputs(ref e) => + write_err!(f, "conversion of one of the PSBT outputs failed"; e), + } + } +} + +#[cfg(feature = "std")] +impl std::error::Error for DecodePsbtError { + fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { + match *self { + Self::Tx(ref e) => Some(e), + Self::GlobalXpubs(ref e) => Some(e), + Self::Proprietary(ref e) => Some(e), + Self::Unknown(ref e) => Some(e), + Self::Inputs(ref e) => Some(e), + Self::Outputs(ref e) => Some(e), + } + } +} + +/// Error when converting one of the global xpubs failed. +#[derive(Debug)] +pub enum GlobalXpubError { + /// Conversion of the `xpub` field failed. + Xpub(bip32::Error), + /// Conversion of the `master_fingerprint` field failed. + MasterFingerprint(hex::HexToArrayError), + /// Conversion of the `path` field failed. + Path(bip32::Error), +} + +impl fmt::Display for GlobalXpubError { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + match *self { + Self::Xpub(ref e) => write_err!(f, "conversion of the xpub failed"; e), + Self::MasterFingerprint(ref e) => + write_err!(f, "conversion of the `master_fingerprint` field failed"; e), + Self::Path(ref e) => write_err!(f, "conversion of the `path` field failed"; e), + } + } +} + +#[cfg(feature = "std")] +impl std::error::Error for GlobalXpubError { + fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { + match *self { + Self::Xpub(ref e) => Some(e), + Self::MasterFingerprint(ref e) => Some(e), + Self::Path(ref e) => Some(e), + } + } +} + +/// Error when converting one of the `DecodePsbt` inputs failed. +#[derive(Debug)] +pub enum PsbtInputError { + /// Conversion of the `non_witness_utxo` field failed. + NonWitnessUtxo(RawTransactionError), + /// Conversion of the `witness_utxo` field failed. + WitnessUtxo(WitnessUtxoError), + /// Conversion of the `partial_signatures` field failed. + PartialSignatures(PartialSignatureError), + /// Conversion of the `sighash` field failed. + Sighash(sighash::SighashTypeParseError), + /// Conversion of the `redeem_script` field failed. + RedeemScript(hex::HexToBytesError), + /// Conversion of the `witness_script` field failed. + WitnessScript(hex::HexToBytesError), + /// Conversion of the `bip32_derivs` field failed. + Bip32Derivs(Bip32DerivError), + /// Conversion of the `final_script_sig` field failed. + FinalScriptSig(hex::HexToBytesError), + /// Conversion of the `final_script_witness` field failed. + FinalScriptWitness(hex::HexToBytesError), + /// Conversion of the `ripemd160` hash failed. + Ripemd160(hex::HexToArrayError), + /// Conversion of the `ripemd160` preimage failed. + Ripemd160Preimage(hex::HexToBytesError), + /// Conversion of the `sha256` hash failed. + Sha256(hex::HexToArrayError), + /// Conversion of the `sha256` preimage failed. + Sha256Preimage(hex::HexToBytesError), + /// Conversion of the `hash160` hash failed. + Hash160(hex::HexToArrayError), + /// Conversion of the `hash160` preimage failed. + Hash160Preimage(hex::HexToBytesError), + /// Conversion of the `hash256` hash failed. + Hash256(hex::HexToArrayError), + /// Conversion of the `hash256` preimage failed. + Hash256Preimage(hex::HexToBytesError), + /// Conversion of the `taproot_key_path_sig` field failed. + TaprootKeyPathSig(super::taproot::Error), + /// Conversion of the `taproot_script_path_sigs` field failed. + TaprootScriptPathSigs(TaprootScriptPathSigError), + /// Conversion of the `taproot_scripts` field failed. + TaprootScripts(TaprootScriptError), + /// Conversion of the `taproot_bip32_derives` field failed. + TaprootBip32Derivs(TaprootBip32DerivsError), + /// Conversion of the `taproot_internal_key` field failed. + TaprootInternalKey(secp256k1::Error), + /// Conversion of the `taproot_merkle_root` field failed. + TaprootMerkleRoot(hex::HexToArrayError), + /// Conversion of the `proprietary` field failed. + Proprietary(hex::HexToBytesError), + /// Conversion of the `unknown` field failed. + Unknown(hex::HexToBytesError), +} + +impl fmt::Display for PsbtInputError { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + match *self { + Self::NonWitnessUtxo(ref e) => + write_err!(f, "conversion of the `non_witness_utxo` field failed"; e), + Self::WitnessUtxo(ref e) => + write_err!(f, "conversion of the `witness_utxo` field failed"; e), + Self::PartialSignatures(ref e) => + write_err!(f, "conversion of the `partial_signatures` field failed"; e), + Self::Sighash(ref e) => write_err!(f, "conversion of the `sighash` field failed"; e), + Self::RedeemScript(ref e) => + write_err!(f, "conversion of the `redeem_script` field failed"; e), + Self::WitnessScript(ref e) => + write_err!(f, "conversion of the `witness_script` field failed"; e), + Self::Bip32Derivs(ref e) => + write_err!(f, "conversion of the `bip32_derivs` field failed"; e), + Self::FinalScriptSig(ref e) => + write_err!(f, "conversion of the `final_script_sig` field failed"; e), + Self::FinalScriptWitness(ref e) => + write_err!(f, "conversion of the `final_script_witness` field failed"; e), + Self::Ripemd160(ref e) => write_err!(f, "conversion of the `ripemd160` hash failed"; e), + Self::Ripemd160Preimage(ref e) => + write_err!(f, "conversion of the `ripemd160` preimage failed"; e), + Self::Sha256(ref e) => write_err!(f, "conversion of the `sha256` hash failed"; e), + Self::Sha256Preimage(ref e) => + write_err!(f, "conversion of the `sha256` preimage failed"; e), + Self::Hash160(ref e) => write_err!(f, "conversion of the `hash160` hash failed"; e), + Self::Hash160Preimage(ref e) => + write_err!(f, "conversion of the `hash160` preimage failed"; e), + Self::Hash256(ref e) => write_err!(f, "conversion of the `hash256` hash failed"; e), + Self::Hash256Preimage(ref e) => + write_err!(f, "conversion of the `hash256` preimage failed"; e), + Self::TaprootKeyPathSig(ref e) => + write_err!(f, "conversion of the `taproot_key_path_sig` field failed"; e), + Self::TaprootScriptPathSigs(ref e) => + write_err!(f, "conversion of the `taproot_script_path_sigs` field failed"; e), + Self::TaprootScripts(ref e) => + write_err!(f, "conversion of the `taproot_scripts` field failed"; e), + Self::TaprootBip32Derivs(ref e) => + write_err!(f, "conversion of the `taproot_bip32_derivs` field failed"; e), + Self::TaprootInternalKey(ref e) => + write_err!(f, "conversion of the `taproot_internal_key` field failed"; e), + Self::TaprootMerkleRoot(ref e) => + write_err!(f, "conversion of the `taproot_merkle_root` field failed"; e), + Self::Proprietary(ref e) => + write_err!(f, "conversion of one the map items in the `proprietray` field failed"; e), + Self::Unknown(ref e) => write_err!(f, "conversion of the `unknown` field failed"; e), + } + } +} + +#[cfg(feature = "std")] +impl std::error::Error for PsbtInputError { + fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { + match *self { + Self::NonWitnessUtxo(ref e) => Some(e), + Self::WitnessUtxo(ref e) => Some(e), + Self::PartialSignatures(ref e) => Some(e), + Self::Sighash(ref e) => Some(e), + Self::RedeemScript(ref e) => Some(e), + Self::WitnessScript(ref e) => Some(e), + Self::Bip32Derivs(ref e) => Some(e), + Self::FinalScriptSig(ref e) => Some(e), + Self::FinalScriptWitness(ref e) => Some(e), + Self::Ripemd160(ref e) => Some(e), + Self::Ripemd160Preimage(ref e) => Some(e), + Self::Sha256(ref e) => Some(e), + Self::Sha256Preimage(ref e) => Some(e), + Self::Hash160(ref e) => Some(e), + Self::Hash160Preimage(ref e) => Some(e), + Self::Hash256(ref e) => Some(e), + Self::Hash256Preimage(ref e) => Some(e), + Self::TaprootKeyPathSig(ref e) => Some(e), + Self::TaprootScriptPathSigs(ref e) => Some(e), + Self::TaprootScripts(ref e) => Some(e), + Self::TaprootBip32Derivs(ref e) => Some(e), + Self::TaprootInternalKey(ref e) => Some(e), + Self::TaprootMerkleRoot(ref e) => Some(e), + Self::Proprietary(ref e) => Some(e), + Self::Unknown(ref e) => Some(e), + } + } +} + +/// Error when converting one of the `DecodePsbt` outputs failed. +#[derive(Debug)] +pub enum PsbtOutputError { + /// Conversion of the `redeem_script` field failed. + RedeemScript(hex::HexToBytesError), + /// Conversion of the `witness_script` field failed. + WitnessScript(hex::HexToBytesError), + /// Conversion of the `bip32_derivs` field failed. + Bip32Derivs(Bip32DerivError), + /// Conversion of the `taproot_internal_key` field failed. + TaprootInternalKey(secp256k1::Error), + /// Conversion of the `taproot_tree` field failed. + TaprootTree(TaprootLeafError), + /// Conversion of the `taproot_bip32_derives` field failed. + TaprootBip32Derivs(TaprootBip32DerivsError), + /// Conversion of the `proprietary` field failed. + Proprietary(hex::HexToBytesError), + /// Conversion of the `unknown` field failed. + Unknown(hex::HexToBytesError), +} + +impl fmt::Display for PsbtOutputError { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + match *self { + Self::RedeemScript(ref e) => + write_err!(f, "conversion of the `redeem_script` field failed"; e), + Self::WitnessScript(ref e) => + write_err!(f, "conversion of the `witness_script` field failed"; e), + Self::Bip32Derivs(ref e) => + write_err!(f, "conversion of the `bip32_derivs` field failed"; e), + Self::TaprootInternalKey(ref e) => + write_err!(f, "conversion of the `taproot_internal_key` field failed"; e), + Self::TaprootTree(ref e) => + write_err!(f, "conversion of the `taproot_tree` field failed"; e), + Self::TaprootBip32Derivs(ref e) => + write_err!(f, "conversion of the `taproot_bip32_derivs` field failed"; e), + Self::Proprietary(ref e) => + write_err!(f, "conversion of one the map items in the `proprietray` field failed"; e), + Self::Unknown(ref e) => write_err!(f, "conversion of the `unknown` field failed"; e), + } + } +} + +#[cfg(feature = "std")] +impl std::error::Error for PsbtOutputError { + fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { + match *self { + Self::RedeemScript(ref e) => Some(e), + Self::WitnessScript(ref e) => Some(e), + Self::Bip32Derivs(ref e) => Some(e), + Self::TaprootInternalKey(ref e) => Some(e), + Self::TaprootTree(ref e) => Some(e), + Self::TaprootBip32Derivs(ref e) => Some(e), + Self::Proprietary(ref e) => Some(e), + Self::Unknown(ref e) => Some(e), + } + } +} + +/// Error when converting a taproot script path sig. +#[derive(Debug)] +pub enum TaprootScriptPathSigError { + /// Conversion of the `pubkey` field failed. + Pubkey(secp256k1::Error), + /// Conversion of the `leaf_hash` field failed. + LeafHash(hex::HexToArrayError), + /// Conversion of the `sig` field failed. + Sig(super::taproot::Error), +} + +impl fmt::Display for TaprootScriptPathSigError { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + match *self { + Self::Pubkey(ref e) => write_err!(f, "conversion of the `pubkey` field failed"; e), + Self::LeafHash(ref e) => write_err!(f, "conversion of the `leaf_hash` field failed"; e), + Self::Sig(ref e) => write_err!(f, "conversion of the `sig` field failed"; e), + } + } +} + +#[cfg(feature = "std")] +impl std::error::Error for TaprootScriptPathSigError { + fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { + match *self { + Self::Pubkey(ref e) => Some(e), + Self::LeafHash(ref e) => Some(e), + Self::Sig(ref e) => Some(e), + } + } +} + +/// Error when converting a taproot script. +#[derive(Debug)] +pub enum TaprootScriptError { + /// Conversion of the `script` field failed. + Script(hex::HexToBytesError), + /// Conversion of the `leaf_ver` field failed. + LeafVer(TaprootError), + /// Conversion of the `control_blocks` field failed. + ControlBlocks(ControlBlocksError), +} + +impl fmt::Display for TaprootScriptError { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + match *self { + Self::Script(ref e) => write_err!(f, "conversion of the `script` field failed"; e), + Self::LeafVer(ref e) => write_err!(f, "conversion of the `leaf_ver` field failed"; e), + Self::ControlBlocks(ref e) => + write_err!(f, "conversion of the `control_blocks` field failed"; e), + } + } +} + +#[cfg(feature = "std")] +impl std::error::Error for TaprootScriptError { + fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { + match *self { + Self::Script(ref e) => Some(e), + Self::LeafVer(ref e) => Some(e), + Self::ControlBlocks(ref e) => Some(e), + } + } +} + +/// Error when converting the control blocks vector. +#[derive(Debug)] +pub enum ControlBlocksError { + /// No control block returned by Core for this script. + Missing, + /// Multiple control blocks returned by Core for this script. + Multiple(usize), + /// Failed to parse control block hex string. + Parse(hex::HexToBytesError), + /// Failed to decode parsed bytes. + Decode(TaprootError), +} + +impl fmt::Display for ControlBlocksError { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + match *self { + Self::Missing => write!(f, "no control block returned by Core for this script"), + Self::Multiple(n) => + write!(f, "multiple control blocks returned by Core for this script: {}", n), + Self::Parse(ref e) => write_err!(f, "failed to parse control block hex"; e), + Self::Decode(ref e) => write_err!(f, "failed to decode control block from bytes"; e), + } + } +} + +#[cfg(feature = "std")] +impl std::error::Error for ControlBlocksError { + fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { + match *self { + Self::Missing => None, + Self::Multiple(_) => None, + Self::Parse(ref e) => Some(e), + Self::Decode(ref e) => Some(e), + } + } +} + +/// Error when converting a taproot BIP-32 derivation. +#[derive(Debug)] +pub enum TaprootBip32DerivsError { + /// Conversion of the `pubkey` field failed. + Pubkey(secp256k1::Error), + /// Conversion of the `master_fingerprint` field failed. + MasterFingerprint(hex::HexToArrayError), + /// Conversion of the `path` field failed. + Path(bip32::Error), + /// Conversion of one of the leaf hashes failed. + LeafHashes(hex::HexToArrayError), +} + +impl fmt::Display for TaprootBip32DerivsError { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + match *self { + Self::Pubkey(ref e) => write_err!(f, "conversion of the `pubkey` field failed"; e), + Self::MasterFingerprint(ref e) => + write_err!(f, "conversion of the `master_fingerprint` field failed"; e), + Self::Path(ref e) => write_err!(f, "conversion of the `path` field failed"; e), + Self::LeafHashes(ref e) => + write_err!(f, "conversion of the `leaf_hashes` field failed"; e), + } + } +} + +#[cfg(feature = "std")] +impl std::error::Error for TaprootBip32DerivsError { + fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { + match *self { + Self::Pubkey(ref e) => Some(e), + Self::MasterFingerprint(ref e) => Some(e), + Self::Path(ref e) => Some(e), + Self::LeafHashes(ref e) => Some(e), + } + } +} + +/// Error when converting a taproot script. +#[derive(Debug)] +pub enum TaprootLeafError { + /// Conversion of the `leaf_ver` field failed. + LeafVer(TaprootError), + /// Conversion of the `script` field failed. + Script(hex::HexToBytesError), + /// Failed to add leaf to builder. + TaprootBuilder(TaprootBuilderError), + /// Failed to convert builder into a tap tree. + IncompleteBuilder(IncompleteBuilderError), +} + +impl fmt::Display for TaprootLeafError { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + match *self { + Self::LeafVer(ref e) => write_err!(f, "conversion of the `leaf_ver` field failed"; e), + Self::Script(ref e) => write_err!(f, "conversion of the `script` field failed"; e), + Self::TaprootBuilder(ref e) => write_err!(f, "failed to add leaf to builder"; e), + Self::IncompleteBuilder(ref e) => + write_err!(f, "failed to convert builder into a tap tree"; e), + } + } +} + +#[cfg(feature = "std")] +impl std::error::Error for TaprootLeafError { + fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { + match *self { + Self::Script(ref e) => Some(e), + Self::LeafVer(ref e) => Some(e), + Self::TaprootBuilder(ref e) => Some(e), + Self::IncompleteBuilder(ref e) => Some(e), + } + } +} diff --git a/types/src/v30/raw_transactions/into.rs b/types/src/v30/raw_transactions/into.rs new file mode 100644 index 00000000..eef03fdb --- /dev/null +++ b/types/src/v30/raw_transactions/into.rs @@ -0,0 +1,464 @@ +// SPDX-License-Identifier: CC0-1.0 + +use std::collections::BTreeMap; + +use bitcoin::bip32::{DerivationPath, Fingerprint, KeySource, Xpub}; +use bitcoin::hashes::{hash160, ripemd160, sha256, sha256d}; +use bitcoin::hex::{self, FromHex as _}; +use bitcoin::psbt::{self, raw, PsbtSighashType}; +use bitcoin::taproot::{ + ControlBlock, LeafVersion, TapLeafHash, TapNodeHash, TapTree, TaprootBuilder, +}; +use bitcoin::{Amount, ScriptBuf, XOnlyPublicKey}; + +use super::{ + taproot, ControlBlocksError, DecodePsbt, DecodePsbtError, GlobalXpub, GlobalXpubError, + Proprietary, PsbtInput, PsbtInputError, PsbtOutput, PsbtOutputError, TaprootBip32Deriv, + TaprootBip32DerivsError, TaprootLeaf, TaprootLeafError, TaprootScript, TaprootScriptError, + TaprootScriptPathSig, TaprootScriptPathSigError, +}; +use crate::model; + +impl DecodePsbt { + /// Converts version specific type to a version nonspecific, more strongly typed type. + pub fn into_model(self) -> Result { + use DecodePsbtError as E; + + let unsigned_tx = self.tx.to_transaction().map_err(E::Tx)?; + let version = self.psbt_version; + + let mut xpubs = BTreeMap::default(); + for g in self.global_xpubs { + let (xpub, key_source) = g.to_key_value_pair().map_err(E::GlobalXpubs)?; + xpubs.insert(xpub, key_source); + } + + let proprietary = match self.proprietary { + Some(props) => { + let mut map = BTreeMap::default(); + for prop in props { + let (key, vec) = prop.to_key_value_pair().map_err(E::Proprietary)?; + map.insert(key, vec); + } + map + } + None => BTreeMap::default(), + }; + + let unknown = match self.unknown { + Some(map) => crate::psbt::into_unknown(map).map_err(E::Unknown)?, + None => BTreeMap::default(), + }; + + let inputs = self + .inputs + .into_iter() + .map(|input| input.into_input()) + .collect::>() + .map_err(E::Inputs)?; + let outputs = self + .outputs + .into_iter() + .map(|output| output.into_output()) + .collect::>() + .map_err(E::Outputs)?; + + let psbt = bitcoin::Psbt { + unsigned_tx, + version, + xpub: xpubs, + proprietary, + unknown, + inputs, + outputs, + }; + let fee = self.fee.map(Amount::from_sat); + + Ok(model::DecodePsbt { psbt, fee }) + } +} + +impl GlobalXpub { + /// Converts this global xpub list element to a map entry suitable to use in `bitcoin::Psbt`. + pub fn to_key_value_pair(&self) -> Result<(Xpub, KeySource), GlobalXpubError> { + use GlobalXpubError as E; + + let xpub = self.xpub.parse::().map_err(E::Xpub)?; + let fp = Fingerprint::from_hex(&self.master_fingerprint).map_err(E::MasterFingerprint)?; + let path = self.path.parse::().map_err(E::Path)?; + Ok((xpub, (fp, path))) + } +} + +impl Proprietary { + /// Converts this proprietary list element to a map entry suitable to use in `bitcoin::Psbt`. + pub fn to_key_value_pair( + &self, + ) -> Result<(raw::ProprietaryKey, Vec), hex::HexToBytesError> { + // FIXME: Remove cast once rust-bitcoin 0.33 is out. + // + // This is changed to a u64 in the upcoming rust-bitcoin + // release, until then just ignore any additional bits. + let subtype = self.subtype as u8; + + let prefix = Vec::from_hex(&self.identifier)?; + let key = Vec::from_hex(&self.key)?; + let value = Vec::from_hex(&self.value)?; + + Ok((raw::ProprietaryKey { prefix, subtype, key }, value)) + } +} + +impl PsbtInput { + /// Converts this PSBT data into a PSBT input. + pub fn into_input(self) -> Result { + use PsbtInputError as E; + + let non_witness_utxo = self + .non_witness_utxo + .map(|raw| raw.to_transaction()) + .transpose() + .map_err(E::NonWitnessUtxo)?; + let witness_utxo = + self.witness_utxo.map(|utxo| utxo.to_tx_out()).transpose().map_err(E::WitnessUtxo)?; + let partial_sigs = match self.partial_signatures { + Some(map) => crate::psbt::into_partial_signatures(map).map_err(E::PartialSignatures)?, + None => BTreeMap::default(), + }; + let sighash_type = self + .sighash + .map(|partial| partial.parse::()) + .transpose() + .map_err(E::Sighash)?; + let redeem_script = self + .redeem_script + .map(|script| script.script_buf()) + .transpose() + .map_err(E::RedeemScript)?; + let witness_script = self + .witness_script + .map(|script| script.script_buf()) + .transpose() + .map_err(E::WitnessScript)?; + let bip32_derivation = match self.bip32_derivs { + Some(derivs) => + crate::psbt::vec_into_bip32_derivation(derivs).map_err(E::Bip32Derivs)?, + None => BTreeMap::default(), + }; + let final_script_sig = self + .final_script_sig + .map(|script| script.script_buf()) + .transpose() + .map_err(E::FinalScriptSig)?; + let final_script_witness = self + .final_script_witness + .map(|v| crate::witness_from_hex_slice(&v)) + .transpose() + .map_err(E::FinalScriptWitness)?; + + let ripemd160_preimages = match self.ripemd160_preimages { + Some(map) => { + let mut preimages = BTreeMap::default(); + for (hash, preimage) in map.iter() { + let hash = hash.parse::().map_err(E::Ripemd160)?; + let preimage = Vec::from_hex(preimage).map_err(E::Ripemd160Preimage)?; + preimages.insert(hash, preimage); + } + preimages + } + None => BTreeMap::default(), + }; + let sha256_preimages = match self.sha256_preimages { + Some(map) => { + let mut preimages = BTreeMap::default(); + for (hash, preimage) in map.iter() { + let hash = hash.parse::().map_err(E::Sha256)?; + let preimage = Vec::from_hex(preimage).map_err(E::Sha256Preimage)?; + preimages.insert(hash, preimage); + } + preimages + } + None => BTreeMap::default(), + }; + let hash160_preimages = match self.hash160_preimages { + Some(map) => { + let mut preimages = BTreeMap::default(); + for (hash, preimage) in map.iter() { + let hash = hash.parse::().map_err(E::Hash160)?; + let preimage = Vec::from_hex(preimage).map_err(E::Hash160Preimage)?; + preimages.insert(hash, preimage); + } + preimages + } + None => BTreeMap::default(), + }; + let hash256_preimages = match self.hash256_preimages { + Some(map) => { + let mut preimages = BTreeMap::default(); + for (hash, preimage) in map.iter() { + let hash = hash.parse::().map_err(E::Hash256)?; + let preimage = Vec::from_hex(preimage).map_err(E::Hash256Preimage)?; + preimages.insert(hash, preimage); + } + preimages + } + None => BTreeMap::default(), + }; + + let tap_key_sig = self + .taproot_key_path_sig + .map(|s| taproot::signature_from_str(&s)) + .transpose() + .map_err(E::TaprootKeyPathSig)?; + let tap_script_sigs = match self.taproot_script_path_sigs { + Some(vec) => { + let mut map = BTreeMap::default(); + for elem in vec.iter() { + let ((pubkey, hash), sig) = + elem.to_key_value_pair().map_err(E::TaprootScriptPathSigs)?; + map.insert((pubkey, hash), sig); + } + map + } + None => BTreeMap::default(), + }; + let tap_scripts = match self.taproot_scripts { + Some(vec) => { + let mut map = BTreeMap::default(); + for elem in vec.iter() { + let (control_block, (script, key_source)) = + elem.to_key_value_pair().map_err(E::TaprootScripts)?; + map.insert(control_block, (script, key_source)); + } + map + } + None => BTreeMap::default(), + }; + let tap_key_origins = match self.taproot_bip32_derivs { + Some(vec) => { + let mut map = BTreeMap::default(); + for elem in vec.iter() { + let (pubkey, (leaves, key_source)) = + elem.to_key_value_pair().map_err(E::TaprootBip32Derivs)?; + map.insert(pubkey, (leaves, key_source)); + } + map + } + None => BTreeMap::default(), + }; + let tap_internal_key = self + .taproot_internal_key + .map(|key| key.parse::()) + .transpose() + .map_err(E::TaprootInternalKey)?; + let tap_merkle_root = self + .taproot_merkle_root + .map(|root| root.parse::()) + .transpose() + .map_err(E::TaprootMerkleRoot)?; + + let proprietary = match self.proprietary { + Some(props) => { + let mut map = BTreeMap::default(); + for prop in props { + let (key, vec) = prop.to_key_value_pair().map_err(E::Proprietary)?; + map.insert(key, vec); + } + map + } + None => BTreeMap::default(), + }; + + let unknown = match self.unknown { + Some(map) => crate::psbt::into_unknown(map).map_err(E::Unknown)?, + None => BTreeMap::default(), + }; + + Ok(psbt::Input { + non_witness_utxo, + witness_utxo, + partial_sigs, + sighash_type, + redeem_script, + witness_script, + bip32_derivation, + final_script_sig, + final_script_witness, + ripemd160_preimages, + sha256_preimages, + hash160_preimages, + hash256_preimages, + tap_key_sig, + tap_script_sigs, + tap_scripts, + tap_key_origins, + tap_internal_key, + tap_merkle_root, + proprietary, + unknown, + }) + } +} + +impl PsbtOutput { + /// Converts this PSBT data into a PSBT output. + pub fn into_output(self) -> Result { + use PsbtOutputError as E; + + let redeem_script = self + .redeem_script + .map(|script| script.script_buf()) + .transpose() + .map_err(E::RedeemScript)?; + let witness_script = self + .witness_script + .map(|script| script.script_buf()) + .transpose() + .map_err(E::WitnessScript)?; + let bip32_derivation = match self.bip32_derivs { + Some(derivs) => + crate::psbt::vec_into_bip32_derivation(derivs).map_err(E::Bip32Derivs)?, + None => BTreeMap::default(), + }; + + let tap_internal_key = self + .taproot_internal_key + .map(|key| key.parse::()) + .transpose() + .map_err(E::TaprootInternalKey)?; + + let tap_tree = + self.taproot_tree.map(build_taproot_tree).transpose().map_err(E::TaprootTree)?; + let tap_key_origins = match self.taproot_bip32_derivs { + Some(vec) => { + let mut map = BTreeMap::default(); + for elem in vec.iter() { + let (pubkey, (leaves, key_source)) = + elem.to_key_value_pair().map_err(E::TaprootBip32Derivs)?; + map.insert(pubkey, (leaves, key_source)); + } + map + } + None => BTreeMap::default(), + }; + + let proprietary = match self.proprietary { + Some(props) => { + let mut map = BTreeMap::default(); + for prop in props { + let (key, vec) = prop.to_key_value_pair().map_err(E::Proprietary)?; + map.insert(key, vec); + } + map + } + None => BTreeMap::default(), + }; + + let unknown = match self.unknown { + Some(map) => crate::psbt::into_unknown(map).map_err(E::Unknown)?, + None => BTreeMap::default(), + }; + + Ok(psbt::Output { + redeem_script, + witness_script, + bip32_derivation, + tap_internal_key, + tap_tree, + tap_key_origins, + proprietary, + unknown, + }) + } +} + +impl TaprootScriptPathSig { + /// Converts list element to a map entry suitable to use in `bitcoin::psbt::Input`. + pub fn to_key_value_pair( + &self, + ) -> Result<((XOnlyPublicKey, TapLeafHash), taproot::Signature), TaprootScriptPathSigError> + { + use TaprootScriptPathSigError as E; + + let pubkey = self.pubkey.parse::().map_err(E::Pubkey)?; + let hash = self.leaf_hash.parse::().map_err(E::LeafHash)?; + let sig = super::taproot::signature_from_str(&self.sig).map_err(E::Sig)?; + + Ok(((pubkey, hash), sig)) + } +} + +impl TaprootScript { + /// Converts list element to a map entry suitable to use in `bitcoin::psbt::Input`. + pub fn to_key_value_pair( + &self, + ) -> Result<(ControlBlock, (ScriptBuf, LeafVersion)), TaprootScriptError> { + use TaprootScriptError as E; + + let script = ScriptBuf::from_hex(&self.script).map_err(E::Script)?; + + let leaf_version = self.leaf_version as u8; // FIXME: Is this cast ok? + let version = LeafVersion::from_consensus(leaf_version).map_err(E::LeafVer)?; + + let control_block = control_block(&self.control_blocks).map_err(E::ControlBlocks)?; + + Ok((control_block, (script, version))) + } +} + +// FIXME: I (Tobin) cannot work out why Core returns a vector of control blocks. From my +// reading of rust-bitcoin code and also BIP-341 there is exactly one control block per script? +fn control_block(control_blocks: &[String]) -> Result { + use ControlBlocksError as E; + + match control_blocks.len() { + // FIXME: How can this be empty, there would be nothing to key the `tap_scripts` map by? + 0 => Err(E::Missing), + 1 => { + let bytes = Vec::from_hex(&control_blocks[0]).map_err(E::Parse)?; + Ok(ControlBlock::decode(&bytes).map_err(E::Decode)?) + } + n => Err(E::Multiple(n)), + } +} + +impl TaprootBip32Deriv { + /// Converts list element to a map entry suitable to use in `bitcoin::psbt::Input`. + pub fn to_key_value_pair( + &self, + ) -> Result<(XOnlyPublicKey, (Vec, KeySource)), TaprootBip32DerivsError> { + use TaprootBip32DerivsError as E; + + let pubkey = self.pubkey.parse::().map_err(E::Pubkey)?; + let fp = Fingerprint::from_hex(&self.master_fingerprint).map_err(E::MasterFingerprint)?; + let path = self.path.parse::().map_err(E::Path)?; + let hashes = self + .leaf_hashes + .iter() + .map(|leaf| leaf.parse::()) + .collect::>() + .map_err(E::LeafHashes)?; + + Ok((pubkey, (hashes, (fp, path)))) + } +} + +fn build_taproot_tree(leaves: Vec) -> Result { + use TaprootLeafError as E; + + let mut builder = TaprootBuilder::with_capacity(leaves.len()); + + for leaf in leaves.iter() { + // Cast ok because depth can never exceed 128. + let depth = leaf.depth as u8; + + let leaf_version = leaf.leaf_version as u8; // FIXME: Is this cast ok? + let version = LeafVersion::from_consensus(leaf_version).map_err(E::LeafVer)?; + + let script = ScriptBuf::from_hex(&leaf.script).map_err(E::Script)?; + + builder = builder.add_leaf_with_ver(depth, script, version).map_err(E::TaprootBuilder)?; + } + let tree = builder.try_into_taptree().map_err(E::IncompleteBuilder)?; + Ok(tree) +} diff --git a/types/src/v30/raw_transactions/mod.rs b/types/src/v30/raw_transactions/mod.rs new file mode 100644 index 00000000..10e5e58a --- /dev/null +++ b/types/src/v30/raw_transactions/mod.rs @@ -0,0 +1,319 @@ +// SPDX-License-Identifier: CC0-1.0 + +//! The JSON-RPC API for Bitcoin Core `v30` - raw transactions. +//! +//! Types for methods found under the `== Rawtransactions ==` section of the API docs. + +mod error; +mod into; + +use std::collections::HashMap; + +use serde::{Deserialize, Serialize}; + +use crate::ScriptSig; + +#[rustfmt::skip] // Keep public re-exports separate. +pub use self::error::{ + DecodePsbtError, GlobalXpubError, PsbtInputError, PsbtOutputError, TaprootScriptPathSigError, + TaprootScriptError, TaprootBip32DerivsError, ControlBlocksError, TaprootLeafError +}; +// Re-export types that appear in the public API of this module. +pub use super::{Bip32DerivError, PartialSignatureError, RawTransactionError, WitnessUtxoError}; +pub use crate::psbt::{Bip32Deriv, PsbtScript, RawTransaction, WitnessUtxo}; + +/// Result of JSON-RPC method `decodepsbt`. +/// +/// > decodepsbt "psbt" +/// > +/// > Return a JSON object representing the serialized, base64-encoded partially signed Bitcoin transaction. +/// > +/// > Arguments: +/// > 1. "psbt" (string, required) The PSBT base64 string +#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] +#[cfg_attr(feature = "serde-deny-unknown-fields", serde(deny_unknown_fields))] +pub struct DecodePsbt { + /// The decoded network-serialized unsigned transaction. + pub tx: RawTransaction, + /// The global xpubs. + pub global_xpubs: Vec, + /// The PSBT version number. Not to be confused with the unsigned transaction version. + pub psbt_version: u32, + /// The global proprietary map. + pub proprietary: Option>, + /// The unknown global fields. + pub unknown: Option>, + /// Array of transaction inputs. + pub inputs: Vec, + /// Array of transaction outputs. + pub outputs: Vec, + /// The transaction fee paid if all UTXOs slots in the PSBT have been filled. + pub fee: Option, +} + +/// An item from the global xpubs list. Part of `decodepsbt`. +#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] +#[cfg_attr(feature = "serde-deny-unknown-fields", serde(deny_unknown_fields))] +pub struct GlobalXpub { + /// The extended public key this path corresponds to. + pub xpub: String, + /// The fingerprint of the master key. + pub master_fingerprint: String, + /// The path. + pub path: String, +} + +/// An item from the global proprietary list. Part of `decodepsbt`. +#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] +#[cfg_attr(feature = "serde-deny-unknown-fields", serde(deny_unknown_fields))] +pub struct Proprietary { + /// The hex string for the proprietary identifier. + identifier: String, + /// The number for the subtype. + subtype: i64, + /// The hex for the key. + key: String, + /// The hex for the value. + value: String, +} + +/// An input in a partially signed Bitcoin transaction. Part of `decodepsbt`. +/// +/// TODO: Update model once Musig is supported in rust-bitcoin. +#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] +#[cfg_attr(feature = "serde-deny-unknown-fields", serde(deny_unknown_fields))] +pub struct PsbtInput { + /// Decoded network transaction for non-witness UTXOs. + pub non_witness_utxo: Option, + /// Transaction output for witness UTXOs. + pub witness_utxo: Option, + /// The public key and signature that corresponds to it. + pub partial_signatures: Option>, + /// The sighash type to be used. + pub sighash: Option, + /// The redeem script. + pub redeem_script: Option, + /// The witness script. + pub witness_script: Option, + /// The public key with the derivation path as the value. + pub bip32_derivs: Option>, + /// The final scriptsig. + #[serde(rename = "final_scriptsig")] + pub final_script_sig: Option, + /// Hex-encoded witness data (if any). + #[serde(rename = "final_scriptwitness")] + pub final_script_witness: Option>, + /// The hash and preimage that corresponds to it. + pub ripemd160_preimages: Option>, + /// The hash and preimage that corresponds to it. + pub sha256_preimages: Option>, + /// The hash and preimage that corresponds to it. + pub hash160_preimages: Option>, + /// The hash and preimage that corresponds to it. + pub hash256_preimages: Option>, + /// Hex-encoded signature for the Taproot key path spend. + pub taproot_key_path_sig: Option, + /// The signature for the pubkey and leaf hash combination. + pub taproot_script_path_sigs: Option>, + /// Scripts and control blocks for script path spends. + pub taproot_scripts: Option>, + /// BIP-32 derivation paths for keys. + pub taproot_bip32_derivs: Option>, + /// The hex-encoded Taproot x-only internal key. + pub taproot_internal_key: Option, + /// The hex-encoded Taproot merkle root. + pub taproot_merkle_root: Option, + /// MuSig2 participant public keys. + pub musig2_participant_pubkeys: Option>, + /// MuSig2 public nonces. + pub musig2_pubnonces: Option>, + /// MuSig2 partial signatures. + pub musig2_partial_sigs: Option>, + /// The input proprietary map. + pub proprietary: Option>, + /// The unknown input fields. + pub unknown: Option>, +} + +/// An output in a partially signed Bitcoin transaction. Part of `decodepsbt`. +#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] +#[cfg_attr(feature = "serde-deny-unknown-fields", serde(deny_unknown_fields))] +pub struct PsbtOutput { + /// The redeem script. + pub redeem_script: Option, + /// The witness script. + pub witness_script: Option, + /// The public key with the derivation path as the value. + pub bip32_derivs: Option>, + /// The hex-encoded Taproot x-only internal key. + pub taproot_internal_key: Option, + /// The tuples that make up the Taproot tree, in depth first search order. + pub taproot_tree: Option>, + /// BIP32 derivation paths for keys. + pub taproot_bip32_derivs: Option>, + /// MuSig2 participant public keys. + pub musig2_participant_pubkeys: Option>, + /// The output proprietary map. + pub proprietary: Option>, + /// The unknown global fields. + pub unknown: Option>, +} + +/// An item from the `taproot_script_path_sigs` list. Part of `decodepsbt`. +#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] +#[cfg_attr(feature = "serde-deny-unknown-fields", serde(deny_unknown_fields))] +pub struct TaprootScriptPathSig { + /// The x-only pubkey for this signature. + pub pubkey: String, + /// The leaf hash for this signature. + pub leaf_hash: String, + /// The signature itself. + pub sig: String, +} + +/// An item from the `taproot_scripts` list. Part of `decodepsbt`. +#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] +#[cfg_attr(feature = "serde-deny-unknown-fields", serde(deny_unknown_fields))] +pub struct TaprootScript { + /// A leaf script. + pub script: String, + /// The version number for the leaf script. + #[serde(rename = "leaf_ver")] + pub leaf_version: u32, + /// The control blocks for this script. + pub control_blocks: Vec, +} + +/// An item from the `taproot_bip32_derivs` list. Part of `decodepsbt`. +#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] +#[cfg_attr(feature = "serde-deny-unknown-fields", serde(deny_unknown_fields))] +pub struct TaprootBip32Deriv { + /// The x-only public key this path corresponds to. + pub pubkey: String, + /// The fingerprint of the master key. + pub master_fingerprint: String, + /// The path. + pub path: String, + /// The hashes of the leaves this pubkey appears in. + pub leaf_hashes: Vec, +} + +/// A Taproot leaf script at depth with version. Part of `decodepsbt`. +#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] +#[cfg_attr(feature = "serde-deny-unknown-fields", serde(deny_unknown_fields))] +pub struct TaprootLeaf { + /// The depth of this element in the tree. + pub depth: u32, + /// The version of this leaf. + #[serde(rename = "leaf_ver")] + pub leaf_version: u32, + /// The hex-encoded script itself. + pub script: String, +} + +/// MuSig2 participant public keys. Part of `decodepsbt`. +#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] +#[cfg_attr(feature = "serde-deny-unknown-fields", serde(deny_unknown_fields))] +pub struct Musig2ParticipantPubkeys { + /// The compressed aggregate public key for which the participants create. + pub aggregate_pubkey: String, + /// The compressed public keys that are aggregated for aggregate_pubkey. + pub participant_pubkeys: Vec, +} + +/// MuSig2 public nonce. Part of `decodepsbt`. +#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] +#[cfg_attr(feature = "serde-deny-unknown-fields", serde(deny_unknown_fields))] +pub struct Musig2Pubnonce { + /// The compressed public key of the participant that created this pubnonce. + pub participant_pubkey: String, + /// The compressed aggregate public key for which this pubnonce is for. + pub aggregate_pubkey: String, + /// The hash of the leaf script that contains the aggregate pubkey being signed for. Omitted when signing for the internal key. + pub leaf_hash: Option, + /// The public nonce itself. + pub pubnonce: String, +} + +/// MuSig2 partial signature. Part of `decodepsbt`. +#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] +#[cfg_attr(feature = "serde-deny-unknown-fields", serde(deny_unknown_fields))] +pub struct Musig2PartialSig { + /// The compressed public key of the participant that created this partial signature. + pub participant_pubkey: String, + /// The compressed aggregate public key for which this partial signature is for. + pub aggregate_pubkey: String, + /// The hash of the leaf script that contains the aggregate pubkey being signed for. Omitted when signing for the internal key. + pub leaf_hash: Option, + /// The partial signature itself. + pub partial_sig: String, +} + +// TODO: Remove all this code once it is implemented and backported to 0.32.x +// https://github.com/rust-bitcoin/rust-bitcoin/issues/3285 +pub mod taproot { + use core::fmt; + + use bitcoin::hex::{self, FromHex as _}; + use bitcoin::sighash::InvalidSighashTypeError; + // Re-export this because this module is named the same as the one from `bitcoin`. + pub use bitcoin::taproot::Signature; + use bitcoin::{secp256k1, taproot, TapSighashType}; + + use crate::error::write_err; + + /// Parses a Taproot signature from a hex string. + pub fn signature_from_str(sig: &str) -> Result { + use Error as E; + + let bytes = Vec::from_hex(sig).map_err(E::Hex)?; + let (sighash_byte, signature) = bytes.split_last().ok_or(E::EmptySignature)?; + Ok(Signature { + signature: secp256k1::schnorr::Signature::from_slice(signature) + .map_err(E::Secp256k1)?, + sighash_type: TapSighashType::from_consensus_u8(*sighash_byte) + .map_err(E::SighashType)?, + }) + } + + /// A Taproot signature-related error. + #[derive(Debug, Clone, PartialEq, Eq)] + #[non_exhaustive] + pub enum Error { + /// Hex decoding error. + Hex(hex::HexToBytesError), + /// Non-standard sighash type. + SighashType(InvalidSighashTypeError), + /// Signature was empty. + EmptySignature, + /// A secp256k1 error while creating signature from a slice. + Secp256k1(secp256k1::Error), + } + + impl fmt::Display for Error { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + use Error::*; + + match *self { + Hex(ref e) => write_err!(f, "signature hex decoding error"; e), + SighashType(ref e) => write_err!(f, "non-standard signature hash type"; e), + EmptySignature => write!(f, "empty Taproot signature"), + Secp256k1(ref e) => write_err!(f, "secp256k1"; e), + } + } + } + + #[cfg(feature = "std")] + impl std::error::Error for Error { + fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { + use Error::*; + + match *self { + Hex(ref e) => Some(e), + Secp256k1(ref e) => Some(e), + SighashType(ref e) => Some(e), + EmptySignature => None, + } + } + } +}