Skip to content
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

add tapret tweak only when necessary #158

Merged
merged 1 commit into from
Apr 19, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 9 additions & 7 deletions src/pay.rs
Original file line number Diff line number Diff line change
Expand Up @@ -315,13 +315,15 @@ impl Runtime {
let contract_id = invoice.contract.ok_or(CompletionError::NoContract)?;

let fascia = psbt.rgb_commit()?;
if let Some(output) = psbt.dbc_output::<TapretProof>() {
let terminal = output
.terminal_derivation()
.ok_or(CompletionError::InconclusiveDerivation)?;
let tapret_commitment = output.tapret_commitment()?;
self.wallet_mut()
.add_tapret_tweak(terminal, tapret_commitment)?;
if let (Some(_), _) = fascia.anchor.as_reduced_unsafe().as_split() {
Copy link
Member

Choose a reason for hiding this comment

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

This is dangerous way to do it - if the split method change signature and will return opret anchor first, this will be missed to be changed. Thus, the better is to

Suggested change
if let (Some(_), _) = fascia.anchor.as_reduced_unsafe().as_split() {
if let (Some(Anchor::<_, TapretProof> { .. }), _) = fascia.anchor.as_reduced_unsafe().as_split() {

... but this is too clunky and better I would modify RGB Core API

if let Some(output) = psbt.dbc_output::<TapretProof>() {
let terminal = output
.terminal_derivation()
.ok_or(CompletionError::InconclusiveDerivation)?;
let tapret_commitment = output.tapret_commitment()?;
self.wallet_mut()
.add_tapret_tweak(terminal, tapret_commitment)?;
}
}

let witness_txid = psbt.txid();
Expand Down
Loading