-
Notifications
You must be signed in to change notification settings - Fork 120
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
Part 1: Asset Minting with V1 Asset Group Key and Chantools Cold Storage Support #1272
base: main
Are you sure you want to change the base?
Changes from 1 commit
58f7f05
a74692e
702dc6e
c79ad28
8d3a435
e891588
66b442b
76a5b0e
74decd6
a993070
c682091
a235fb8
05a0299
e058731
db912f2
cb985f7
fbe8206
a00fd22
f030426
650efb5
d49f4c1
06ec377
18bbcf3
3b7a2ec
c0c6795
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 |
---|---|---|
|
@@ -6,6 +6,7 @@ import ( | |
"math" | ||
"os" | ||
"strconv" | ||
"strings" | ||
|
||
taprootassets "github.com/lightninglabs/taproot-assets" | ||
"github.com/lightninglabs/taproot-assets/tapcfg" | ||
|
@@ -138,6 +139,21 @@ var mintAssetCommand = cli.Command{ | |
"in order to avoid printing a large amount " + | ||
"of data in case of large batches", | ||
}, | ||
cli.StringFlag{ | ||
Name: "group_key_xpub", | ||
Usage: "the xpub of the group key to use to mint the " + | ||
"asset", | ||
}, | ||
cli.StringFlag{ | ||
Name: "group_key_derivation_path", | ||
Usage: "the derivation path that was used to derive " + | ||
"the group key xpub", | ||
}, | ||
cli.StringFlag{ | ||
Name: "group_key_fingerprint", | ||
Usage: "the master fingerprint of the key the xpub " + | ||
"was derived from", | ||
}, | ||
}, | ||
Action: mintAsset, | ||
Subcommands: []cli.Command{ | ||
|
@@ -326,6 +342,32 @@ func mintAsset(ctx *cli.Context) error { | |
client, cleanUp := getMintClient(ctx) | ||
defer cleanUp() | ||
|
||
gkXPub := ctx.String("group_key_xpub") | ||
gkPath := ctx.String("group_key_derivation_path") | ||
gkFingerprint := ctx.String("group_key_fingerprint") | ||
|
||
var externalKey *taprpc.ExternalKey | ||
switch { | ||
case (gkXPub != "" || gkPath != "" || gkFingerprint != "") && | ||
(gkXPub == "" || gkPath == "" || gkFingerprint == ""): | ||
|
||
return fmt.Errorf("group key xpub, derivation path, and " + | ||
"fingerprint must all be set or all be empty") | ||
|
||
case gkXPub != "" && gkPath != "" && gkFingerprint != "": | ||
fingerPrintBytes, err := hex.DecodeString(gkFingerprint) | ||
if err != nil { | ||
return fmt.Errorf("cannot hex decode group key "+ | ||
"fingerprint: %w", err) | ||
} | ||
|
||
externalKey = &taprpc.ExternalKey{ | ||
Xpub: gkXPub, | ||
MasterFingerprint: fingerPrintBytes, | ||
DerivationPath: gkPath, | ||
} | ||
} | ||
|
||
resp, err := client.MintAsset(ctxc, &mintrpc.MintAssetRequest{ | ||
Asset: &mintrpc.MintAsset{ | ||
AssetType: assetType, | ||
|
@@ -340,6 +382,7 @@ func mintAsset(ctx *cli.Context) error { | |
AssetVersion: taprpc.AssetVersion( | ||
ctx.Uint64(assetVersionName), | ||
), | ||
ExternalGroupKey: externalKey, | ||
}, | ||
ShortResponse: ctx.Bool(shortResponseName), | ||
}) | ||
|
@@ -415,6 +458,11 @@ var sealBatchCommand = cli.Command{ | |
"in order to avoid printing a large amount " + | ||
"of data in case of large batches", | ||
}, | ||
cli.StringSliceFlag{ | ||
Name: "group_signatures", | ||
Usage: "the asset ID and signature, separated by a " + | ||
"colon", | ||
}, | ||
}, | ||
Hidden: true, | ||
Action: sealBatch, | ||
|
@@ -425,9 +473,37 @@ func sealBatch(ctx *cli.Context) error { | |
client, cleanUp := getMintClient(ctx) | ||
defer cleanUp() | ||
|
||
resp, err := client.SealBatch(ctxc, &mintrpc.SealBatchRequest{ | ||
req := &mintrpc.SealBatchRequest{ | ||
ShortResponse: ctx.Bool(shortResponseName), | ||
}) | ||
} | ||
|
||
// TODO(guggero): Actually just ask for the signed PSBT back and extract | ||
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. Will this be addressed in this PR? So accepting the signed PSBT to extract the signatures manually ourselves. 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. One other related thing is that we want to add some basic meta data to the group key minting PSBT to allow external software to display information such as the asset ID, name, and units to be minted. |
||
// the signature from there. We can query the pending batch to get the | ||
// asset ID of each PSBT (can match by the unsigned transaction's input | ||
// prev out). | ||
sigs := ctx.StringSlice("group_signatures") | ||
for _, witness := range sigs { | ||
parts := strings.Split(witness, ":") | ||
assetIDHex, sigHex := parts[0], parts[1] | ||
assetIDBytes, err := hex.DecodeString(assetIDHex) | ||
if err != nil { | ||
return fmt.Errorf("invalid asset ID") | ||
} | ||
|
||
sigBytes, err := hex.DecodeString(sigHex) | ||
if err != nil { | ||
return fmt.Errorf("invalid signature") | ||
} | ||
|
||
req.GroupWitnesses = append( | ||
req.GroupWitnesses, &taprpc.GroupWitness{ | ||
GenesisId: assetIDBytes, | ||
Witness: [][]byte{sigBytes}, | ||
}, | ||
) | ||
} | ||
|
||
resp, err := client.SealBatch(ctxc, req) | ||
if err != nil { | ||
return fmt.Errorf("unable to seal batch: %w", err) | ||
} | ||
|
@@ -511,6 +587,9 @@ var listBatchesCommand = cli.Command{ | |
Name: batchKeyName, | ||
Usage: "if set, the batch key for a specific batch", | ||
}, | ||
cli.BoolFlag{ | ||
Name: "verbose", | ||
}, | ||
}, | ||
Action: listBatches, | ||
} | ||
|
@@ -536,6 +615,7 @@ func listBatches(ctx *cli.Context) error { | |
Filter: &mintrpc.ListBatchRequest_BatchKey{ | ||
BatchKey: batchKey, | ||
}, | ||
Verbose: ctx.Bool("verbose"), | ||
}) | ||
if err != nil { | ||
return fmt.Errorf("unable to list batches: %w", err) | ||
|
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.
Do we also need to be able to specify optional leaves for the custom tapscript root?