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

RPC: Remove anchor_txid from AnchorInfo #663

Merged
merged 3 commits into from
Nov 9, 2023
Merged
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
13 changes: 10 additions & 3 deletions itest/assertions.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,17 @@ func AssetAnchorCheck(txid, blockHash chainhash.Hash) AssetCheck {
return fmt.Errorf("asset is missing chain anchor field")
}

if a.ChainAnchor.AnchorTxid != txid.String() {
out, err :=
wire.NewOutPointFromString(a.ChainAnchor.AnchorOutpoint)
if err != nil {
return fmt.Errorf("unable to parse outpoint: %v", err)
}

anchorTxid := out.Hash.String()

if anchorTxid != txid.String() {
return fmt.Errorf("unexpected asset anchor TXID, got "+
"%v wanted %x", a.ChainAnchor.AnchorTxid,
txid[:])
"%v wanted %x", anchorTxid, txid[:])
}

if a.ChainAnchor.AnchorBlockHash != blockHash.String() {
Expand Down
9 changes: 6 additions & 3 deletions itest/assets_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"time"

"github.com/btcsuite/btcd/chaincfg/chainhash"
"github.com/btcsuite/btcd/wire"
"github.com/lightninglabs/taproot-assets/fn"
"github.com/lightninglabs/taproot-assets/proof"
"github.com/lightninglabs/taproot-assets/taprpc"
Expand Down Expand Up @@ -173,11 +174,13 @@ func transferAssetProofs(t *harnessTest, src, dst *tapdHarness,
importedAssets := GroupAssetsByName(listResp.Assets)
for _, existingAsset := range assets {
gen := existingAsset.AssetGenesis
anchorTxHash, err := chainhash.NewHashFromStr(
existingAsset.ChainAnchor.AnchorTxid,
out, err := wire.NewOutPointFromString(
existingAsset.ChainAnchor.AnchorOutpoint,
)
require.NoError(t.t, err)

anchorTxHash := out.Hash

anchorBlockHash, err := chainhash.NewHashFromStr(
existingAsset.ChainAnchor.AnchorBlockHash,
)
Expand All @@ -187,7 +190,7 @@ func transferAssetProofs(t *harnessTest, src, dst *tapdHarness,
t.t, importedAssets, gen.Name, gen.MetaHash,
AssetAmountCheck(existingAsset.Amount),
AssetTypeCheck(existingAsset.AssetGenesis.AssetType),
AssetAnchorCheck(*anchorTxHash, *anchorBlockHash),
AssetAnchorCheck(anchorTxHash, *anchorBlockHash),
AssetScriptKeyIsLocalCheck(shouldShowUpAsLocal),
)
}
Expand Down
2 changes: 0 additions & 2 deletions rpcserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -727,7 +727,6 @@ func (r *rpcServer) marshalChainAsset(ctx context.Context, a *tapdb.ChainAsset,

rpcAsset.ChainAnchor = &taprpc.AnchorInfo{
AnchorTx: anchorTxBytes,
AnchorTxid: a.AnchorTxid.String(),
AnchorBlockHash: a.AnchorBlockHash.String(),
AnchorOutpoint: a.AnchorOutpoint.String(),
InternalKey: a.AnchorInternalKey.SerializeCompressed(),
Expand Down Expand Up @@ -1380,7 +1379,6 @@ func (r *rpcServer) marshalProof(ctx context.Context, p *proof.Proof,
rpcAsset, err := r.marshalChainAsset(ctx, &tapdb.ChainAsset{
Asset: &p.Asset,
AnchorTx: &p.AnchorTx,
AnchorTxid: p.AnchorTx.TxHash(),
AnchorBlockHash: p.BlockHeader.BlockHash(),
AnchorBlockHeight: p.BlockHeight,
AnchorOutpoint: anchorOutpoint,
Expand Down
4 changes: 0 additions & 4 deletions tapdb/assets_store.go
Original file line number Diff line number Diff line change
Expand Up @@ -362,9 +362,6 @@ type ChainAsset struct {
// AnchorTx is the transaction that anchors this chain asset.
AnchorTx *wire.MsgTx

// AnchorTxid is the TXID of the anchor tx.
AnchorTxid chainhash.Hash

// AnchorBlockHash is the blockhash that mined the anchor tx.
AnchorBlockHash chainhash.Hash

Expand Down Expand Up @@ -761,7 +758,6 @@ func (a *AssetStore) dbAssetsToChainAssets(dbAssets []ConfirmedAsset,
Asset: assetSprout,
IsSpent: sprout.Spent,
AnchorTx: anchorTx,
AnchorTxid: anchorTx.TxHash(),
AnchorBlockHash: anchorBlockHash,
AnchorOutpoint: anchorOutpoint,
AnchorInternalKey: anchorInternalKey,
Expand Down
1,441 changes: 715 additions & 726 deletions taprpc/taprootassets.pb.go

Large diffs are not rendered by default.

3 changes: 0 additions & 3 deletions taprpc/taprootassets.proto
Original file line number Diff line number Diff line change
Expand Up @@ -183,9 +183,6 @@ message AnchorInfo {
// resides.
bytes anchor_tx = 1;

// The txid of the above transaction.
string anchor_txid = 2;

// The block hash the contains the anchor transaction above.
string anchor_block_hash = 3;

Expand Down
4 changes: 0 additions & 4 deletions taprpc/taprootassets.swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -976,10 +976,6 @@
"format": "byte",
"description": "The transaction that anchors the Taproot Asset commitment where the asset\n resides."
},
"anchor_txid": {
"type": "string",
"description": "The txid of the above transaction."
},
"anchor_block_hash": {
"type": "string",
"description": "The block hash the contains the anchor transaction above."
Expand Down
4 changes: 0 additions & 4 deletions taprpc/universerpc/universe.swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -1304,10 +1304,6 @@
"format": "byte",
"description": "The transaction that anchors the Taproot Asset commitment where the asset\n resides."
},
"anchor_txid": {
"type": "string",
"description": "The txid of the above transaction."
},
"anchor_block_hash": {
"type": "string",
"description": "The block hash the contains the anchor transaction above."
Expand Down