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

taprpc: move ImportProof from tapdevrpc to taprpc #1139

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 0 additions & 1 deletion cmd/tapcli/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,6 @@ func main() {
app.Commands = append(app.Commands, proofCommands...)
app.Commands = append(app.Commands, rfqCommands...)
app.Commands = append(app.Commands, universeCommands...)
app.Commands = append(app.Commands, devCommands...)

if err := app.Run(os.Args); err != nil {
fatal(err)
Expand Down
47 changes: 47 additions & 0 deletions cmd/tapcli/proofs.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ var proofCommands = []cli.Command{
verifyProofCommand,
decodeProofCommand,
exportProofCommand,
importProofCommand,
proveOwnershipCommand,
verifyOwnershipCommand,
},
Expand Down Expand Up @@ -277,6 +278,52 @@ func exportProof(ctx *cli.Context) error {
return nil
}

var importProofCommand = cli.Command{
Name: "importproof",
ShortName: "i",
Usage: "import a taproot asset proof",
Description: `
Imports a taproot asset proof that contains the full provenance of an
asset. If the asset script key of the asset is known to the lnd node
the daemon is connected to, then this results in a spendable asset being
imported into the wallet.
`,
Flags: []cli.Flag{
cli.StringFlag{
Name: proofPathName,
Usage: "the path to the proof file on disk; use the " +
"dash character (-) to read from stdin instead",
},
},
Action: importProof,
}

func importProof(ctx *cli.Context) error {
ctxc := getContext()
client, cleanUp := getClient(ctx)
defer cleanUp()

if ctx.String(proofPathName) == "" {
return cli.ShowSubcommandHelp(ctx)
}

filePath := lncfg.CleanAndExpandPath(ctx.String(proofPathName))
proofFile, err := readFile(filePath)
if err != nil {
return fmt.Errorf("unable to read proof file: %w", err)
}

resp, err := client.ImportProof(ctxc, &taprpc.ImportProofRequest{
ProofFile: proofFile,
})
if err != nil {
return fmt.Errorf("unable to import proof file: %w", err)
}

printRespJSON(resp)
return nil
}

var proveOwnershipCommand = cli.Command{
Name: "proveownership",
ShortName: "po",
Expand Down
79 changes: 0 additions & 79 deletions cmd/tapcli/tapdevrpc_active.go

This file was deleted.

7 changes: 0 additions & 7 deletions cmd/tapcli/tapdevrpc_default.go

This file was deleted.

11 changes: 5 additions & 6 deletions itest/addrs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import (
"github.com/lightninglabs/taproot-assets/taprpc"
wrpc "github.com/lightninglabs/taproot-assets/taprpc/assetwalletrpc"
"github.com/lightninglabs/taproot-assets/taprpc/mintrpc"
"github.com/lightninglabs/taproot-assets/taprpc/tapdevrpc"
unirpc "github.com/lightninglabs/taproot-assets/taprpc/universerpc"
"github.com/lightninglabs/taproot-assets/universe"
"github.com/lightningnetwork/lnd/lntest/wait"
Expand Down Expand Up @@ -840,7 +839,7 @@ func testUnknownTlvType(t *harnessTest) {
// using the development only ImportProof RPC on the destination node.
func sendProof(t *harnessTest, src, dst *tapdHarness,
sendResp *taprpc.SendAssetResponse, scriptKey []byte,
genInfo *taprpc.GenesisInfo) *tapdevrpc.ImportProofResponse {
genInfo *taprpc.GenesisInfo) *taprpc.ImportProofResponse {

proofResp := exportProof(t, src, sendResp, scriptKey, genInfo)
return importProof(t, dst, proofResp.RawProofFile, genInfo.GenesisPoint)
Expand Down Expand Up @@ -892,12 +891,12 @@ func exportProof(t *harnessTest, src *tapdHarness,
// importProof manually imports a proof using the development only ImportProof
// RPC.
func importProof(t *harnessTest, dst *tapdHarness, rawFile []byte,
genesisPoint string) *tapdevrpc.ImportProofResponse {
genesisPoint string) *taprpc.ImportProofResponse {

t.Logf("Importing proof %x", rawFile)

ctxb := context.Background()
importResp, err := dst.ImportProof(ctxb, &tapdevrpc.ImportProofRequest{
importResp, err := dst.ImportProof(ctxb, &taprpc.ImportProofRequest{
ProofFile: rawFile,
GenesisPoint: genesisPoint,
})
Expand All @@ -910,7 +909,7 @@ func importProof(t *harnessTest, dst *tapdHarness, rawFile []byte,
// universe RPCs and then imports it into the destination node.
func sendUniProof(t *harnessTest, src, dst *tapdHarness, scriptKey []byte,
genInfo *taprpc.GenesisInfo, group *taprpc.AssetGroup,
outpoint string) *tapdevrpc.ImportProofResponse {
outpoint string) *taprpc.ImportProofResponse {

ctxb := context.Background()
ctxt, cancel := context.WithTimeout(ctxb, defaultWaitTimeout)
Expand Down Expand Up @@ -990,7 +989,7 @@ func sendUniProof(t *harnessTest, src, dst *tapdHarness, scriptKey []byte,

t.Logf("Importing proof %x", buf.Bytes())

importResp, err := dst.ImportProof(ctxb, &tapdevrpc.ImportProofRequest{
importResp, err := dst.ImportProof(ctxb, &taprpc.ImportProofRequest{
ProofFile: buf.Bytes(),
GenesisPoint: genInfo.GenesisPoint,
})
Expand Down
3 changes: 1 addition & 2 deletions itest/assets_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import (
"github.com/lightninglabs/taproot-assets/taprpc"
wrpc "github.com/lightninglabs/taproot-assets/taprpc/assetwalletrpc"
"github.com/lightninglabs/taproot-assets/taprpc/mintrpc"
"github.com/lightninglabs/taproot-assets/taprpc/tapdevrpc"
"github.com/lightningnetwork/lnd/lnrpc"
"github.com/lightningnetwork/lnd/lnrpc/walletrpc"
"github.com/stretchr/testify/require"
Expand Down Expand Up @@ -229,7 +228,7 @@ func transferAssetProofs(t *harnessTest, src, dst *tapdHarness,
proofFile := AssertAssetProofs(
t.t, src, chainClient, existingAsset,
)
_, err := dst.ImportProof(ctxt, &tapdevrpc.ImportProofRequest{
_, err := dst.ImportProof(ctxt, &taprpc.ImportProofRequest{
ProofFile: proofFile,
GenesisPoint: gen.GenesisPoint,
})
Expand Down
4 changes: 2 additions & 2 deletions itest/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -507,7 +507,7 @@ func ConfirmBatch(t *testing.T, minerClient *rpcclient.Client,

func ManualMintSimpleAsset(t *harnessTest, lndNode *node.HarnessNode,
tapClient *tapdHarness, commitVersion commitment.TapCommitmentVersion,
req *mintrpc.MintAsset) (*taprpc.Asset, *tapdevrpc.ImportProofRequest) {
req *mintrpc.MintAsset) (*taprpc.Asset, *taprpc.ImportProofRequest) {

ctxb := context.Background()
ctxt, cancel := context.WithTimeout(ctxb, defaultWaitTimeout)
Expand Down Expand Up @@ -668,7 +668,7 @@ func ManualMintSimpleAsset(t *harnessTest, lndNode *node.HarnessNode,
require.NoError(t.t, err)
require.True(t.t, proof.IsProofFile(proofBlob))

importReq := tapdevrpc.ImportProofRequest{
importReq := taprpc.ImportProofRequest{
ProofFile: proofBlob,
GenesisPoint: genesisOutpoint.String(),
}
Expand Down
8 changes: 4 additions & 4 deletions perms/perms.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,10 @@ var (
Entity: "assets",
Action: "read",
}},
"/taprpc.TaprootAssets/ImportProof": {{
Entity: "proofs",
Action: "write",
}},
"/assetwalletrpc.AssetWallet/FundVirtualPsbt": {{
Entity: "assets",
Action: "write",
Expand Down Expand Up @@ -280,10 +284,6 @@ var (
// This RPC is completely stateless and doesn't require
// any permissions to use.
},
"/tapdevrpc.TapDev/ImportProof": {{
Entity: "proofs",
Action: "write",
}},
"/tapdevrpc.TapDev/SubscribeSendAssetEventNtfns": {{
Entity: "assets",
Action: "write",
Expand Down
4 changes: 2 additions & 2 deletions rpcserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -1899,7 +1899,7 @@ func (r *rpcServer) ExportProof(ctx context.Context,
// new asset will be inserted on disk, spendable using the specified target
// script key, and internal key.
func (r *rpcServer) ImportProof(ctx context.Context,
req *tapdevrpc.ImportProofRequest) (*tapdevrpc.ImportProofResponse,
req *taprpc.ImportProofRequest) (*taprpc.ImportProofResponse,
error) {

// We'll perform some basic input validation before we move forward.
Expand Down Expand Up @@ -1939,7 +1939,7 @@ func (r *rpcServer) ImportProof(ctx context.Context,
return nil, err
}

return &tapdevrpc.ImportProofResponse{}, nil
return &taprpc.ImportProofResponse{}, nil
}

// AddrReceives lists all receives for incoming asset transfers for addresses
Expand Down
1 change: 1 addition & 0 deletions taprpc/gen_protos.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ tapchannelrpc/tapchannel.proto"

# Generate the REST reverse proxy.
annotationsFile=${file//proto/yaml}
echo $annotationsFile
protoc -I/usr/local/include -I. \
-I/tmp/build/.modcache/github.com/lightningnetwork/lnd@${LND_VERSION}/lnrpc \
--grpc-gateway_out . \
Expand Down
Loading
Loading