refactor(wallet)!: Make Wallet require a change descriptor

All `Wallet` constructors are modified to require a change
descriptor, where previously it was optional. Additionally
we enforce uniqueness of the change descriptor to avoid
ambiguity when deriving scripts and ensure the wallet will
always have two distinct keystores.

Notable changes

* Add error DescriptorError::ExternalAndInternalAreTheSame
* Remove error CreateTxError::ChangePolicyDescriptor
* No longer rely on `map_keychain`
This commit is contained in:
valued mammal
2024-03-26 21:57:10 -04:00
parent 8eef350bd0
commit 9d954cf7d2
16 changed files with 393 additions and 341 deletions

View File

@@ -25,7 +25,7 @@ pub struct Args {
pub descriptor: String,
/// Wallet change descriptor
#[clap(env = "CHANGE_DESCRIPTOR")]
pub change_descriptor: Option<String>,
pub change_descriptor: String,
/// Earliest block height to start sync from
#[clap(env = "START_HEIGHT", long, default_value = "481824")]
pub start_height: u32,
@@ -88,7 +88,7 @@ fn main() -> anyhow::Result<()> {
let start_load_wallet = Instant::now();
let mut wallet = Wallet::new_or_load(
&args.descriptor,
args.change_descriptor.as_ref(),
&args.change_descriptor,
Store::<bdk_wallet::wallet::ChangeSet>::open_or_create_new(
DB_MAGIC.as_bytes(),
args.db_path,