Skip to content

Commit 51a3f3b

Browse files
committed
Add a feature to force using deterministic signatures in the wallet for regtest
1 parent ba45c02 commit 51a3f3b

2 files changed

Lines changed: 22 additions & 2 deletions

File tree

wallet/Cargo.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,4 +53,8 @@ tempfile.workspace = true
5353
[features]
5454
trezor = ["dep:trezor-client", "wallet-types/trezor"]
5555
enable-trezor-device-tests = []
56+
# Note: currently this is used in certain external tests (in particular, in the bridge), so we only
57+
# allow it for regtest. TODO: it's better to have some regtest-specific options for the wallet,
58+
# similar to what we have for the node.
59+
use-deterministic-signatures-in-software-signer-for-regtest = []
5660
default = ["trezor"]

wallet/src/signer/software_signer/mod.rs

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ use itertools::Itertools;
1919

2020
use common::{
2121
chain::{
22+
config::ChainType,
2223
htlc::HtlcSecret,
2324
signature::{
2425
inputsig::{
@@ -46,7 +47,7 @@ use common::{
4647
use crypto::key::{
4748
extended::{ExtendedPrivateKey, ExtendedPublicKey},
4849
hdkd::{derivable::Derivable, u31::U31},
49-
PrivateKey, SigAuxDataProvider,
50+
PredefinedSigAuxDataProvider, PrivateKey, SigAuxDataProvider,
5051
};
5152
use randomness::make_true_rng;
5253
use wallet_storage::{
@@ -76,7 +77,22 @@ pub struct SoftwareSigner {
7677

7778
impl SoftwareSigner {
7879
pub fn new(chain_config: Arc<ChainConfig>, account_index: U31) -> Self {
79-
Self::new_with_sig_aux_data_provider(chain_config, account_index, Box::new(make_true_rng()))
80+
let use_deterministic_signer = *chain_config.chain_type() == ChainType::Regtest
81+
&& cfg!(feature = "use-deterministic-signatures-in-software-signer-for-regtest");
82+
83+
if use_deterministic_signer {
84+
Self::new_with_sig_aux_data_provider(
85+
chain_config,
86+
account_index,
87+
Box::new(PredefinedSigAuxDataProvider),
88+
)
89+
} else {
90+
Self::new_with_sig_aux_data_provider(
91+
chain_config,
92+
account_index,
93+
Box::new(make_true_rng()),
94+
)
95+
}
8096
}
8197

8298
pub fn new_with_sig_aux_data_provider(

0 commit comments

Comments
 (0)