Skip to content
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
1 change: 1 addition & 0 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,7 @@ jobs:
working-directory: ./lightning-terminal
run: |
go mod edit -replace=github.com/lightninglabs/taproot-assets=../
go mod edit -replace=github.com/lightninglabs/taproot-assets/taprpc=../taprpc
go mod tidy

- name: Install yarn
Expand Down
29 changes: 25 additions & 4 deletions address/book.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,8 @@ type QueryParams struct {
// known to universe servers in our federation.
type AssetSyncer interface {
// SyncAssetInfo queries the universes in our federation for genesis
// and asset group information about the given asset ID.
SyncAssetInfo(ctx context.Context, assetID *asset.ID) error
// and asset group information about the given asset.
SyncAssetInfo(ctx context.Context, specifier asset.Specifier) error

// EnableAssetSync updates the sync config for the given asset so that
// we sync future issuance proofs.
Expand Down Expand Up @@ -232,7 +232,7 @@ func (b *Book) QueryAssetInfo(ctx context.Context,
log.Debugf("Asset %v is unknown, attempting to bootstrap", id.String())

// Use the AssetSyncer to query our universe federation for the asset.
err = b.cfg.Syncer.SyncAssetInfo(ctx, &id)
err = b.cfg.Syncer.SyncAssetInfo(ctx, asset.NewSpecifierFromId(id))
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -264,6 +264,27 @@ func (b *Book) QueryAssetInfo(ctx context.Context,
return assetGroup, nil
}

// SyncAssetGroup attempts to enable asset sync for the given asset group, then
// perform an initial sync with the federation for that group.
func (b *Book) SyncAssetGroup(ctx context.Context,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alternatively, we can have QueryAssetInfo accept an asset.Specifier.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The way the function is setup, if you call it twice, only the first time will it actually try to fetch data.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But QueryAssetInfo does the opposite of what we want: Given an asset ID it finds out what the group key is.
But what we need for this use case is: Given a group key, what asset IDs does that group contain?

groupKey btcec.PublicKey) error {

groupInfo := &asset.AssetGroup{
GroupKey: &asset.GroupKey{
GroupPubKey: groupKey,
},
}
err := b.cfg.Syncer.EnableAssetSync(ctx, groupInfo)
if err != nil {
return fmt.Errorf("unable to enable asset sync: %w", err)
}

// Use the AssetSyncer to query our universe federation for the asset.
return b.cfg.Syncer.SyncAssetInfo(
ctx, asset.NewSpecifierFromGroupKey(groupKey),
)
}

// FetchAssetMetaByHash attempts to fetch an asset meta based on an asset hash.
func (b *Book) FetchAssetMetaByHash(ctx context.Context,
metaHash [asset.MetaHashLen]byte) (*proof.MetaReveal, error) {
Expand Down Expand Up @@ -296,7 +317,7 @@ func (b *Book) FetchAssetMetaForAsset(ctx context.Context,
assetID.String())

// Use the AssetSyncer to query our universe federation for the asset.
err = b.cfg.Syncer.SyncAssetInfo(ctx, &assetID)
err = b.cfg.Syncer.SyncAssetInfo(ctx, asset.NewSpecifierFromId(assetID))
if err != nil {
return nil, err
}
Expand Down
5 changes: 4 additions & 1 deletion itest/channels_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,10 @@ func testChannelRPCs(t *harnessTest) {
require.NoError(t.t, err)

_, err = stream.Recv()
require.ErrorContains(t.t, err, "invalid vertex length of 0, want 33")
require.ErrorContains(
t.t, err, "destination node must be specified for keysend "+
"payment",
)

// Now let's also try the invoice path, which should fail because we
// don't have any asset channels with peers that we could ask for a
Expand Down
12 changes: 6 additions & 6 deletions rfq/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -579,7 +579,7 @@ func (m *Manager) addScidAlias(scidAlias uint64, assetSpecifier asset.Specifier,
continue
}

match, err := m.ChannelCompatible(
match, err := m.ChannelMatchesFully(
ctxb, assetData, assetSpecifier,
)
if err != nil {
Expand Down Expand Up @@ -1019,11 +1019,11 @@ func (m *Manager) GetPriceDeviationPpm() uint64 {
return m.cfg.AcceptPriceDeviationPpm
}

// ChannelCompatible checks a channel's assets against an asset specifier. If
// the specifier is an asset ID, then all assets must be of that specific ID,
// if the specifier is a group key, then all assets in the channel must belong
// to that group.
func (m *Manager) ChannelCompatible(ctx context.Context,
// ChannelMatchesFully checks a channel's assets against an asset specifier. If
// the specifier is an asset ID, then all asset UTXOs must be of that specific
// ID, if the specifier is a group key, then all assets in the channel must
// belong to that group.
func (m *Manager) ChannelMatchesFully(ctx context.Context,
jsonChannel rfqmsg.JsonAssetChannel, specifier asset.Specifier) (bool,
error) {

Expand Down
Loading
Loading