Skip to content

Exclude opreturn from change heuristics #81

Merged
arminsabouri merged 3 commits into
masterfrom
exclude-opreturn
May 16, 2026
Merged

Exclude opreturn from change heuristics #81
arminsabouri merged 3 commits into
masterfrom
exclude-opreturn

Conversation

@arminsabouri

Copy link
Copy Markdown
Contributor

@0xZaddyy To replace PR #73 And fixed the UIH1 inconsistency discussed in #73


let outputs: Vec<_> = tx.outputs().map(|o| (o.id(), o.value())).collect();
if outputs.is_empty() {
for output_id in txouts.iter() {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

per-output mask makes sense, but is_uih1_candidate recomputes min(input_values) per output

O(K²) lookups for a K-in/K-out tx

could group output_ids by tx here and compute min(in) once per tx

same mask output

wdyt?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

yeah something like that could make sense. Alternatively we could redesignt the optimal change node to iterate over txs instead of txouts. I have a feeling we would do this kind of refactor when we tackle #65

@0xZaddyy 0xZaddyy left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Overall, everything looks good
ACK

pub struct SpendableTxConstituent<T>(T);

impl<T: HasScriptPubkey> SpendableTxConstituent<T> {
/// Wraps `value` if it is spendable; returns it back as `Err` if OP_RETURN.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
/// Wraps `value` if it is spendable; returns it back as `Err` if OP_RETURN.
/// Wraps `value` if it is spendable; returns it back as `Err` if OP_RETURN or NonStandard.

@bc1cindy bc1cindy left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM, ACK

@Mshehu5 Mshehu5 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

ACK

Wrapper around `TxConstituent` that is converted when the spk is "spendable"
Co-authored-by: Oladapo Oyindamola <111582215+0xZaddyy@users.noreply.github.com>

Change is defined as an output going belonging to the 
same wallet the input set. Unspendable outputs by this definition
cannot be change.
UIH1 now takes Expr<TxOutSet> and returns Expr<TxOutMask>, matching the
convention of other change heuristics. The underlying is_uih1_candidate
was updated to take SpendableTxConstituent<T>, so the node wraps each
output at the call site before delegating.
@arminsabouri arminsabouri merged commit 16ae6f5 into master May 16, 2026
5 checks passed
@arminsabouri arminsabouri deleted the exclude-opreturn branch May 16, 2026 19:52
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.

4 participants