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

Store transfer output proof delivery status #1035

Merged
merged 7 commits into from
Jul 29, 2024
45 changes: 7 additions & 38 deletions tapfreighter/chain_porter.go
Original file line number Diff line number Diff line change
Expand Up @@ -643,47 +643,16 @@ func (p *ChainPorter) transferReceiverProof(pkg *sendPackage) error {
deliver := func(ctx context.Context, out TransferOutput) error {
key := out.ScriptKey.PubKey

// If this is an output that is going to our own node/wallet,
// we don't need to transfer the proof.
if out.ScriptKey.TweakedScriptKey != nil && out.ScriptKeyLocal {
log.Debugf("Not transferring proof for local output "+
"script key %x", key.SerializeCompressed())
return nil
}

// Un-spendable means this is a tombstone output resulting from
// a split.
unSpendable, err := out.ScriptKey.IsUnSpendable()
// We'll first check to see if the proof should be delivered.
shouldDeliverProof, err := out.ShouldDeliverProof()
if err != nil {
return fmt.Errorf("error checking if script key is "+
"unspendable: %w", err)
}
if unSpendable {
log.Debugf("Not transferring proof for un-spendable "+
"output script key %x",
key.SerializeCompressed())
return nil
}

// Burns are also always kept local and not sent to any
// receiver.
if len(out.WitnessData) > 0 && asset.IsBurnKey(
Copy link
Member

Choose a reason for hiding this comment

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

Ah I see this was also just existing behavior, feel free to ignore those other comments.

out.ScriptKey.PubKey, out.WitnessData[0],
) {

log.Debugf("Not transferring proof for burn script "+
"key %x", key.SerializeCompressed())
return nil
return fmt.Errorf("error determining if proof should "+
"be delivered: %w", err)
}

// We can only deliver proofs for outputs that have a proof
// courier address. If an output doesn't have one, we assume it
// is an interactive send where the recipient is already aware
// of the proof or learns of it through another channel.
if len(out.ProofCourierAddr) == 0 {
log.Debugf("Not transferring proof for output with "+
"script key %x as it has no proof courier "+
"address", key.SerializeCompressed())
if !shouldDeliverProof {
log.Debugf("Not delivering proof for output with "+
"script key %x", key.SerializeCompressed())
return nil
}

Expand Down