Skip to content

Commit cdd6707

Browse files
authored
Merge pull request #663 from GeorgeTsagk/rpc-remove-anchor-txid
RPC: Remove `anchor_txid` from `AnchorInfo`
2 parents 12d2439 + da6dcea commit cdd6707

File tree

8 files changed

+731
-749
lines changed

8 files changed

+731
-749
lines changed

itest/assertions.go

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,10 +69,17 @@ func AssetAnchorCheck(txid, blockHash chainhash.Hash) AssetCheck {
6969
return fmt.Errorf("asset is missing chain anchor field")
7070
}
7171

72-
if a.ChainAnchor.AnchorTxid != txid.String() {
72+
out, err :=
73+
wire.NewOutPointFromString(a.ChainAnchor.AnchorOutpoint)
74+
if err != nil {
75+
return fmt.Errorf("unable to parse outpoint: %v", err)
76+
}
77+
78+
anchorTxid := out.Hash.String()
79+
80+
if anchorTxid != txid.String() {
7381
return fmt.Errorf("unexpected asset anchor TXID, got "+
74-
"%v wanted %x", a.ChainAnchor.AnchorTxid,
75-
txid[:])
82+
"%v wanted %x", anchorTxid, txid[:])
7683
}
7784

7885
if a.ChainAnchor.AnchorBlockHash != blockHash.String() {

itest/assets_test.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
"time"
88

99
"github.com/btcsuite/btcd/chaincfg/chainhash"
10+
"github.com/btcsuite/btcd/wire"
1011
"github.com/lightninglabs/taproot-assets/fn"
1112
"github.com/lightninglabs/taproot-assets/proof"
1213
"github.com/lightninglabs/taproot-assets/taprpc"
@@ -173,11 +174,13 @@ func transferAssetProofs(t *harnessTest, src, dst *tapdHarness,
173174
importedAssets := GroupAssetsByName(listResp.Assets)
174175
for _, existingAsset := range assets {
175176
gen := existingAsset.AssetGenesis
176-
anchorTxHash, err := chainhash.NewHashFromStr(
177-
existingAsset.ChainAnchor.AnchorTxid,
177+
out, err := wire.NewOutPointFromString(
178+
existingAsset.ChainAnchor.AnchorOutpoint,
178179
)
179180
require.NoError(t.t, err)
180181

182+
anchorTxHash := out.Hash
183+
181184
anchorBlockHash, err := chainhash.NewHashFromStr(
182185
existingAsset.ChainAnchor.AnchorBlockHash,
183186
)
@@ -187,7 +190,7 @@ func transferAssetProofs(t *harnessTest, src, dst *tapdHarness,
187190
t.t, importedAssets, gen.Name, gen.MetaHash,
188191
AssetAmountCheck(existingAsset.Amount),
189192
AssetTypeCheck(existingAsset.AssetGenesis.AssetType),
190-
AssetAnchorCheck(*anchorTxHash, *anchorBlockHash),
193+
AssetAnchorCheck(anchorTxHash, *anchorBlockHash),
191194
AssetScriptKeyIsLocalCheck(shouldShowUpAsLocal),
192195
)
193196
}

rpcserver.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -727,7 +727,6 @@ func (r *rpcServer) marshalChainAsset(ctx context.Context, a *tapdb.ChainAsset,
727727

728728
rpcAsset.ChainAnchor = &taprpc.AnchorInfo{
729729
AnchorTx: anchorTxBytes,
730-
AnchorTxid: a.AnchorTxid.String(),
731730
AnchorBlockHash: a.AnchorBlockHash.String(),
732731
AnchorOutpoint: a.AnchorOutpoint.String(),
733732
InternalKey: a.AnchorInternalKey.SerializeCompressed(),
@@ -1380,7 +1379,6 @@ func (r *rpcServer) marshalProof(ctx context.Context, p *proof.Proof,
13801379
rpcAsset, err := r.marshalChainAsset(ctx, &tapdb.ChainAsset{
13811380
Asset: &p.Asset,
13821381
AnchorTx: &p.AnchorTx,
1383-
AnchorTxid: p.AnchorTx.TxHash(),
13841382
AnchorBlockHash: p.BlockHeader.BlockHash(),
13851383
AnchorBlockHeight: p.BlockHeight,
13861384
AnchorOutpoint: anchorOutpoint,

tapdb/assets_store.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -362,9 +362,6 @@ type ChainAsset struct {
362362
// AnchorTx is the transaction that anchors this chain asset.
363363
AnchorTx *wire.MsgTx
364364

365-
// AnchorTxid is the TXID of the anchor tx.
366-
AnchorTxid chainhash.Hash
367-
368365
// AnchorBlockHash is the blockhash that mined the anchor tx.
369366
AnchorBlockHash chainhash.Hash
370367

@@ -761,7 +758,6 @@ func (a *AssetStore) dbAssetsToChainAssets(dbAssets []ConfirmedAsset,
761758
Asset: assetSprout,
762759
IsSpent: sprout.Spent,
763760
AnchorTx: anchorTx,
764-
AnchorTxid: anchorTx.TxHash(),
765761
AnchorBlockHash: anchorBlockHash,
766762
AnchorOutpoint: anchorOutpoint,
767763
AnchorInternalKey: anchorInternalKey,

taprpc/taprootassets.pb.go

Lines changed: 715 additions & 726 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

taprpc/taprootassets.proto

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -183,9 +183,6 @@ message AnchorInfo {
183183
// resides.
184184
bytes anchor_tx = 1;
185185

186-
// The txid of the above transaction.
187-
string anchor_txid = 2;
188-
189186
// The block hash the contains the anchor transaction above.
190187
string anchor_block_hash = 3;
191188

taprpc/taprootassets.swagger.json

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -976,10 +976,6 @@
976976
"format": "byte",
977977
"description": "The transaction that anchors the Taproot Asset commitment where the asset\n resides."
978978
},
979-
"anchor_txid": {
980-
"type": "string",
981-
"description": "The txid of the above transaction."
982-
},
983979
"anchor_block_hash": {
984980
"type": "string",
985981
"description": "The block hash the contains the anchor transaction above."

taprpc/universerpc/universe.swagger.json

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1304,10 +1304,6 @@
13041304
"format": "byte",
13051305
"description": "The transaction that anchors the Taproot Asset commitment where the asset\n resides."
13061306
},
1307-
"anchor_txid": {
1308-
"type": "string",
1309-
"description": "The txid of the above transaction."
1310-
},
13111307
"anchor_block_hash": {
13121308
"type": "string",
13131309
"description": "The block hash the contains the anchor transaction above."

0 commit comments

Comments
 (0)