Skip to content

Commit ca6de1a

Browse files
committed
tapdb: fix passive asset re-anchoring
When re-anchoring a passive asset, we need to reset any time locks it previously had on it. Because the re-anchoring is a normal transfer with just a simple signature, we need to clear any previous restrictions. The ReAnchorPassiveAssets query basically needs to mirror what the asset.CopySpendTemplate() method does.
1 parent 184f02e commit ca6de1a

File tree

3 files changed

+10
-3
lines changed

3 files changed

+10
-3
lines changed

tapdb/assets_store.go

-1
Original file line numberDiff line numberDiff line change
@@ -2288,7 +2288,6 @@ func (a *AssetStore) queryCommitments(ctx context.Context,
22882288
map[wire.OutPoint]*commitment.TapCommitment,
22892289
)
22902290
for anchorPoint := range chainAnchorToAssets {
2291-
anchorPoint := anchorPoint
22922291
anchorUTXO := anchorPoints[anchorPoint]
22932292
anchoredAssets := chainAnchorToAssets[anchorPoint]
22942293
anchoredAltLeaves := anchorAltLeaves[anchorPoint]

tapdb/sqlc/queries/transfers.sql

+5-1
Original file line numberDiff line numberDiff line change
@@ -137,8 +137,12 @@ RETURNING asset_id;
137137
-- name: ReAnchorPassiveAssets :exec
138138
UPDATE assets
139139
SET anchor_utxo_id = @new_anchor_utxo_id,
140+
-- The following fields need to be the same fields we reset in
141+
-- Asset.CopySpendTemplate.
140142
split_commitment_root_hash = NULL,
141-
split_commitment_root_value = NULL
143+
split_commitment_root_value = NULL,
144+
lock_time = 0,
145+
relative_lock_time = 0
142146
WHERE asset_id = @asset_id;
143147

144148
-- name: DeleteAssetWitnesses :exec

tapdb/sqlc/transfers.sql.go

+5-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)