-
Notifications
You must be signed in to change notification settings - Fork 123
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
Provable asset burning #477
Conversation
rpcserver.go
Outdated
|
||
// If there is only a single output, it means that we are attempting to | ||
// burn all the assets that were selected and that there are no passive | ||
// assets either. This would mean we'd create a BTC level output with |
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.
Wouldn't this be the same as the tombstone scenario? With the only difference being this new burn NUMs key is used instead of the existing burn/nums key?
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.
Or it's even just a send as "normal", with no need for an anchor at all, as it looks sort of like UTXO consolidation.
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.
Ah, true. But I guess that way we'd end up sending 1k sats to a BTC output that can't be spent anymore (at least not with the current RPCs). I can remove that restriction if we want and create an issue that we'll eventually need a "sweep BTC from outputs with empty commitments/tombstones/burns".
2070c37
to
a735502
Compare
a735502
to
8424ea5
Compare
Addressed all comments and fixed all TODOs. This is ready for full review. |
43eb682
to
b9c7662
Compare
Pushed up a rebased version. |
b9c7662
to
49f7cda
Compare
tapfreighter/wallet.go
Outdated
Amount: 0, | ||
Type: tappsbt.TypeSplitRoot, | ||
AnchorOutputIndex: 0, | ||
ScriptKey: asset.NUMSScriptKey, |
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.
Thought tombstones weren't needed for this case? cc @jharveyb
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.
IIUC the tombstone output is added here so that fundPacketWithInputs
handles change calculation on building a valid change output if needed. The branch later on handles the full-value burn situation, so we should never end up with an actual tombstone. I think the comment could be a bit more verbose in nothing that the final result will not be a tombstone.
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.
Correct, they aren't. This is just to give the wallet an asset output it can attach any passive assets to. We remove it again later if there are no passive assets. Added a more explicit comment to it.
// without an actual commitment in it. So if we are not getting any | ||
// change or passive assets in this output, we'll not want to go through | ||
// with it. | ||
changeOut := fundedPkt.VPacket.Outputs[0] |
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.
If the above is unchanged though, then doesn't this lead to us just sending those other funds to the NUMs key?
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.
Yes, but I think from fundPacketWithInputs
and the logic right after this, that key will never stay as NUMS if the amount is non-zero; this either becomes a normal split, or the tombstone is removed.
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.
Correct. We might want to eventually refactor the whole wallet code a bit to either make some of the assumptions less implicit or by just documenting them better.
// assets. Otherwise, for an interactive send we don't | ||
// need a tombstone output and this wouldn't be a two | ||
// output collectible send. | ||
if !rootOut.Type.CanCarryPassive() && |
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.
Needs unit test
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.
Added a unit test.
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.
Looks good, cool to see how the freighter changes are relatively contained!
Gave my nits offline or in existing threads.
if in.AmountToBurn == 0 { | ||
return nil, fmt.Errorf("amount to burn must be specified") | ||
} | ||
if in.ConfirmationText != AssetBurnConfirmationText { |
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.
💯
scriptKey3, anchorInternalKeyDesc3 := deriveKeys(t.t, t.tapd) | ||
scriptKey4, _ := deriveKeys(t.t, t.tapd) | ||
|
||
// We create the following outputs: |
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.
Very helpful for following the flow & cases here!
Because a burn is an interactive send, we don't need to create a tombstone output if it's a full-value send. So in case there are passive assets in the same commitment, we don't have a split root output to hook them to. With the introduction of the new TypeSimplePassiveAssets we have a new way to signal to the send state machine where to commit passive assets to if there is no actual split or tombstone output.
We want to be able to show/list burned assets, so we want to re-create them in the assets table. But to avoid them showing up in any balances, we also mark burned assets as spent and we'll add an extra is_burn flag to the asset output as well on the RPC response.
The same way we prune tombstone asset outputs from the input commitment when spending an anchor output, we also want to remove any burned assets.
In the case where we have an interactive full-value send of a collectible, we would normally only expect a single output. But if there are passive assets to commit to, then there needs to be a second output just for those.
49f7cda
to
2d15923
Compare
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.
LGTM 🦜
Fixes #24.
Depends on #482.Still work in progress, main things missing are:
More unit testsCLI commandtapcli assets burn
Burn all coins in a commitment (expect error because of edge case)Burn all assets of one ID while there are other (passive) assets (=> expect root asset for burn)Burn some assets, get some change back (=> expect split asset for burn)Burn assets from multiple inputs