Skip to content

Commit 2ddf47c

Browse files
committed
Merge #354: Remove BlockTemplateTransaction from v29
e85b1bf Remove BlockTemplateTransaction from v29 (Jamil Lambert, PhD) da52d8f Remove empty file (Jamil Lambert, PhD) Pull request description: Why is it even there? it's not even an RPC, it's the `transactions` field of `GetBlockTemplate` which hasn't changed since v17. Remove it. Also remove an empty file left over from a previous change. ACKs for top commit: tcharding: ACK e85b1bf Tree-SHA512: dd574a99ca5488d75a42dc83920446188668a47d7ab88f830f8b655cbe190c70413558274a95c27d53e95057029990e7b1c1c89f40cb0f371c5bccabd3bb1efa
2 parents d3126b0 + e85b1bf commit 2ddf47c

File tree

5 files changed

+4
-114
lines changed

5 files changed

+4
-114
lines changed

types/src/v26/get_prioritised_transactions.rs

Lines changed: 0 additions & 1 deletion
This file was deleted.

types/src/v29/mining/error.rs

Lines changed: 0 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -2,60 +2,9 @@
22

33
use core::fmt;
44

5-
use bitcoin::amount::ParseAmountError;
65
use bitcoin::error::UnprefixedHexError;
7-
use bitcoin::{consensus, hex};
86

97
use crate::error::write_err;
10-
use crate::NumericError;
11-
12-
/// Error when converting a `BlockTemplateTransaction` type into the model type.
13-
#[derive(Debug)]
14-
pub enum BlockTemplateTransactionError {
15-
/// Conversion of numeric type to expected type failed.
16-
Numeric(NumericError),
17-
/// Conversion of the `data` field failed.
18-
Data(consensus::encode::FromHexError),
19-
/// Conversion of the `txid` field failed.
20-
Txid(hex::HexToArrayError),
21-
/// Conversion of the `hash` field failed.
22-
Hash(hex::HexToArrayError),
23-
/// Conversion of the `fee` field failed.
24-
Fee(ParseAmountError),
25-
}
26-
27-
impl fmt::Display for BlockTemplateTransactionError {
28-
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
29-
use BlockTemplateTransactionError as E;
30-
31-
match *self {
32-
E::Numeric(ref e) => write_err!(f, "numeric"; e),
33-
E::Data(ref e) => write_err!(f, "conversion of the `data` field failed"; e),
34-
E::Txid(ref e) => write_err!(f, "conversion of the `txid` field failed"; e),
35-
E::Hash(ref e) => write_err!(f, "conversion of the `hash` field failed"; e),
36-
E::Fee(ref e) => write_err!(f, "conversion of the `fee` field failed"; e),
37-
}
38-
}
39-
}
40-
41-
#[cfg(feature = "std")]
42-
impl std::error::Error for BlockTemplateTransactionError {
43-
fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
44-
use BlockTemplateTransactionError as E;
45-
46-
match *self {
47-
E::Numeric(ref e) => Some(e),
48-
E::Data(ref e) => Some(e),
49-
E::Txid(ref e) => Some(e),
50-
E::Hash(ref e) => Some(e),
51-
E::Fee(ref e) => Some(e),
52-
}
53-
}
54-
}
55-
56-
impl From<NumericError> for BlockTemplateTransactionError {
57-
fn from(e: NumericError) -> Self { Self::Numeric(e) }
58-
}
598

609
/// Error when converting a `GetMiningInfo` type into the model type.
6110
#[derive(Debug)]

types/src/v29/mining/into.rs

Lines changed: 2 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,10 @@
11
// SPDX-License-Identifier: CC0-1.0
22

3-
use bitcoin::{consensus, CompactTarget, SignedAmount, Target, Transaction, Txid, Weight, Wtxid};
3+
use bitcoin::{CompactTarget, Target, Weight};
44

5-
use super::{
6-
BlockTemplateTransaction, BlockTemplateTransactionError, GetMiningInfo, GetMiningInfoError,
7-
NextBlockInfo, NextBlockInfoError,
8-
};
5+
use super::{GetMiningInfo, GetMiningInfoError, NextBlockInfo, NextBlockInfoError};
96
use crate::model;
107

11-
impl BlockTemplateTransaction {
12-
/// Converts version specific type to a version nonspecific, more strongly typed type.
13-
pub fn into_model(
14-
self,
15-
) -> Result<model::BlockTemplateTransaction, BlockTemplateTransactionError> {
16-
use BlockTemplateTransactionError as E;
17-
18-
let data =
19-
consensus::encode::deserialize_hex::<Transaction>(&self.data).map_err(E::Data)?;
20-
let txid = self.txid.parse::<Txid>().map_err(E::Txid)?;
21-
let wtxid = self.hash.parse::<Wtxid>().map_err(E::Hash)?;
22-
let depends = self
23-
.depends
24-
.iter()
25-
.map(|x| crate::to_u32(*x, "depend"))
26-
.collect::<Result<Vec<_>, _>>()?;
27-
let fee = SignedAmount::from_sat(self.fee);
28-
let sigops = crate::to_u32(self.sigops, "sigops")?;
29-
let weight = Weight::from_wu(self.weight); // FIXME: Is this the correct unit?
30-
31-
Ok(model::BlockTemplateTransaction { data, txid, wtxid, depends, fee, sigops, weight })
32-
}
33-
}
34-
358
impl GetMiningInfo {
369
/// Converts version specific type to a version nonspecific, more strongly typed type.
3710
pub fn into_model(self) -> Result<model::GetMiningInfo, GetMiningInfoError> {

types/src/v29/mining/mod.rs

Lines changed: 1 addition & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -9,35 +9,7 @@ mod into;
99

1010
use serde::{Deserialize, Serialize};
1111

12-
pub use self::error::{BlockTemplateTransactionError, GetMiningInfoError, NextBlockInfoError};
13-
14-
/// Contents of non-coinbase transactions that should be included in the next block.
15-
///
16-
/// Returned as part of `getblocktemplate`.
17-
#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)]
18-
#[serde(deny_unknown_fields)]
19-
pub struct BlockTemplateTransaction {
20-
/// Transaction data encoded in hexadecimal (byte-for-byte).
21-
pub data: String,
22-
/// Transaction id encoded in little-endian hexadecimal.
23-
pub txid: String,
24-
/// Hash encoded in little-endian hexadecimal (including witness data).
25-
pub hash: String,
26-
/// Array of numbers.
27-
///
28-
/// Transactions before this one (by 1-based index in 'transactions' list) that must be present in the final block if this one is.
29-
pub depends: Vec<i64>,
30-
/// Difference in value between transaction inputs and outputs (in satoshis); for coinbase
31-
/// transactions, this is a negative Number of the total collected block fees (ie, not including
32-
/// the block subsidy); if key is not present, fee is unknown and clients MUST NOT assume there
33-
/// isn't one.
34-
pub fee: i64,
35-
/// Total SigOps cost, as counted for purposes of block limits; if key is not present, sigop
36-
/// cost is unknown and clients MUST NOT assume it is zero.
37-
pub sigops: i64,
38-
/// Total transaction weight, as counted for purposes of block limits.
39-
pub weight: u64,
40-
}
12+
pub use self::error::{GetMiningInfoError, NextBlockInfoError};
4113

4214
/// Result of the JSON-RPC method `getmininginfo`.
4315
///

types/src/v29/mod.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -264,10 +264,7 @@ pub use self::{
264264
GetBlockchainInfoError, GetChainStates, GetChainStatesError, GetDescriptorActivity,
265265
GetDescriptorActivityError, ReceiveActivity, SpendActivity,
266266
},
267-
mining::{
268-
BlockTemplateTransaction, GetMiningInfo, GetMiningInfoError, NextBlockInfo,
269-
NextBlockInfoError,
270-
},
267+
mining::{GetMiningInfo, GetMiningInfoError, NextBlockInfo, NextBlockInfoError},
271268
raw_transactions::{MempoolAcceptance, TestMempoolAccept},
272269
util::{DeriveAddressesMultipath, GetDescriptorInfo},
273270
};

0 commit comments

Comments
 (0)