-
Notifications
You must be signed in to change notification settings - Fork 132
minting: fix re-issuing into existing group with external key #1517
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2668,14 +2668,19 @@ func (c *ChainPlanter) prepAssetSeedling(ctx context.Context, | |
// If a group internal key or tapscript root is specified, emission must | ||
// also be enabled. | ||
if !req.EnableEmission { | ||
if req.GroupInternalKey != nil { | ||
// For re-issuing grouped assets or regular (non-grouped) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. should this say "NEW regular (non-grouped)? |
||
// assets, the group internal key shouldn't be set. It is, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. seems contradictory to your comment https://github.com/lightninglabs/taproot-assets/pull/1517/files#r2077342801 ? |
||
// however, set for re-issuance with an external key, because | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. is it required or optional? I'm able to do a second tranche using external signer without setting it. |
||
// the internal group key is the key we compare the external key | ||
// against. | ||
if req.GroupInternalKey != nil && req.ExternalKey.IsNone() { | ||
return fmt.Errorf("cannot specify group internal key " + | ||
"without enabling emission") | ||
"without creating a new grouped asset") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. should you add "first" on the end of this line? |
||
} | ||
|
||
if req.GroupTapscriptRoot != nil { | ||
return fmt.Errorf("cannot specify group tapscript " + | ||
"root without enabling emission") | ||
"root without creating a new grouped asset") | ||
} | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -183,10 +183,49 @@ func (c Seedling) validateFields() error { | |||||||||||||||||||||||
func (c Seedling) validateGroupKey(group asset.AssetGroup, | ||||||||||||||||||||||||
anchorMeta *proof.MetaReveal) error { | ||||||||||||||||||||||||
|
||||||||||||||||||||||||
// We must be able to sign with the group key. | ||||||||||||||||||||||||
if !group.GroupKey.IsLocal() { | ||||||||||||||||||||||||
groupKeyBytes := c.GroupInfo.GroupPubKey.SerializeCompressed() | ||||||||||||||||||||||||
return fmt.Errorf("can't sign with group key %x", groupKeyBytes) | ||||||||||||||||||||||||
switch { | ||||||||||||||||||||||||
// If we have an external key, we need to check that the group key | ||||||||||||||||||||||||
// matches the external key. | ||||||||||||||||||||||||
case c.ExternalKey.IsSome(): | ||||||||||||||||||||||||
err := fn.MapOptionZ( | ||||||||||||||||||||||||
c.ExternalKey, func(extKey asset.ExternalKey) error { | ||||||||||||||||||||||||
if group.GroupKey == nil { | ||||||||||||||||||||||||
return fmt.Errorf("group key is nil") | ||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. is this the same as There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No, this is just the outer struct holding the info, it doesn't have an RPC couterpart. This error should never happen, it's just defensive to avoid a panic. |
||||||||||||||||||||||||
} | ||||||||||||||||||||||||
|
||||||||||||||||||||||||
if group.GroupKey.RawKey.PubKey == nil { | ||||||||||||||||||||||||
return fmt.Errorf("group raw key is " + | ||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. is this the same as taproot-assets/taprpc/mintrpc/mint.proto Lines 216 to 226 in 5225722
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No, this is the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. not understanding it, but may be outside of my knowledge scope, so maybe it doesn't need more clarification. not sure. |
||||||||||||||||||||||||
"nil") | ||||||||||||||||||||||||
} | ||||||||||||||||||||||||
|
||||||||||||||||||||||||
pk, err := extKey.PubKey() | ||||||||||||||||||||||||
if err != nil { | ||||||||||||||||||||||||
return fmt.Errorf("error getting "+ | ||||||||||||||||||||||||
"external key: %w", err) | ||||||||||||||||||||||||
} | ||||||||||||||||||||||||
|
||||||||||||||||||||||||
if !pk.IsEqual(group.RawKey.PubKey) { | ||||||||||||||||||||||||
return fmt.Errorf("external key " + | ||||||||||||||||||||||||
"does not match group key") | ||||||||||||||||||||||||
} | ||||||||||||||||||||||||
|
||||||||||||||||||||||||
return nil | ||||||||||||||||||||||||
}, | ||||||||||||||||||||||||
) | ||||||||||||||||||||||||
if err != nil { | ||||||||||||||||||||||||
return fmt.Errorf("error validating external key: %w", | ||||||||||||||||||||||||
err) | ||||||||||||||||||||||||
} | ||||||||||||||||||||||||
|
||||||||||||||||||||||||
// If it's not an external key, we need to check that we can actually | ||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. so this would mean taproot-assets/taprpc/mintrpc/mint.proto Lines 174 to 182 in 5225722
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not necessarily. You only need to specify the |
||||||||||||||||||||||||
// sign with the group key. | ||||||||||||||||||||||||
default: | ||||||||||||||||||||||||
if !group.GroupKey.IsLocal() { | ||||||||||||||||||||||||
groupPubKey := c.GroupInfo.GroupPubKey | ||||||||||||||||||||||||
groupKeyBytes := groupPubKey.SerializeCompressed() | ||||||||||||||||||||||||
return fmt.Errorf("can't sign with group key %x", | ||||||||||||||||||||||||
groupKeyBytes) | ||||||||||||||||||||||||
} | ||||||||||||||||||||||||
} | ||||||||||||||||||||||||
|
||||||||||||||||||||||||
// The seedling asset type must match the group asset type. | ||||||||||||||||||||||||
|
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.
you want to remove "emission" here too?