diff --git a/types/src/v26/get_prioritised_transactions.rs b/types/src/v26/get_prioritised_transactions.rs deleted file mode 100644 index 8b137891..00000000 --- a/types/src/v26/get_prioritised_transactions.rs +++ /dev/null @@ -1 +0,0 @@ - diff --git a/types/src/v29/mining/error.rs b/types/src/v29/mining/error.rs index 5dc09cd0..efb406de 100644 --- a/types/src/v29/mining/error.rs +++ b/types/src/v29/mining/error.rs @@ -2,60 +2,9 @@ use core::fmt; -use bitcoin::amount::ParseAmountError; use bitcoin::error::UnprefixedHexError; -use bitcoin::{consensus, hex}; use crate::error::write_err; -use crate::NumericError; - -/// Error when converting a `BlockTemplateTransaction` type into the model type. -#[derive(Debug)] -pub enum BlockTemplateTransactionError { - /// Conversion of numeric type to expected type failed. - Numeric(NumericError), - /// Conversion of the `data` field failed. - Data(consensus::encode::FromHexError), - /// Conversion of the `txid` field failed. - Txid(hex::HexToArrayError), - /// Conversion of the `hash` field failed. - Hash(hex::HexToArrayError), - /// Conversion of the `fee` field failed. - Fee(ParseAmountError), -} - -impl fmt::Display for BlockTemplateTransactionError { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - use BlockTemplateTransactionError as E; - - match *self { - E::Numeric(ref e) => write_err!(f, "numeric"; e), - E::Data(ref e) => write_err!(f, "conversion of the `data` field failed"; e), - E::Txid(ref e) => write_err!(f, "conversion of the `txid` field failed"; e), - E::Hash(ref e) => write_err!(f, "conversion of the `hash` field failed"; e), - E::Fee(ref e) => write_err!(f, "conversion of the `fee` field failed"; e), - } - } -} - -#[cfg(feature = "std")] -impl std::error::Error for BlockTemplateTransactionError { - fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { - use BlockTemplateTransactionError as E; - - match *self { - E::Numeric(ref e) => Some(e), - E::Data(ref e) => Some(e), - E::Txid(ref e) => Some(e), - E::Hash(ref e) => Some(e), - E::Fee(ref e) => Some(e), - } - } -} - -impl From for BlockTemplateTransactionError { - fn from(e: NumericError) -> Self { Self::Numeric(e) } -} /// Error when converting a `GetMiningInfo` type into the model type. #[derive(Debug)] diff --git a/types/src/v29/mining/into.rs b/types/src/v29/mining/into.rs index 41374948..7a3d0882 100644 --- a/types/src/v29/mining/into.rs +++ b/types/src/v29/mining/into.rs @@ -1,37 +1,10 @@ // SPDX-License-Identifier: CC0-1.0 -use bitcoin::{consensus, CompactTarget, SignedAmount, Target, Transaction, Txid, Weight, Wtxid}; +use bitcoin::{CompactTarget, Target, Weight}; -use super::{ - BlockTemplateTransaction, BlockTemplateTransactionError, GetMiningInfo, GetMiningInfoError, - NextBlockInfo, NextBlockInfoError, -}; +use super::{GetMiningInfo, GetMiningInfoError, NextBlockInfo, NextBlockInfoError}; use crate::model; -impl BlockTemplateTransaction { - /// Converts version specific type to a version nonspecific, more strongly typed type. - pub fn into_model( - self, - ) -> Result { - use BlockTemplateTransactionError as E; - - let data = - consensus::encode::deserialize_hex::(&self.data).map_err(E::Data)?; - let txid = self.txid.parse::().map_err(E::Txid)?; - let wtxid = self.hash.parse::().map_err(E::Hash)?; - let depends = self - .depends - .iter() - .map(|x| crate::to_u32(*x, "depend")) - .collect::, _>>()?; - let fee = SignedAmount::from_sat(self.fee); - let sigops = crate::to_u32(self.sigops, "sigops")?; - let weight = Weight::from_wu(self.weight); // FIXME: Is this the correct unit? - - Ok(model::BlockTemplateTransaction { data, txid, wtxid, depends, fee, sigops, weight }) - } -} - impl GetMiningInfo { /// Converts version specific type to a version nonspecific, more strongly typed type. pub fn into_model(self) -> Result { diff --git a/types/src/v29/mining/mod.rs b/types/src/v29/mining/mod.rs index cea378b8..76c81611 100644 --- a/types/src/v29/mining/mod.rs +++ b/types/src/v29/mining/mod.rs @@ -9,35 +9,7 @@ mod into; use serde::{Deserialize, Serialize}; -pub use self::error::{BlockTemplateTransactionError, GetMiningInfoError, NextBlockInfoError}; - -/// Contents of non-coinbase transactions that should be included in the next block. -/// -/// Returned as part of `getblocktemplate`. -#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] -#[serde(deny_unknown_fields)] -pub struct BlockTemplateTransaction { - /// Transaction data encoded in hexadecimal (byte-for-byte). - pub data: String, - /// Transaction id encoded in little-endian hexadecimal. - pub txid: String, - /// Hash encoded in little-endian hexadecimal (including witness data). - pub hash: String, - /// Array of numbers. - /// - /// Transactions before this one (by 1-based index in 'transactions' list) that must be present in the final block if this one is. - pub depends: Vec, - /// Difference in value between transaction inputs and outputs (in satoshis); for coinbase - /// transactions, this is a negative Number of the total collected block fees (ie, not including - /// the block subsidy); if key is not present, fee is unknown and clients MUST NOT assume there - /// isn't one. - pub fee: i64, - /// Total SigOps cost, as counted for purposes of block limits; if key is not present, sigop - /// cost is unknown and clients MUST NOT assume it is zero. - pub sigops: i64, - /// Total transaction weight, as counted for purposes of block limits. - pub weight: u64, -} +pub use self::error::{GetMiningInfoError, NextBlockInfoError}; /// Result of the JSON-RPC method `getmininginfo`. /// diff --git a/types/src/v29/mod.rs b/types/src/v29/mod.rs index 80cf7beb..6932a9aa 100644 --- a/types/src/v29/mod.rs +++ b/types/src/v29/mod.rs @@ -264,10 +264,7 @@ pub use self::{ GetBlockchainInfoError, GetChainStates, GetChainStatesError, GetDescriptorActivity, GetDescriptorActivityError, ReceiveActivity, SpendActivity, }, - mining::{ - BlockTemplateTransaction, GetMiningInfo, GetMiningInfoError, NextBlockInfo, - NextBlockInfoError, - }, + mining::{GetMiningInfo, GetMiningInfoError, NextBlockInfo, NextBlockInfoError}, raw_transactions::{MempoolAcceptance, TestMempoolAccept}, util::{DeriveAddressesMultipath, GetDescriptorInfo}, };