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

Part 1: Asset Minting with V1 Asset Group Key and Chantools Cold Storage Support #1272

Open
wants to merge 25 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
58f7f05
multi: fix formatting and doc comments
ffranr Jan 3, 2025
a74692e
asset: add GroupKeyRevealTapscript.Root method
ffranr Jan 8, 2025
702dc6e
tapgarden: introduce FundBatchResp return type for FundBatch
ffranr Jan 6, 2025
c79ad28
tapgarden: add new function newVerboseBatch
ffranr Jan 6, 2025
8d3a435
tapgarden: clarify buildGroupReqs with additional comments
ffranr Jan 8, 2025
e891588
docs: add guide for using external group keys
ffranr Jan 7, 2025
66b442b
multi: update FundBatch RPC to return verbose batch
ffranr Jan 6, 2025
76a5b0e
rpc: add ExternalKey message type and integrate with MintAsset
ffranr Jan 8, 2025
74decd6
asset+tapgarden: add ExternalKey field to Seedling and GroupKeyRequest
ffranr Jan 9, 2025
a993070
rpcserver: unmarshal Asset.ExternalGroupKey in MintAsset endpoint
ffranr Jan 9, 2025
c682091
taprpc: add external_key field to GroupKeyRequest message
ffranr Jan 9, 2025
a235fb8
cmd/tapcli: add minting flags for external key asset group support
guggero Dec 27, 2024
05a0299
mintrpc: update doc comment for MintAsset.group_tapscript_root field
ffranr Jan 8, 2025
e058731
asset+tapgarden: add CustomTapscriptRoot to GroupKey and GroupKeyRequest
ffranr Jan 8, 2025
db912f2
asset: add versioning to GroupKey and GroupKeyRequest
ffranr Jan 8, 2025
cb985f7
asset: add support for V1 group keys in GroupKeyRequest methods
ffranr Jan 7, 2025
fbe8206
rpc+tapgarden: FundBatch and ListBatches return unsealed PSBTs
ffranr Nov 22, 2024
a00fd22
sqlc: add rows version and custom_subtree_root to asset_groups table
ffranr Jan 8, 2025
f030426
tapdb: write new GroupKey fields to database rows
ffranr Jan 8, 2025
650efb5
tapdb: read new GroupKey fields from database rows
ffranr Jan 8, 2025
d49f4c1
proof: support group key reveal V1 in mint proof generation
ffranr Jan 8, 2025
06ec377
itest: verify group virtual transaction can be derived from PSBT
ffranr Nov 22, 2024
18bbcf3
Makefile: enhance `build-itest` target for chantools setup
ffranr Jan 9, 2025
3b7a2ec
itest: add harness for invoking chantools binary
ffranr Jan 6, 2025
c0c6795
itest: add test for minting with external group key via chantools
ffranr Jan 6, 2025
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
84 changes: 82 additions & 2 deletions cmd/tapcli/assets.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"math"
"os"
"strconv"
"strings"

taprootassets "github.com/lightninglabs/taproot-assets"
"github.com/lightninglabs/taproot-assets/tapcfg"
Expand Down Expand Up @@ -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",
Copy link
Member

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?

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{
Expand Down Expand Up @@ -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,
Expand All @@ -340,6 +382,7 @@ func mintAsset(ctx *cli.Context) error {
AssetVersion: taprpc.AssetVersion(
ctx.Uint64(assetVersionName),
),
ExternalGroupKey: externalKey,
},
ShortResponse: ctx.Bool(shortResponseName),
})
Expand Down Expand Up @@ -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,
Expand All @@ -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
Copy link
Member

Choose a reason for hiding this comment

The 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.

Copy link
Member

Choose a reason for hiding this comment

The 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)
}
Expand Down Expand Up @@ -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,
}
Expand All @@ -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)
Expand Down