Skip to content

Add user defined script as part of multisig#17

Draft
topologoanatom wants to merge 2 commits into
developmentfrom
script-timelocks
Draft

Add user defined script as part of multisig#17
topologoanatom wants to merge 2 commits into
developmentfrom
script-timelocks

Conversation

@topologoanatom
Copy link
Copy Markdown
Collaborator

@topologoanatom topologoanatom commented May 11, 2026

Changes

Redesigns P2TR flow to hold 2-of-2 multisig from previous versions and user defined recovery path as leafs of taptree (key path unspendable); removes p2sh, p2wsh types.

  • implement logic and update demo for bitcoin regtest;
  • implement logic and update demo for elements;

Changed demo scripts for bitcoin regtest. Elements
versions are broken now
@topologoanatom topologoanatom self-assigned this May 11, 2026
@topologoanatom topologoanatom requested a review from ivanlele May 12, 2026 10:05
Comment thread cli/scripts/demo_bitcoin.sh Outdated

set -e

# Make sure bitcoind is running
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we catch that bitcoind connection is absent and give appropriate error with this message?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PTAL

@topologoanatom topologoanatom changed the title add timelock recovery path Add user defined script as part of multisig May 13, 2026
@topologoanatom
Copy link
Copy Markdown
Collaborator Author

It's tricky to finalize generic user's script, so finalization is handled only for multisignature path. CLI provides tooling for manual finalization of CSV script for demo purposes.

@topologoanatom topologoanatom requested a review from ivanlele May 13, 2026 14:21
Comment thread core/src/utils.rs
/// OP_IF
/// OP_2 <cosigner_pk(33)> <user_pk(33)> OP_2 OP_CHECKMULTISIG
/// OP_ELSE
/// <locktime> OP_CSV OP_DROP <user_pk(33)> OP_CHECKSIG
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cleanup the timelock related staff from this the core, and move it into cli if it is used there.

Comment thread core/src/runner.rs
let program = Program::<CoreExtension>::from_str(program, witness)
.map_err(RunnerError::ProgramParse)?;

let env = UnchainedEnv::new(redeem_script, ());
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The same logic used previously for P2SH and P2WSH should apply here as well. We place the redeem script of our leaf here.

length(min = 1),
custom(function = "validation::validate_user_leaf_script")
)]
pub user_leaf_script_hex: String,
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't really care what users put in their leaf, we should just accept TapLeafHash, it is enough to build control block.

}

#[cfg(test)]
/*#[cfg(test)]
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tests should run

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants