Skip to content

Commit db41f4f

Browse files
authored
Merge pull request #2 from ckb-cell/feature/disable-diff-checks
feat: add an option to disable difficulty (and pow) checks
2 parents 7a49f8d + 303add7 commit db41f4f

File tree

3 files changed

+20
-3
lines changed

3 files changed

+20
-3
lines changed

Cargo.lock

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ ckb-hash = "0.114"
3939
[dependencies.ckb-bitcoin-spv-verifier]
4040
version = "0.1.0"
4141
git = "https://github.com/ckb-cell/ckb-bitcoin-spv"
42-
rev = "2464c8f"
42+
rev = "837a307"
4343

4444
[features]
4545
default = ["default-tls"]

src/cli/init.rs

+18-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,10 @@
33
use std::{collections::HashMap, path::PathBuf};
44

55
use bitcoin::blockdata::constants::DIFFCHANGE_INTERVAL;
6-
use ckb_bitcoin_spv_verifier::types::{core::Hash as BitcoinHash, packed, prelude::Pack as VPack};
6+
use ckb_bitcoin_spv_verifier::{
7+
constants::FLAG_DISABLE_DIFFICULTY_CHECK,
8+
types::{core::Hash as BitcoinHash, packed, prelude::Pack as VPack},
9+
};
710
use ckb_jsonrpc_types::TransactionView;
811
use ckb_sdk::{
912
core::TransactionBuilder,
@@ -83,6 +86,15 @@ pub struct Args {
8386
#[arg(long, value_parser = value_parsers::AddressValueParser)]
8487
pub(crate) spv_owner: CkbAddress,
8588

89+
/// Disable the on-chain difficulty check.
90+
///
91+
/// Warning
92+
///
93+
/// For testing purpose only.
94+
/// Do NOT enable this flag in production environment.
95+
#[arg(long)]
96+
pub(crate) disable_difficulty_check: bool,
97+
8698
/// Perform all steps without sending.
8799
#[arg(long, hide = true)]
88100
pub(crate) dry_run: bool,
@@ -164,9 +176,14 @@ impl Args {
164176
let cells_count = usize::from(self.spv_clients_count) + 1;
165177
let type_id_array = calculate_type_id(input0.cell_input(), cells_count);
166178
let type_id = BitcoinHash::from_bytes_ref(&type_id_array);
179+
let mut flags = 0u8;
180+
if self.disable_difficulty_check {
181+
flags |= FLAG_DISABLE_DIFFICULTY_CHECK;
182+
}
167183
let args = packed::SpvTypeArgs::new_builder()
168184
.type_id(type_id.pack())
169185
.clients_count(self.spv_clients_count.into())
186+
.flags(flags.into())
170187
.build();
171188
Script::new_builder()
172189
.code_hash(self.spv_contract_data_hash.pack())

0 commit comments

Comments
 (0)