Skip to content

Commit 3dac194

Browse files
committed
tapdb: return lease owner and expiry for managed UTXOs
This should help us track down issues when assets aren't unlocked even though they should be. We also extend an existing unit test to ensure these values are properly set.
1 parent f5d39c9 commit 3dac194

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed

tapdb/assets_store.go

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -417,6 +417,14 @@ type ManagedUTXO struct {
417417
// TapscriptSibling is the serialized tapscript sibling preimage of
418418
// this asset. This will usually be blank.
419419
TapscriptSibling []byte
420+
421+
// LeaseOwner is the identifier of the lease owner of this UTXO. If
422+
// blank, this UTXO isn't leased.
423+
LeaseOwner []byte
424+
425+
// LeaseExpiry is the expiry time of the lease on this UTXO. If the
426+
// zero, then this UTXO isn't leased.
427+
LeaseExpiry time.Time
420428
}
421429

422430
// AssetHumanReadable is a subset of the base asset struct that only includes
@@ -1125,7 +1133,7 @@ func (a *AssetStore) FetchManagedUTXOs(ctx context.Context) (
11251133
return nil, err
11261134
}
11271135

1128-
managedUtxos[i] = &ManagedUTXO{
1136+
utxo := &ManagedUTXO{
11291137
OutPoint: anchorPoint,
11301138
OutputValue: btcutil.Amount(u.AmtSats),
11311139
InternalKey: keychain.KeyDescriptor{
@@ -1140,7 +1148,13 @@ func (a *AssetStore) FetchManagedUTXOs(ctx context.Context) (
11401148
TaprootAssetRoot: u.TaprootAssetRoot,
11411149
MerkleRoot: u.MerkleRoot,
11421150
TapscriptSibling: u.TapscriptSibling,
1151+
LeaseOwner: u.LeaseOwner,
11431152
}
1153+
if u.LeaseExpiry.Valid {
1154+
utxo.LeaseExpiry = u.LeaseExpiry.Time
1155+
}
1156+
1157+
managedUtxos[i] = utxo
11441158
}
11451159

11461160
return managedUtxos, nil

tapdb/assets_store_test.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1465,8 +1465,11 @@ func TestAssetExportLog(t *testing.T) {
14651465
require.NoError(t, err)
14661466
require.Len(t, utxos, 3)
14671467

1468-
// First UTXO should remain unchanged.
1468+
// First UTXO should remain unchanged. It should now have a lease
1469+
// expiry and owner set.
14691470
require.Equal(t, assetGen.anchorPoints[0], utxos[0].OutPoint)
1471+
require.Equal(t, leaseOwner[:], utxos[0].LeaseOwner[:])
1472+
require.NotZero(t, utxos[0].LeaseExpiry)
14701473

14711474
// Second UTXO will be our new one.
14721475
newUtxo := utxos[1]

0 commit comments

Comments
 (0)