|
3 | 3 | use std::{collections::HashMap, path::PathBuf};
|
4 | 4 |
|
5 | 5 | 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 | +}; |
7 | 10 | use ckb_jsonrpc_types::TransactionView;
|
8 | 11 | use ckb_sdk::{
|
9 | 12 | core::TransactionBuilder,
|
@@ -83,6 +86,15 @@ pub struct Args {
|
83 | 86 | #[arg(long, value_parser = value_parsers::AddressValueParser)]
|
84 | 87 | pub(crate) spv_owner: CkbAddress,
|
85 | 88 |
|
| 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 | + |
86 | 98 | /// Perform all steps without sending.
|
87 | 99 | #[arg(long, hide = true)]
|
88 | 100 | pub(crate) dry_run: bool,
|
@@ -164,9 +176,14 @@ impl Args {
|
164 | 176 | let cells_count = usize::from(self.spv_clients_count) + 1;
|
165 | 177 | let type_id_array = calculate_type_id(input0.cell_input(), cells_count);
|
166 | 178 | 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 | + } |
167 | 183 | let args = packed::SpvTypeArgs::new_builder()
|
168 | 184 | .type_id(type_id.pack())
|
169 | 185 | .clients_count(self.spv_clients_count.into())
|
| 186 | + .flags(flags.into()) |
170 | 187 | .build();
|
171 | 188 | Script::new_builder()
|
172 | 189 | .code_hash(self.spv_contract_data_hash.pack())
|
|
0 commit comments