Skip to content

Commit 188d114

Browse files
authored
Merge pull request #107 from tcharding/03-19-hack
Just for fun
2 parents 79efa7f + 9d15d75 commit 188d114

File tree

18 files changed

+86
-70
lines changed

18 files changed

+86
-70
lines changed

integration_test/tests/generating.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,16 @@
44
55
use integration_test::{Node, NodeExt as _, Wallet};
66

7+
#[test]
8+
// The `generate` method deprecated in Core v18 and was removed in v19.
9+
#[cfg(feature = "v17")]
10+
fn generate() {
11+
const NBLOCKS: usize = 10;
12+
13+
let node = Node::with_wallet(Wallet::Default, &[]);
14+
let _ = node.client.generate(NBLOCKS).expect("generate");
15+
}
16+
717
#[test]
818
fn generate_to_address() {
919
const NBLOCKS: usize = 1;

types/src/model/blockchain.rs

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -408,20 +408,15 @@ pub struct MempoolEntry {
408408
pub struct MempoolEntryFees {
409409
/// Transaction fee in BTC.
410410
pub base: Amount,
411-
/// Transaction fee with fee deltas used for mining priority in BTC.
411+
/// Transaction fee with fee deltas used for mining priority.
412412
pub modified: Amount,
413-
/// Modified fees (see above) of in-mempool ancestors (including this one) in BTC
413+
/// Modified fees (see above) of in-mempool ancestors (including this one).
414414
pub ancestor: Amount,
415-
/// Modified fees (see above) of in-mempool descendants (including this one) in BTC.
415+
/// Modified fees (see above) of in-mempool descendants (including this one).
416416
pub descendant: Amount,
417417
}
418418

419-
/// Models the result of JSON-RPC method `getmempooldescendants` with verbose set to true.
420-
/// Result of JSON-RPC method `getmempoolinfo` with verbose set to true
421-
///
422-
/// > getmempoolinfo
423-
/// >
424-
/// > Returns details on the active state of the TX memory pool.
419+
/// Models the result of JSON-RPC method `getmempoolinfo` with verbose set to true.
425420
#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)]
426421
pub struct GetMempoolInfo {
427422
/// Current transaction count.

types/src/v17/blockchain/error.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ impl fmt::Display for GetBlockVerbosityOneError {
3838
Hash(ref e) => write_err!(f, "conversion of the `hash` field failed"; e),
3939
Tx(ref e) => write_err!(f, "conversion of the `tx` field failed"; e),
4040
Bits(ref e) => write_err!(f, "conversion of the `bits` field failed"; e),
41-
ChainWork(ref e) => write_err!(f, "conversion of the `chain_ork` field failed"; e),
41+
ChainWork(ref e) => write_err!(f, "conversion of the `chain_work` field failed"; e),
4242
PreviousBlockHash(ref e) =>
4343
write_err!(f, "conversion of the `previous_block_hash` field failed"; e),
4444
NextBlockHash(ref e) =>
@@ -172,7 +172,7 @@ impl fmt::Display for GetBlockHeaderVerboseError {
172172
Numeric(ref e) => write_err!(f, "numeric"; e),
173173
Hash(ref e) => write_err!(f, "conversion of the `hash` field failed"; e),
174174
MerkleRoot(ref e) => write_err!(f, "conversion of the `merkle_root` field failed"; e),
175-
Bits(ref e) => write_err!(f, "conversion of the `bit` field failed"; e),
175+
Bits(ref e) => write_err!(f, "conversion of the `bits` field failed"; e),
176176
ChainWork(ref e) => write_err!(f, "conversion of the `chain_work` field failed"; e),
177177
PreviousBlockHash(ref e) =>
178178
write_err!(f, "conversion of the `previous_bock_hash` field failed"; e),
@@ -344,7 +344,7 @@ impl std::error::Error for MapMempoolEntryError {
344344
}
345345
}
346346

347-
/// Error when converting a `Mem` type into the model type.
347+
/// Error when converting a `MempoolEntry` type into the model type.
348348
#[derive(Debug)]
349349
pub enum MempoolEntryError {
350350
/// Conversion of numeric type to expected type failed.
@@ -392,15 +392,15 @@ impl std::error::Error for MempoolEntryError {
392392
}
393393
}
394394

395-
/// Error when converting a `MempoolEntryFeesError` type into the model type.
395+
/// Error when converting a `MempoolEntryFees` type into the model type.
396396
#[derive(Debug)]
397397
pub enum MempoolEntryFeesError {
398398
/// Conversion of the `base` field failed.
399399
Base(ParseAmountError),
400400
/// Conversion of the `modified` field failed.
401401
Modified(ParseAmountError),
402402
/// Conversion of the `ancestor` field failed.
403-
MempoolEntry(ParseAmountError),
403+
Ancestor(ParseAmountError),
404404
/// Conversion of the `descendant` field failed.
405405
Descendant(ParseAmountError),
406406
}
@@ -412,7 +412,7 @@ impl fmt::Display for MempoolEntryFeesError {
412412
match *self {
413413
E::Base(ref e) => write_err!(f, "conversion of the `base` field failed"; e),
414414
E::Modified(ref e) => write_err!(f, "conversion of the `modified` field failed"; e),
415-
E::MempoolEntry(ref e) => write_err!(f, "conversion of the `ancestor` field failed"; e),
415+
E::Ancestor(ref e) => write_err!(f, "conversion of the `ancestor` field failed"; e),
416416
E::Descendant(ref e) => write_err!(f, "conversion of the `descendant` field failed"; e),
417417
}
418418
}
@@ -426,7 +426,7 @@ impl std::error::Error for MempoolEntryFeesError {
426426
match *self {
427427
E::Base(ref e) => Some(e),
428428
E::Modified(ref e) => Some(e),
429-
E::MempoolEntry(ref e) => Some(e),
429+
E::Ancestor(ref e) => Some(e),
430430
E::Descendant(ref e) => Some(e),
431431
}
432432
}
@@ -521,7 +521,7 @@ impl From<NumericError> for GetTxOutError {
521521
fn from(e: NumericError) -> Self { Self::Numeric(e) }
522522
}
523523

524-
/// Error when converting a `GetTxOut` type into the model type.
524+
/// Error when converting a `GetTxOutSetInfo` type into the model type.
525525
#[derive(Debug)]
526526
pub enum GetTxOutSetInfoError {
527527
/// Conversion of numeric type to expected type failed.
@@ -538,7 +538,7 @@ impl fmt::Display for GetTxOutSetInfoError {
538538

539539
match *self {
540540
Numeric(ref e) => write_err!(f, "numeric"; e),
541-
BestBlock(ref e) => write_err!(f, "conversion of the `beast_block` field failed"; e),
541+
BestBlock(ref e) => write_err!(f, "conversion of the `best_block` field failed"; e),
542542
TotalAmount(ref e) => write_err!(f, "conversion of the `total_amount` field failed"; e),
543543
}
544544
}

types/src/v17/blockchain/into.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -372,6 +372,13 @@ impl GetMempoolDescendantsVerbose {
372372
}
373373
}
374374

375+
impl GetMempoolEntry {
376+
/// Converts version specific type to a version nonspecific, more strongly typed type.
377+
pub fn into_model(self) -> Result<model::GetMempoolEntry, MempoolEntryError> {
378+
Ok(model::GetMempoolEntry(self.0.into_model()?))
379+
}
380+
}
381+
375382
impl MempoolEntry {
376383
/// Converts version specific type to a version nonspecific, more strongly typed type.
377384
pub fn into_model(self) -> Result<model::MempoolEntry, MempoolEntryError> {
@@ -425,7 +432,7 @@ impl MempoolEntryFees {
425432
Ok(model::MempoolEntryFees {
426433
base: Amount::from_btc(self.base).map_err(E::Base)?,
427434
modified: Amount::from_btc(self.modified).map_err(E::Modified)?,
428-
ancestor: Amount::from_btc(self.ancestor).map_err(E::MempoolEntry)?,
435+
ancestor: Amount::from_btc(self.ancestor).map_err(E::Ancestor)?,
429436
descendant: Amount::from_btc(self.descendant).map_err(E::Descendant)?,
430437
})
431438
}

types/src/v17/blockchain/mod.rs

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,21 @@ pub struct GetBestBlockHash(pub String);
2727

2828
/// Result of JSON-RPC method `getblock` with verbosity set to 0.
2929
///
30-
/// A string that is serialized, hex-encoded data for block 'hash'.
30+
/// > getblock "blockhash" ( verbosity )
31+
/// >
32+
/// > If verbosity is 0, returns a string that is serialized, hex-encoded data for block 'hash'.
33+
/// > If verbosity is 1, returns an Object with information about block `<hash>`.
34+
/// > If verbosity is 2, returns an Object with information about block `<hash>` and information about each transaction.
35+
/// >
36+
/// > Arguments:
37+
/// > 1. "blockhash" (string, required) The block hash
38+
/// > 2. verbosity (numeric, optional, default=1) 0 for hex encoded data, 1 for a json object, and 2 for json object with transaction data
3139
#[derive(Clone, PartialEq, Debug, Deserialize, Serialize)]
3240
// TODO: Consider renaming this to `GetBlcokVerboseZero`.
33-
pub struct GetBlockVerbosityZero(pub String);
41+
pub struct GetBlockVerbosityZero(
42+
/// A string that is serialized, hex-encoded data for block 'hash'.
43+
pub String,
44+
);
3445

3546
/// Result of JSON-RPC method `getblock` with verbosity set to 1.
3647
#[derive(Clone, PartialEq, Debug, Deserialize, Serialize)]
@@ -85,8 +96,8 @@ pub struct GetBlockVerbosityOne {
8596

8697
/// Result of JSON-RPC method `getblockchaininfo`.
8798
///
88-
/// Method call: `getblockchaininfo`
89-
///
99+
/// > getblockchaininfo
100+
/// >
90101
/// > Returns an object containing various state info regarding blockchain processing.
91102
#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)]
92103
pub struct GetBlockchainInfo {
@@ -136,18 +147,18 @@ pub struct GetBlockchainInfo {
136147
#[derive(Clone, Debug, PartialEq, Eq, Deserialize, Serialize)]
137148
pub struct Softfork {
138149
/// Name of softfork.
139-
id: String,
150+
pub id: String,
140151
/// Block version.
141-
version: i64,
152+
pub version: i64,
142153
/// Progress toward rejecting pre-softfork blocks.
143-
reject: SoftforkReject,
154+
pub reject: SoftforkReject,
144155
}
145156

146157
/// Progress toward rejecting pre-softfork blocks.
147158
#[derive(Clone, Debug, PartialEq, Eq, Deserialize, Serialize)]
148159
pub struct SoftforkReject {
149160
/// `true` if threshold reached.
150-
status: bool,
161+
pub status: bool,
151162
}
152163

153164
/// Status of BIP-9 softforksin progress.
@@ -185,15 +196,15 @@ pub enum Bip9SoftforkStatus {
185196
/// Result of JSON-RPC method `getblockcount`.
186197
///
187198
/// > getblockcount
188-
///
199+
/// >
189200
/// > Returns the number of blocks in the longest blockchain.
190201
#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)]
191202
pub struct GetBlockCount(pub u64);
192203

193204
/// Result of JSON-RPC method `getblockhash`.
194205
///
195206
/// > Returns hash of block in best-block-chain at height provided.
196-
///
207+
/// >
197208
/// > Arguments:
198209
/// > 1. height (numeric, required) The height index
199210
#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)]
@@ -472,13 +483,6 @@ pub struct GetMempoolDescendantsVerbose(pub BTreeMap<String, MempoolEntry>);
472483
#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)]
473484
pub struct GetMempoolEntry(pub MempoolEntry);
474485

475-
impl GetMempoolEntry {
476-
/// Converts version specific type to a version nonspecific, more strongly typed type.
477-
pub fn into_model(self) -> Result<model::GetMempoolEntry, MempoolEntryError> {
478-
Ok(model::GetMempoolEntry(self.0.into_model()?))
479-
}
480-
}
481-
482486
/// A relative (ancestor or descendant) transaction of a transaction in the mempool.
483487
#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)]
484488
pub struct MempoolEntry {

types/src/v17/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@
6262
//!
6363
//! | JSON-PRC Method Name | Status |
6464
//! |:-----------------------------------|:---------------:|
65-
//! | generate | done (untested) |
65+
//! | generate | done |
6666
//! | generatetoaddress | done |
6767
//!
6868
//! </details>

types/src/v18/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@
6868
//!
6969
//! | JSON-PRC Method Name | Status |
7070
//! |:-----------------------------------|:---------------:|
71-
//! | generate | done (untested) |
71+
//! | generate | omitted |
7272
//! | generatetoaddress | done |
7373
//!
7474
//! </details>

types/src/v19/blockchain/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ pub use self::error::*;
1616

1717
/// Result of JSON-RPC method `getblockchaininfo`.
1818
///
19-
/// Method call: `getblockchaininfo`
20-
///
19+
/// > getblockchaininfo
20+
/// >
2121
/// > Returns an object containing various state info regarding blockchain processing.
2222
#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)]
2323
pub struct GetBlockchainInfo {

types/src/v19/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,10 @@
5252
//! |:-----------------------------------|:---------------:|
5353
//! | getmemoryinfo | done |
5454
//! | getrpcinfo | done |
55-
//! | help | omitted |
55+
//! | help | done |
5656
//! | logging | done |
57-
//! | stop | omitted |
58-
//! | uptime | omitted |
57+
//! | stop | done |
58+
//! | uptime | done |
5959
//!
6060
//! </details>
6161
//!

types/src/v20/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,10 @@
5252
//! |:-----------------------------------|:---------------:|
5353
//! | getmemoryinfo | done |
5454
//! | getrpcinfo | done |
55-
//! | help | omitted |
55+
//! | help | done |
5656
//! | logging | done |
57-
//! | stop | omitted |
58-
//! | uptime | omitted |
57+
//! | stop | done |
58+
//! | uptime | done |
5959
//!
6060
//! </details>
6161
//!

0 commit comments

Comments
 (0)