Skip to content

Commit 851dcad

Browse files
authored
Merge pull request #1491 from bhandras/queryparcels-output-pkscript
tapdb: correctly fill pkScript for outputs of QueryParcels
2 parents d9dd3c0 + 8e982f5 commit 851dcad

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

tapdb/assets_store.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3542,6 +3542,13 @@ func (a *AssetStore) QueryParcels(ctx context.Context,
35423542
"anchor tx: %w", err)
35433543
}
35443544

3545+
// Fill in the anchor transaction's output pkScripts.
3546+
for i, out := range outputs {
3547+
outIdx := out.Anchor.OutPoint.Index
3548+
pkScript := anchorTx.TxOut[outIdx].PkScript
3549+
outputs[i].Anchor.PkScript = pkScript
3550+
}
3551+
35453552
// Marshal anchor tx block hash from the database to a
35463553
// Hash type.
35473554
var anchorTxBlockHash fn.Option[chainhash.Hash]

tapdb/assets_store_test.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1597,6 +1597,11 @@ func TestAssetExportLog(t *testing.T) {
15971597
PkScript: bytes.Repeat([]byte{0x01}, 34),
15981598
Value: 1000,
15991599
})
1600+
newAnchorTx.AddTxOut(&wire.TxOut{
1601+
PkScript: bytes.Repeat([]byte{0x02}, 34),
1602+
Value: 1000,
1603+
})
1604+
16001605
const heightHint = 1450
16011606

16021607
newScriptKey := asset.NewScriptKeyBip86(keychain.KeyDescriptor{
@@ -1691,6 +1696,7 @@ func TestAssetExportLog(t *testing.T) {
16911696
// application sets it properly.
16921697
TaprootAssetRoot: bytes.Repeat([]byte{0x1}, 32),
16931698
MerkleRoot: bytes.Repeat([]byte{0x1}, 32),
1699+
PkScript: bytes.Repeat([]byte{0x1}, 34),
16941700
},
16951701
ScriptKey: newScriptKey,
16961702
ScriptKeyLocal: true,
@@ -1727,6 +1733,7 @@ func TestAssetExportLog(t *testing.T) {
17271733
// application sets it properly.
17281734
TaprootAssetRoot: bytes.Repeat([]byte{0x1}, 32),
17291735
MerkleRoot: bytes.Repeat([]byte{0x1}, 32),
1736+
PkScript: bytes.Repeat([]byte{0x2}, 34),
17301737
},
17311738
ScriptKey: newScriptKey2,
17321739
ScriptKeyLocal: true,

0 commit comments

Comments
 (0)