-
Notifications
You must be signed in to change notification settings - Fork 332
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Introduce canonicalization modifiers. #1808
base: master
Are you sure you want to change the base?
Introduce canonicalization modifiers. #1808
Conversation
Introduce `CanonicalizationMods` which is passed in to `CanonicalIter::new`. `CanonicalizationMods::assume_canonical` is the only field right now. This contains a list of txids that we assume to be canonical, superceding any other canonicalization rules.
Also change `TxTemplate` API to allow for testing with `assume_canonical`.
4169060
to
0f00cdb
Compare
Would it make sense to add This way the existing And if you could only add new Then you could also add the For
|
use bdk_core::BlockId; | ||
use bitcoin::{Transaction, Txid}; | ||
|
||
/// Modifies the canonicalization algorithm. | ||
#[derive(Debug, Default, Clone)] | ||
pub struct CanonicalizationMods { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"Params" feels more idiomatic.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agree, it also aligns better with other usages in the project, i.e: TxParams, LoadParams.
|
||
impl CanonicalizationMods { | ||
/// No mods. | ||
pub const NONE: Self = Self { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Dunno if we need this. Default
is enough.
// We want to be able to replace an unsigned tx with a signed tx. | ||
// The tx with more weight has precedence (and tiebreak with the actual tx data). | ||
// We can also check whether the witness is valid and also prioritize signatures | ||
// with less weight, but that is more work and this solution is good enough. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Prediction: It's less lines of code than this comment to just do it correctly.
ConceptACK. Would be nice to have draft PR built on this that resolves #1748 so we know that this is all that's needed at the chain level before merging this. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cACK 0f00cdb
use bdk_core::BlockId; | ||
use bitcoin::{Transaction, Txid}; | ||
|
||
/// Modifies the canonicalization algorithm. | ||
#[derive(Debug, Default, Clone)] | ||
pub struct CanonicalizationMods { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agree, it also aligns better with other usages in the project, i.e: TxParams, LoadParams.
Took this out of the |
Partially Fixes #1748
Description
Add the ability to modify the canonicalization algorithm. Right now, the only modifier is
assume_canonical
which takes in aVec
(ordered list) of txids and superimposes it on the canonicalization algorithm. Txs later in the list (higher index) have a higher priority (in case of conflicts).This is a "partial fix" because I haven't figured out how to expose this on the
bdk_wallet
level yet (some thoughts on this will be very appreciated).Notes to the reviewers
None at the moment.
Changelog notice
CanonicalizationMods
to allow the caller to modify the canonicalization algorithm. This in a new parameter onCanonicalIter::new
.Checklists
All Submissions:
cargo fmt
andcargo clippy
before committingNew Features:
Bugfixes: