-
Notifications
You must be signed in to change notification settings - Fork 137
Open
Labels
Description
I'm trying to use DecodeAssetPayReq with a group_key defined but I'm getting the error
error deriving asset amount: error querying ask price: OracleError(code=0, msg=Unsupported subject asset)
even though my price oracle is configured for the group_key. Then I look at the code and I see that DecodeAssetPayReq tries to request the price of the first asset_id in the group:
Lines 9667 to 9720 in 8ff0ae9
| // The group key is a bit more involved. We first need to sync the asset | |
| // group, then fetch the leaves that are associated with this group key. | |
| // From there, we can look up the asset ID of one of the group's | |
| // tranches. | |
| case len(payReq.GroupKey) != 0: | |
| var ( | |
| groupKey *btcec.PublicKey | |
| err error | |
| ) | |
| if len(payReq.GroupKey) == 32 { | |
| groupKey, err = schnorr.ParsePubKey(payReq.GroupKey) | |
| } else { | |
| groupKey, err = btcec.ParsePubKey(payReq.GroupKey) | |
| } | |
| if err != nil { | |
| return nil, fmt.Errorf("error parsing group "+ | |
| "key: %w", err) | |
| } | |
| assetID, err = r.syncAssetGroup(ctx, *groupKey) | |
| if err != nil { | |
| return nil, fmt.Errorf("error syncing asset group: %w", | |
| err) | |
| } | |
| tapdLog.Debugf("Resolved asset ID %v for group key %x", | |
| assetID.String(), groupKey.SerializeCompressed()) | |
| } | |
| // With the inputs validated, we'll first call out to lnd to decode the | |
| // payment request. | |
| rpcCtx, _, rawClient := r.cfg.Lnd.Client.RawClientWithMacAuth(ctx) | |
| payReqInfo, err := rawClient.DecodePayReq(rpcCtx, &lnrpc.PayReqString{ | |
| PayReq: payReq.PayReqString, | |
| }) | |
| if err != nil { | |
| return nil, fmt.Errorf("unable to fetch channel: %w", err) | |
| } | |
| resp := tchrpc.AssetPayReqResponse{ | |
| PayReq: payReqInfo, | |
| } | |
| // Next, we'll fetch the information for this asset ID through the addr | |
| // book. This'll automatically fetch the asset if needed. | |
| assetGroup, err := r.cfg.AddrBook.QueryAssetInfo( | |
| ctx, asset.NewSpecifierFromId(assetID), | |
| ) | |
| if err != nil { | |
| return nil, fmt.Errorf("unable to fetch asset info for "+ | |
| "asset_id=%x: %w", assetID[:], err) | |
| } | |
but my price oracle doesn't know about all the asset tranches, so that is why I'm thinking it is failing.
I don't think DecodeAssetPayReq should query the price oracle based on the first asset_id in the group. Instead, it should query the price oracle based on the group_key, I think that is what all the other RPC do that support group_key.