Skip to content

Commit 40810ad

Browse files
committed
Fix up v29 support
This repo is pretty hard to work on. Gideon made a good effort at adding v29 support, I decided to help out and push it over the line.
1 parent 72a7c10 commit 40810ad

File tree

19 files changed

+307
-247
lines changed

19 files changed

+307
-247
lines changed

.github/workflows/rust.yaml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -217,8 +217,6 @@ jobs:
217217
"27_1",
218218
"27_0",
219219
"26_2",
220-
"26_1",
221-
"26_0",
222220
"25_2",
223221
"24_2",
224222
"23_2",

client/src/client_sync/v29/blockchain.rs

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,11 @@
1414
macro_rules! impl_client_v29__getdescriptoractivity {
1515
() => {
1616
impl Client {
17-
pub fn get_descriptor_activity(
18-
&self,
19-
blockhashes: &[BlockHash],
20-
scan_objects: &[&str],
21-
include_mempool: bool,
22-
) -> Result<GetDescriptorActivity> {
23-
let blockhashes_val = json!(blockhashes);
24-
let scan_objects_val = json!(scan_objects);
25-
let include_mempool_val = json!(include_mempool);
26-
27-
let params = vec![blockhashes_val, scan_objects_val, include_mempool_val];
28-
17+
pub fn get_descriptor_activity(&self) -> Result<GetDescriptorActivity> {
18+
let block_hashes: &[BlockHash] = &[];
19+
let scan_objects: &[&str] = &[];
20+
// FIXME: Core errors if we don't pass empty arrays?
21+
let params = vec![json!(block_hashes), json!(scan_objects)];
2922
self.call("getdescriptoractivity", &params)
3023
}
3124
}

client/src/client_sync/v29/mod.rs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -141,20 +141,6 @@ crate::impl_client_v21__unloadwallet!();
141141
crate::impl_client_v17__walletcreatefundedpsbt!();
142142
crate::impl_client_v17__walletprocesspsbt!();
143143

144-
/// Client side supported softfork deployment.
145-
#[derive(Copy, Clone, PartialEq, Eq, Debug, Deserialize, Serialize)]
146-
#[serde(rename_all = "lowercase")]
147-
pub enum TemplateRules {
148-
/// SegWit v0 supported.
149-
Segwit,
150-
/// Signet supported.
151-
Signet,
152-
/// CSV supported.
153-
Csv,
154-
/// Taproot supported.
155-
Taproot,
156-
}
157-
158144
/// Arg for the `getblocktemplate` method. (v29+).
159145
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, Default)]
160146
pub struct TemplateRequest {
@@ -169,3 +155,17 @@ pub struct TemplateRequest {
169155
#[serde(skip_serializing_if = "Option::is_none")]
170156
pub data: Option<String>,
171157
}
158+
159+
/// Client side supported softfork deployment.
160+
#[derive(Copy, Clone, PartialEq, Eq, Debug, Deserialize, Serialize)]
161+
#[serde(rename_all = "lowercase")]
162+
pub enum TemplateRules {
163+
/// SegWit v0 supported.
164+
Segwit,
165+
/// Signet supported.
166+
Signet,
167+
/// CSV supported.
168+
Csv,
169+
/// Taproot supported.
170+
Taproot,
171+
}

integration_test/Cargo.toml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,8 @@ edition = "2021"
1919
27_2 = ["v27", "node/27_2"]
2020
27_1 = ["v27", "node/27_1"]
2121
27_0 = ["v27", "node/27_0"]
22-
26_2 = ["v26", "node/26_2"]
23-
26_1 = ["v26", "node/26_1"]
24-
26_0 = ["v26", "node/26_0"]
2522
# Only the latest minor version for older versions.
23+
26_2 = ["v26", "node/26_2"]
2624
25_2 = ["v25", "node/25_2"]
2725
24_2 = ["v24", "node/24_2"]
2826
23_2 = ["v23", "node/23_2"]

integration_test/tests/blockchain.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ fn blockchain__get_chain_tx_stats__modelled() {
154154
fn blockchain__get_descriptor_activity__modelled() {
155155
let node = Node::with_wallet(Wallet::None, &["-coinstatsindex=1", "-txindex=1"]);
156156

157-
let json: GetDescriptorActivity = node.client.get_descriptor_activity(&[], &[], false).expect("getdescriptoractivity");
157+
let json: GetDescriptorActivity = node.client.get_descriptor_activity().expect("getdescriptoractivity");
158158
let model: Result<mtype::GetDescriptorActivity, GetDescriptorActivityError> = json.into_model();
159159
model.unwrap();
160160
}

node/Cargo.toml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,9 @@ download = ["anyhow", "bitcoin_hashes", "flate2", "tar", "minreq", "zip"]
5151
27_2 = ["27_1"]
5252
27_1 = ["27_0"]
5353
27_0 = ["26_2"]
54-
26_2 = ["26_1"]
55-
26_1 = ["26_0"]
56-
26_0 = ["25_2"]
5754

5855
# We only support the latest minor version for older versions.
56+
26_2 = ["25_2"]
5957
25_2 = ["24_2"]
6058
24_2 = ["23_2"]
6159
23_2 = ["22_1"]

node/contrib/extra_tests.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
set -euox pipefail
1616

17-
FEATURES=("29_0" "28_1" "28_0" "27_1" "27_0" "26_2" "26_1" "26_0" "25_2" "24_2" \
17+
FEATURES=("29_0" "28_1" "28_0" "27_1" "27_0" "26_2" "25_2" "24_2" \
1818
"23_2" "22_1" "0_21_2" "0_20_2" "0_19_1" "0_18_1" "0_17_2")
1919

2020
# Use the current `Cargo.lock` file without updating it.

node/src/client_versions.rs

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,7 @@ pub use corepc_client::{client_sync::v27::*, types::v27 as vtype};
2727
#[cfg(all(feature = "26_2", not(feature = "27_0")))]
2828
pub use corepc_client::{client_sync::v26::*, types::v26 as vtype};
2929

30-
#[cfg(all(feature = "26_1", not(feature = "26_2")))]
31-
pub use corepc_client::{client_sync::v26::*, types::v26 as vtype};
32-
33-
#[cfg(all(feature = "26_0", not(feature = "26_1")))]
34-
pub use corepc_client::{client_sync::v26::*, types::v26 as vtype};
35-
36-
#[cfg(all(feature = "25_2", not(feature = "26_0")))]
30+
#[cfg(all(feature = "25_2", not(feature = "26_2")))]
3731
pub use corepc_client::{client_sync::v25::*, types::v25 as vtype};
3832

3933
#[cfg(all(feature = "24_2", not(feature = "25_2")))]
@@ -70,8 +64,6 @@ pub use corepc_client::{client_sync::v17::*, types::v17 as vtype};
7064
not(feature = "27_1"),
7165
not(feature = "27_0"),
7266
not(feature = "26_2"),
73-
not(feature = "26_1"),
74-
not(feature = "26_0"),
7567
not(feature = "25_2"),
7668
not(feature = "24_2"),
7769
not(feature = "23_2"),

node/src/versions.rs

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@
88
not(feature = "27_1"),
99
not(feature = "27_0"),
1010
not(feature = "26_2"),
11-
not(feature = "26_1"),
12-
not(feature = "26_0"),
1311
not(feature = "25_2"),
1412
not(feature = "24_2"),
1513
not(feature = "23_2"),
@@ -44,13 +42,7 @@ pub const VERSION: &str = "27.0";
4442
#[cfg(all(feature = "26_2", not(feature = "27_0")))]
4543
pub const VERSION: &str = "26.2";
4644

47-
#[cfg(all(feature = "26_1", not(feature = "26_2")))]
48-
pub const VERSION: &str = "26.1";
49-
50-
#[cfg(all(feature = "26_0", not(feature = "26_1")))]
51-
pub const VERSION: &str = "26.0";
52-
53-
#[cfg(all(feature = "25_2", not(feature = "26_0")))]
45+
#[cfg(all(feature = "25_2", not(feature = "26_2")))]
5446
pub const VERSION: &str = "25.2";
5547

5648
#[cfg(all(feature = "24_2", not(feature = "25_2")))]
@@ -87,8 +79,6 @@ pub const VERSION: &str = "0.17.2";
8779
not(feature = "27_1"),
8880
not(feature = "27_0"),
8981
not(feature = "26_2"),
90-
not(feature = "26_1"),
91-
not(feature = "26_0"),
9282
not(feature = "25_2"),
9383
not(feature = "24_2"),
9484
not(feature = "23_2"),

types/src/model/blockchain.rs

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ pub struct GetBlockVerboseOne {
5353
pub nonce: u32,
5454
/// The bits.
5555
pub bits: CompactTarget,
56-
/// The difficulty target
56+
/// The difficulty target.
5757
pub target: Option<Target>, // Only from v29 onwards
5858
/// The difficulty.
5959
pub difficulty: f64,
@@ -78,7 +78,7 @@ pub struct GetBlockchainInfo {
7878
pub headers: u32,
7979
/// The hash of the currently best block.
8080
pub best_block_hash: BlockHash,
81-
/// The compact representation of the block difficulty target
81+
/// The compact representation of the block difficulty target.
8282
pub bits: Option<CompactTarget>, // Only from v29 onwards
8383
/// The difficulty target.
8484
pub target: Option<Target>, // Only from v29 onwards
@@ -227,7 +227,7 @@ pub struct GetBlockHeaderVerbose {
227227
pub nonce: u32,
228228
/// The target value below which the blockhash must lie.
229229
pub bits: CompactTarget,
230-
/// The difficulty target
230+
/// The difficulty target.
231231
pub target: Option<Target>, // Only from v29 onwards
232232
/// The difficulty.
233233
pub difficulty: f64,
@@ -508,24 +508,33 @@ pub struct GetDescriptorActivity {
508508
pub activity: Vec<ActivityEntry>,
509509
}
510510

511+
/// Enum representing either a spend or receive activity entry using model types.
512+
#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)]
513+
pub enum ActivityEntry {
514+
/// The spend activity using `model::SpendActivity`.
515+
Spend(SpendActivity),
516+
/// The receive activity using `model::ReceiveActivity`.
517+
Receive(ReceiveActivity),
518+
}
519+
511520
/// Models a 'spend' activity event with strongly typed fields.
512521
#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)]
513522
pub struct SpendActivity {
514-
/// The total amount in BTC of the spent output, converted to `bitcoin::Amount`.
523+
/// The total amount of the spent output.
515524
pub amount: Amount,
516-
/// The blockhash (omitted if unconfirmed), parsed into `bitcoin::BlockHash`.
525+
/// The blockhash (omitted if unconfirmed).
517526
pub block_hash: Option<BlockHash>,
518527
/// Height of the spend (omitted if unconfirmed).
519528
pub height: Option<u32>,
520-
/// The txid of the spending transaction, parsed into `bitcoin::Txid`.
529+
/// The txid of the spending transaction.
521530
pub spend_txid: Txid,
522531
/// The vout of the spend.
523532
pub spend_vout: u32,
524-
/// The txid of the prevout, parsed into `bitcoin::Txid`.
533+
/// The txid of the prevout.
525534
pub prevout_txid: Txid,
526535
/// The vout of the prevout.
527536
pub prevout_vout: u32,
528-
/// The prev scriptPubKey, converted to `model::ScriptPubkey`.
537+
/// The prev scriptPubKey.
529538
pub prevout_spk: ScriptPubkey,
530539
}
531540

@@ -545,13 +554,3 @@ pub struct ReceiveActivity {
545554
/// The ScriptPubKey, converted to `model::ScriptPubkey`.
546555
pub output_spk: ScriptPubkey,
547556
}
548-
549-
/// Enum representing either a spend or receive activity entry using model types.
550-
#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)]
551-
#[serde(tag = "type", rename_all = "lowercase")]
552-
pub enum ActivityEntry {
553-
/// The spend activity using `model::SpendActivity`.
554-
Spend(SpendActivity),
555-
/// The receive activity using `model::ReceiveActivity`.
556-
Receive(ReceiveActivity),
557-
}

0 commit comments

Comments
 (0)