Skip to content

Commit

Permalink
taprpc/tapchannelrpc: add new DecodeAssetPayReq command
Browse files Browse the repository at this point in the history
  • Loading branch information
Roasbeef committed Dec 13, 2024
1 parent 35d8f1c commit 515a0b2
Show file tree
Hide file tree
Showing 6 changed files with 736 additions and 162 deletions.
6 changes: 6 additions & 0 deletions rpcserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -7713,3 +7713,9 @@ func (r *rpcServer) getInboundPolicy(ctx context.Context, chanID uint64,

return policy, nil
}
// DecodeAssetPayReq decodes an incoming invoice, then uses the RFQ system to
// map the BTC amount to the amount of asset units for the specified asset ID.
func (r *rpcServer) DecodeAssetPayReq(ctx context.Context,
payReq *tchrpc.AssetPayReqString) (*tchrpc.AssetPayReq, error) {
return &resp, nil
}
536 changes: 374 additions & 162 deletions taprpc/tapchannelrpc/tapchannel.pb.go

Large diffs are not rendered by default.

35 changes: 35 additions & 0 deletions taprpc/tapchannelrpc/tapchannel.proto
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ option go_package = "github.com/lightninglabs/taproot-assets/taprpc/tapchannelrp
import "rfqrpc/rfq.proto";
import "lightning.proto";
import "routerrpc/router.proto";
import "taprootassets.proto";

service TaprootAssetChannels {
/*
Expand Down Expand Up @@ -39,6 +40,13 @@ service TaprootAssetChannels {
to the specified asset amount.
*/
rpc AddInvoice (AddInvoiceRequest) returns (AddInvoiceResponse);

/*
DecodeAssetPayReq is similar to lnd's lnrpc.DecodePayReq, but it accepts
an asset_id and returns the invoice amount expressed in asset
units along side the normal information.
*/
rpc DecodeAssetPayReq (AssetPayReqString) returns (AssetPayReq);
}

message FundChannelRequest {
Expand Down Expand Up @@ -181,3 +189,30 @@ message AddInvoiceResponse {
// The result of the invoice creation.
lnrpc.AddInvoiceResponse invoice_result = 2;
}

message AssetPayReqString {
// The asset ID that will be used to resolve the invoice's satoshi amount.
bytes asset_id = 1;

// The normal LN invoice that whose amount will be mapped to units of the
// asset ID.
lnrpc.PayReqString pay_req_string = 2;
}

message AssetPayReq {
// The invoice amount, expressed in sats.
uint64 asset_amount = 1;

// The decimal display corresponding to the asset_id.
taprpc.DecimalDisplay decimal_display = 2;

// The group the asset ID belong to, if applicable.
taprpc.AssetGroup asset_group = 3;

// Genesis information for the asset ID which includes the meta hash, and
// asset_id.
taprpc.GenesisInfo genesis_info = 4;

// The normal decoded payment request.
lnrpc.PayReq pay_req = 5;
}
254 changes: 254 additions & 0 deletions taprpc/tapchannelrpc/tapchannel.swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,44 @@
}
}
},
"lnrpcBlindedHop": {
"type": "object",
"properties": {
"blinded_node": {
"type": "string",
"format": "byte",
"description": "The blinded public key of the node."
},
"encrypted_data": {
"type": "string",
"format": "byte",
"description": "An encrypted blob of data provided to the blinded node."
}
}
},
"lnrpcBlindedPath": {
"type": "object",
"properties": {
"introduction_node": {
"type": "string",
"format": "byte",
"description": "The unblinded pubkey of the introduction node for the route."
},
"blinding_point": {
"type": "string",
"format": "byte",
"description": "The ephemeral pubkey used by nodes in the blinded route."
},
"blinded_hops": {
"type": "array",
"items": {
"type": "object",
"$ref": "#/definitions/lnrpcBlindedHop"
},
"description": "A set of blinded node keys and data blobs for the blinded portion of the\nroute. Note that the first hop is expected to be the introduction node,\nso the route is always expected to have at least one hop."
}
}
},
"lnrpcBlindedPathConfig": {
"type": "object",
"properties": {
Expand Down Expand Up @@ -337,6 +375,47 @@
}
}
},
"lnrpcBlindedPaymentPath": {
"type": "object",
"properties": {
"blinded_path": {
"$ref": "#/definitions/lnrpcBlindedPath",
"description": "The blinded path to send the payment to."
},
"base_fee_msat": {
"type": "string",
"format": "uint64",
"description": "The base fee for the blinded path provided, expressed in msat."
},
"proportional_fee_rate": {
"type": "integer",
"format": "int64",
"description": "The proportional fee for the blinded path provided, expressed in parts\nper million."
},
"total_cltv_delta": {
"type": "integer",
"format": "int64",
"description": "The total CLTV delta for the blinded path provided, including the\nfinal CLTV delta for the receiving node."
},
"htlc_min_msat": {
"type": "string",
"format": "uint64",
"description": "The minimum hltc size that may be sent over the blinded path, expressed\nin msat."
},
"htlc_max_msat": {
"type": "string",
"format": "uint64",
"description": "The maximum htlc size that may be sent over the blinded path, expressed\nin msat."
},
"features": {
"type": "array",
"items": {
"$ref": "#/definitions/lnrpcFeatureBit"
},
"description": "The feature bits for the route."
}
}
},
"lnrpcChannelUpdate": {
"type": "object",
"properties": {
Expand Down Expand Up @@ -880,6 +959,79 @@
}
}
},
"lnrpcPayReq": {
"type": "object",
"properties": {
"destination": {
"type": "string"
},
"payment_hash": {
"type": "string"
},
"num_satoshis": {
"type": "string",
"format": "int64"
},
"timestamp": {
"type": "string",
"format": "int64"
},
"expiry": {
"type": "string",
"format": "int64"
},
"description": {
"type": "string"
},
"description_hash": {
"type": "string"
},
"fallback_addr": {
"type": "string"
},
"cltv_expiry": {
"type": "string",
"format": "int64"
},
"route_hints": {
"type": "array",
"items": {
"type": "object",
"$ref": "#/definitions/lnrpcRouteHint"
}
},
"payment_addr": {
"type": "string",
"format": "byte"
},
"num_msat": {
"type": "string",
"format": "int64"
},
"features": {
"type": "object",
"additionalProperties": {
"$ref": "#/definitions/lnrpcFeature"
}
},
"blinded_paths": {
"type": "array",
"items": {
"type": "object",
"$ref": "#/definitions/lnrpcBlindedPaymentPath"
}
}
}
},
"lnrpcPayReqString": {
"type": "object",
"properties": {
"pay_req": {
"type": "string",
"title": "The payment request string to be decoded"
}
}
},
"lnrpcPayment": {
"type": "object",
"properties": {
Expand Down Expand Up @@ -1342,6 +1494,32 @@
}
}
},
"tapchannelrpcAssetPayReq": {
"type": "object",
"properties": {
"asset_amount": {
"type": "string",
"format": "uint64",
"description": "The invoice amount, expressed in sats."
},
"decimal_display": {
"$ref": "#/definitions/taprpcDecimalDisplay",
"description": "The decimal display corresponding to the asset_id."
},
"asset_group": {
"$ref": "#/definitions/taprpcAssetGroup",
"description": "The group the asset ID belong to, if applicable."
},
"genesis_info": {
"$ref": "#/definitions/taprpcGenesisInfo",
"description": "Genesis information for the asset ID which includes the meta hash, and\nasset_id."
},
"pay_req": {
"$ref": "#/definitions/lnrpcPayReq",
"description": "The normal decoded payment request."
}
}
},
"tapchannelrpcEncodeCustomRecordsRequest": {
"type": "object",
"properties": {
Expand Down Expand Up @@ -1475,6 +1653,82 @@
"description": "The payment result of a single payment attempt. Multiple attempts may\nbe returned per payment request until either the payment succeeds or\nthe payment times out."
}
}
},
"taprpcAssetGroup": {
"type": "object",
"properties": {
"raw_group_key": {
"type": "string",
"format": "byte",
"description": "The raw group key which is a normal public key."
},
"tweaked_group_key": {
"type": "string",
"format": "byte",
"description": "The tweaked group key, which is derived based on the genesis point and also\nasset type."
},
"asset_witness": {
"type": "string",
"format": "byte",
"description": "A witness that authorizes a specific asset to be part of the asset group\nspecified by the above key."
},
"tapscript_root": {
"type": "string",
"format": "byte",
"description": "The root hash of a tapscript tree, which enables future issuance authorized\nwith a script witness."
}
}
},
"taprpcAssetType": {
"type": "string",
"enum": [
"NORMAL",
"COLLECTIBLE"
],
"default": "NORMAL",
"description": " - NORMAL: Indicates that an asset is capable of being split/merged, with each of the\nunits being fungible, even across a key asset ID boundary (assuming the\nkey group is the same).\n - COLLECTIBLE: Indicates that an asset is a collectible, meaning that each of the other\nitems under the same key group are not fully fungible with each other.\nCollectibles also cannot be split or merged."
},
"taprpcDecimalDisplay": {
"type": "object",
"properties": {
"decimal_display": {
"type": "integer",
"format": "int64",
"description": "Decimal display dictates the number of decimal places to shift the amount to\nthe left converting from Taproot Asset integer representation to a\nUX-recognizable fractional quantity.\n\nFor example, if the decimal_display value is 2 and there's 100 of those\nassets, then a wallet would display the amount as \"1.00\". This field is\nintended as information for wallets that display balances and has no impact\non the behavior of the daemon or any other part of the protocol. This value\nis encoded in the MetaData field as a JSON field, therefore it is only\ncompatible with assets that have a JSON MetaData field."
}
}
},
"taprpcGenesisInfo": {
"type": "object",
"properties": {
"genesis_point": {
"type": "string",
"description": "The first outpoint of the transaction that created the asset (txid:vout)."
},
"name": {
"type": "string",
"description": "The name of the asset."
},
"meta_hash": {
"type": "string",
"format": "byte",
"description": "The hash of the meta data for this genesis asset."
},
"asset_id": {
"type": "string",
"format": "byte",
"description": "The asset ID that uniquely identifies the asset."
},
"asset_type": {
"$ref": "#/definitions/taprpcAssetType",
"description": "The type of the asset."
},
"output_index": {
"type": "integer",
"format": "int64",
"description": "The index of the output that carries the unique Taproot Asset commitment in\nthe genesis transaction."
}
}
}
}
}
Loading

0 comments on commit 515a0b2

Please sign in to comment.