looprpc: extend client.proto with lnrpc.OutPoint and lnrpc.OpenChannelRequest

In this commit we import the lnd's lightning.proto into client.proto to
then be able to use lnrpc.OutPoint and lnrpc.OpenChannelRequest instead
of the looprpc.OutPoint type.
This is safe because the lnrpc and looprpc versions of OutPoint are the
same type.
This commit is contained in:
Slyghtning 2025-05-21 14:08:54 +02:00
parent 6aaacf8b93
commit f47b611557
No known key found for this signature in database
GPG key ID: F82D456EA023C9BF
7 changed files with 1002 additions and 584 deletions

View file

@ -14,6 +14,7 @@ import (
"github.com/lightninglabs/loop/staticaddr/deposit"
"github.com/lightninglabs/loop/staticaddr/loopin"
"github.com/lightninglabs/loop/swapserverrpc"
"github.com/lightningnetwork/lnd/lnrpc"
"github.com/lightningnetwork/lnd/routing/route"
"github.com/urfave/cli/v3"
)
@ -182,7 +183,7 @@ func withdraw(ctx context.Context, cmd *cli.Command) error {
var (
isAllSelected = cmd.IsSet("all")
isUtxoSelected = cmd.IsSet("utxo")
outpoints []*looprpc.OutPoint
outpoints []*lnrpc.OutPoint
destAddr string
)
@ -406,8 +407,8 @@ func summary(ctx context.Context, cmd *cli.Command) error {
return nil
}
func utxosToOutpoints(utxos []string) ([]*looprpc.OutPoint, error) {
outpoints := make([]*looprpc.OutPoint, 0, len(utxos))
func utxosToOutpoints(utxos []string) ([]*lnrpc.OutPoint, error) {
outpoints := make([]*lnrpc.OutPoint, 0, len(utxos))
if len(utxos) == 0 {
return nil, fmt.Errorf("no utxos specified")
}
@ -425,7 +426,7 @@ func utxosToOutpoints(utxos []string) ([]*looprpc.OutPoint, error) {
// NewProtoOutPoint parses an OutPoint into its corresponding lnrpc.OutPoint
// type.
func NewProtoOutPoint(op string) (*looprpc.OutPoint, error) {
func NewProtoOutPoint(op string) (*lnrpc.OutPoint, error) {
parts := strings.Split(op, ":")
if len(parts) != 2 {
return nil, errors.New("outpoint should be of the form " +
@ -440,7 +441,7 @@ func NewProtoOutPoint(op string) (*looprpc.OutPoint, error) {
return nil, fmt.Errorf("invalid output index: %v", err)
}
return &looprpc.OutPoint{
return &lnrpc.OutPoint{
TxidStr: txid,
OutputIndex: uint32(outputIndex),
}, nil

View file

@ -32,6 +32,7 @@ import (
"github.com/lightninglabs/loop/staticaddr/address"
"github.com/lightninglabs/loop/staticaddr/deposit"
"github.com/lightninglabs/loop/staticaddr/loopin"
"github.com/lightninglabs/loop/staticaddr/staticutil"
"github.com/lightninglabs/loop/staticaddr/withdraw"
"github.com/lightninglabs/loop/swap"
"github.com/lightninglabs/loop/swapserverrpc"
@ -1763,7 +1764,7 @@ func (s *swapClientServer) WithdrawDeposits(ctx context.Context,
}
case isUtxoSelected:
outpoints, err = toServerOutpoints(req.Outpoints)
outpoints, err = staticutil.ToWireOutpoints(req.Outpoints)
if err != nil {
return nil, err
}
@ -2328,23 +2329,6 @@ func toServerState(state looprpc.DepositState) fsm.StateType {
}
}
func toServerOutpoints(outpoints []*looprpc.OutPoint) ([]wire.OutPoint,
error) {
var serverOutpoints []wire.OutPoint
for _, o := range outpoints {
outpointStr := fmt.Sprintf("%s:%d", o.TxidStr, o.OutputIndex)
newOutpoint, err := wire.NewOutPointFromString(outpointStr)
if err != nil {
return nil, err
}
serverOutpoints = append(serverOutpoints, *newOutpoint)
}
return serverOutpoints, nil
}
func rpcAutoloopReason(reason liquidity.Reason) (looprpc.AutoReason, error) {
switch reason {
case liquidity.ReasonNone:

File diff suppressed because it is too large Load diff

View file

@ -1,6 +1,7 @@
syntax = "proto3";
import "swapserverrpc/common.proto";
import "lnrpc/lightning.proto";
package looprpc;
@ -206,13 +207,34 @@ service SwapClient {
rpc GetStaticAddressSummary (StaticAddressSummaryRequest)
returns (StaticAddressSummaryResponse);
/* loop:`static`
/* loop:`static in`
StaticAddressLoopIn initiates a static address loop-in swap.
*/
rpc StaticAddressLoopIn (StaticAddressLoopInRequest)
returns (StaticAddressLoopInResponse);
/* loop:`static openchannel`
StaticOpenChannel opens a channel funded by selected static address
deposits.
*/
rpc StaticOpenChannel (StaticOpenChannelRequest)
returns (StaticOpenChannelResponse);
}
message StaticOpenChannelRequest {
// Wrap lnd's request so Loop can extend this RPC with Loop-specific fields
// without diverging from the upstream API surface.
lnrpc.OpenChannelRequest open_channel_request = 1;
}
message StaticOpenChannelResponse {
/*
The outpoint of the channel opening transaction in the format
"txid:output_index".
*/
string channel_open_outpoint = 1;
};
message StopDaemonRequest {
}
@ -1771,7 +1793,7 @@ message WithdrawDepositsRequest {
/*
The outpoints of the deposits to withdraw.
*/
repeated OutPoint outpoints = 1;
repeated lnrpc.OutPoint outpoints = 1;
/*
If set to true, all deposits will be withdrawn.
@ -1810,23 +1832,6 @@ message WithdrawDepositsResponse {
string address = 2;
}
message OutPoint {
/*
Raw bytes representing the transaction id.
*/
bytes txid_bytes = 1;
/*
Reversed, hex-encoded string representing the transaction id.
*/
string txid_str = 2;
/*
The index of the output on the transaction.
*/
uint32 output_index = 3;
}
message ListStaticAddressDepositsRequest {
/*
Filters the list of all stored deposits by deposit state.
@ -1914,6 +1919,11 @@ message StaticAddressSummaryResponse {
The total value of all htlc timeout sweeps that the client swept.
*/
int64 value_htlc_timeout_sweeps_satoshis = 9;
/*
The total value of all deposits that have been used for channel openings.
*/
int64 value_channels_opened = 10;
}
enum DepositState {
@ -1982,6 +1992,18 @@ enum DepositState {
has been sufficiently confirmed.
*/
EXPIRED = 10;
/*
OPENING_CHANNEL indicates that the channel open in which the deposit was
used is in progress.
*/
OPENING_CHANNEL = 11;
/*
CHANNEL_PUBLISHED indicates that the channel open was finalized and
published and that it should be managed from lnd from now on.
*/
CHANNEL_PUBLISHED = 12;
}
message Deposit {

View file

@ -922,7 +922,7 @@
"parameters": [
{
"name": "state_filter",
"description": "Filters the list of all stored deposits by deposit state.\n\n - UNKNOWN_STATE: UNKNOWN_STATE is the default state of a deposit.\n - DEPOSITED: DEPOSITED indicates that the deposit has been sufficiently confirmed on\nchain.\n - WITHDRAWING: WITHDRAWING indicates that the deposit is currently being withdrawn. It\nflips to WITHDRAWN once the withdrawal transaction has been sufficiently\nconfirmed.\n - WITHDRAWN: WITHDRAWN indicates that the deposit has been withdrawn.\n - LOOPING_IN: LOOPING_IN indicates that the deposit is currently being used in a static\naddress loop-in swap.\n - LOOPED_IN: LOOPED_IN indicates that the deposit was used in a static address loop-in\nswap.\n - SWEEP_HTLC_TIMEOUT: SWEEP_HTLC_TIMEOUT indicates that the deposit is part of an active loop-in\nof which the respective htlc was published by the server and the timeout\npath has opened up for the client to sweep.\n - HTLC_TIMEOUT_SWEPT: HTLC_TIMEOUT_SWEPT indicates that the timeout path of the htlc has been\nswept by the client.\n - PUBLISH_EXPIRED: PUBLISH_EXPIRED indicates that the deposit has expired and the sweep\ntransaction has been published.\n - WAIT_FOR_EXPIRY_SWEEP: WAIT_FOR_EXPIRY_SWEEP indicates that the deposit has expired and the sweep\ntransaction has not yet been sufficiently confirmed.\n - EXPIRED: EXPIRED indicates that the deposit has expired and the sweep transaction\nhas been sufficiently confirmed.",
"description": "Filters the list of all stored deposits by deposit state.\n\n - UNKNOWN_STATE: UNKNOWN_STATE is the default state of a deposit.\n - DEPOSITED: DEPOSITED indicates that the deposit has been sufficiently confirmed on\nchain.\n - WITHDRAWING: WITHDRAWING indicates that the deposit is currently being withdrawn. It\nflips to WITHDRAWN once the withdrawal transaction has been sufficiently\nconfirmed.\n - WITHDRAWN: WITHDRAWN indicates that the deposit has been withdrawn.\n - LOOPING_IN: LOOPING_IN indicates that the deposit is currently being used in a static\naddress loop-in swap.\n - LOOPED_IN: LOOPED_IN indicates that the deposit was used in a static address loop-in\nswap.\n - SWEEP_HTLC_TIMEOUT: SWEEP_HTLC_TIMEOUT indicates that the deposit is part of an active loop-in\nof which the respective htlc was published by the server and the timeout\npath has opened up for the client to sweep.\n - HTLC_TIMEOUT_SWEPT: HTLC_TIMEOUT_SWEPT indicates that the timeout path of the htlc has been\nswept by the client.\n - PUBLISH_EXPIRED: PUBLISH_EXPIRED indicates that the deposit has expired and the sweep\ntransaction has been published.\n - WAIT_FOR_EXPIRY_SWEEP: WAIT_FOR_EXPIRY_SWEEP indicates that the deposit has expired and the sweep\ntransaction has not yet been sufficiently confirmed.\n - EXPIRED: EXPIRED indicates that the deposit has expired and the sweep transaction\nhas been sufficiently confirmed.\n - OPENING_CHANNEL: OPENING_CHANNEL indicates that the channel open in which the deposit was\nused is in progress.\n - CHANNEL_PUBLISHED: CHANNEL_PUBLISHED indicates that the channel open was finalized and\npublished and that it should be managed from lnd from now on.",
"in": "query",
"required": false,
"type": "string",
@ -937,7 +937,9 @@
"HTLC_TIMEOUT_SWEPT",
"PUBLISH_EXPIRED",
"WAIT_FOR_EXPIRY_SWEEP",
"EXPIRED"
"EXPIRED",
"OPENING_CHANNEL",
"CHANNEL_PUBLISHED"
],
"default": "UNKNOWN_STATE"
},
@ -1001,7 +1003,7 @@
},
"/v1/staticaddr/loopin": {
"post": {
"summary": "loop:`static`\nStaticAddressLoopIn initiates a static address loop-in swap.",
"summary": "loop:`static in`\nStaticAddressLoopIn initiates a static address loop-in swap.",
"operationId": "SwapClient_StaticAddressLoopIn",
"responses": {
"200": {
@ -1146,6 +1148,292 @@
"default": "ANY",
"description": " - ANY: ANY indicates that no filter is applied.\n - LOOP_OUT: LOOP_OUT indicates an loop out swap (off-chain to on-chain).\n - LOOP_IN: LOOP_IN indicates a loop in swap (on-chain to off-chain)."
},
"lnrpcChanPointShim": {
"type": "object",
"properties": {
"amt": {
"type": "string",
"format": "int64",
"description": "The size of the pre-crafted output to be used as the channel point for this\nchannel funding."
},
"chan_point": {
"$ref": "#/definitions/lnrpcChannelPoint",
"description": "The target channel point to refrence in created commitment transactions."
},
"local_key": {
"$ref": "#/definitions/lnrpcKeyDescriptor",
"description": "Our local key to use when creating the multi-sig output."
},
"remote_key": {
"type": "string",
"format": "byte",
"description": "The key of the remote party to use when creating the multi-sig output."
},
"pending_chan_id": {
"type": "string",
"format": "byte",
"description": "If non-zero, then this will be used as the pending channel ID on the wire\nprotocol to initate the funding request. This is an optional field, and\nshould only be set if the responder is already expecting a specific pending\nchannel ID."
},
"thaw_height": {
"type": "integer",
"format": "int64",
"description": "This uint32 indicates if this channel is to be considered 'frozen'. A frozen\nchannel does not allow a cooperative channel close by the initiator. The\nthaw_height is the height that this restriction stops applying to the\nchannel. The height can be interpreted in two ways: as a relative height if\nthe value is less than 500,000, or as an absolute height otherwise."
},
"musig2": {
"type": "boolean",
"description": "Indicates that the funding output is using a MuSig2 multi-sig output."
}
}
},
"lnrpcChannelPoint": {
"type": "object",
"properties": {
"funding_txid_bytes": {
"type": "string",
"format": "byte",
"description": "Txid of the funding transaction. When using REST, this field must be\nencoded as base64."
},
"funding_txid_str": {
"type": "string",
"description": "Hex-encoded string representing the byte-reversed hash of the funding\ntransaction."
},
"output_index": {
"type": "integer",
"format": "int64",
"title": "The index of the output of the funding transaction"
}
}
},
"lnrpcCommitmentType": {
"type": "string",
"enum": [
"UNKNOWN_COMMITMENT_TYPE",
"LEGACY",
"STATIC_REMOTE_KEY",
"ANCHORS",
"SCRIPT_ENFORCED_LEASE",
"SIMPLE_TAPROOT",
"SIMPLE_TAPROOT_OVERLAY"
],
"default": "UNKNOWN_COMMITMENT_TYPE",
"description": " - UNKNOWN_COMMITMENT_TYPE: Returned when the commitment type isn't known or unavailable.\n - LEGACY: A channel using the legacy commitment format having tweaked to_remote\nkeys.\n - STATIC_REMOTE_KEY: A channel that uses the modern commitment format where the key in the\noutput of the remote party does not change each state. This makes back\nup and recovery easier as when the channel is closed, the funds go\ndirectly to that key.\n - ANCHORS: A channel that uses a commitment format that has anchor outputs on the\ncommitments, allowing fee bumping after a force close transaction has\nbeen broadcast.\n - SCRIPT_ENFORCED_LEASE: A channel that uses a commitment type that builds upon the anchors\ncommitment format, but in addition requires a CLTV clause to spend outputs\npaying to the channel initiator. This is intended for use on leased channels\nto guarantee that the channel initiator has no incentives to close a leased\nchannel before its maturity date.\n - SIMPLE_TAPROOT: A channel that uses musig2 for the funding output, and the new tapscript\nfeatures where relevant.\n - SIMPLE_TAPROOT_OVERLAY: Identical to the SIMPLE_TAPROOT channel type, but with extra functionality.\nThis channel type also commits to additional meta data in the tapscript\nleaves for the scripts in a channel."
},
"lnrpcFundingShim": {
"type": "object",
"properties": {
"chan_point_shim": {
"$ref": "#/definitions/lnrpcChanPointShim",
"description": "A channel shim where the channel point was fully constructed outside\nof lnd's wallet and the transaction might already be published."
},
"psbt_shim": {
"$ref": "#/definitions/lnrpcPsbtShim",
"description": "A channel shim that uses a PSBT to fund and sign the channel funding\ntransaction."
}
}
},
"lnrpcKeyDescriptor": {
"type": "object",
"properties": {
"raw_key_bytes": {
"type": "string",
"format": "byte",
"description": "The raw bytes of the key being identified."
},
"key_loc": {
"$ref": "#/definitions/lnrpcKeyLocator",
"description": "The key locator that identifies which key to use for signing."
}
}
},
"lnrpcKeyLocator": {
"type": "object",
"properties": {
"key_family": {
"type": "integer",
"format": "int32",
"description": "The family of key being identified."
},
"key_index": {
"type": "integer",
"format": "int32",
"description": "The precise index of the key being identified."
}
}
},
"lnrpcOpenChannelRequest": {
"type": "object",
"properties": {
"sat_per_vbyte": {
"type": "string",
"format": "uint64",
"description": "A manual fee rate set in sat/vbyte that should be used when crafting the\nfunding transaction."
},
"node_pubkey": {
"type": "string",
"format": "byte",
"description": "The pubkey of the node to open a channel with. When using REST, this field\nmust be encoded as base64."
},
"node_pubkey_string": {
"type": "string",
"description": "The hex encoded pubkey of the node to open a channel with. Deprecated now\nthat the REST gateway supports base64 encoding of bytes fields."
},
"local_funding_amount": {
"type": "string",
"format": "int64",
"title": "The number of satoshis the wallet should commit to the channel"
},
"push_sat": {
"type": "string",
"format": "int64",
"title": "The number of satoshis to push to the remote side as part of the initial\ncommitment state"
},
"target_conf": {
"type": "integer",
"format": "int32",
"description": "The target number of blocks that the funding transaction should be\nconfirmed by."
},
"sat_per_byte": {
"type": "string",
"format": "int64",
"description": "Deprecated, use sat_per_vbyte.\nA manual fee rate set in sat/vbyte that should be used when crafting the\nfunding transaction."
},
"private": {
"type": "boolean",
"description": "Whether this channel should be private, not announced to the greater\nnetwork."
},
"min_htlc_msat": {
"type": "string",
"format": "int64",
"description": "The minimum value in millisatoshi we will require for incoming HTLCs on\nthe channel."
},
"remote_csv_delay": {
"type": "integer",
"format": "int64",
"description": "The delay we require on the remote's commitment transaction. If this is\nnot set, it will be scaled automatically with the channel size."
},
"min_confs": {
"type": "integer",
"format": "int32",
"description": "The minimum number of confirmations each one of your outputs used for\nthe funding transaction must satisfy."
},
"spend_unconfirmed": {
"type": "boolean",
"description": "Whether unconfirmed outputs should be used as inputs for the funding\ntransaction."
},
"close_address": {
"type": "string",
"description": "Close address is an optional address which specifies the address to which\nfunds should be paid out to upon cooperative close. This field may only be\nset if the peer supports the option upfront feature bit (call listpeers\nto check). The remote peer will only accept cooperative closes to this\naddress if it is set.\n\nNote: If this value is set on channel creation, you will *not* be able to\ncooperatively close out to a different address."
},
"funding_shim": {
"$ref": "#/definitions/lnrpcFundingShim",
"description": "Funding shims are an optional argument that allow the caller to intercept\ncertain funding functionality. For example, a shim can be provided to use a\nparticular key for the commitment key (ideally cold) rather than use one\nthat is generated by the wallet as normal, or signal that signing will be\ncarried out in an interactive manner (PSBT based)."
},
"remote_max_value_in_flight_msat": {
"type": "string",
"format": "uint64",
"description": "The maximum amount of coins in millisatoshi that can be pending within\nthe channel. It only applies to the remote party."
},
"remote_max_htlcs": {
"type": "integer",
"format": "int64",
"description": "The maximum number of concurrent HTLCs we will allow the remote party to add\nto the commitment transaction."
},
"max_local_csv": {
"type": "integer",
"format": "int64",
"description": "Max local csv is the maximum csv delay we will allow for our own commitment\ntransaction."
},
"commitment_type": {
"$ref": "#/definitions/lnrpcCommitmentType",
"description": "The explicit commitment type to use. Note this field will only be used if\nthe remote peer supports explicit channel negotiation."
},
"zero_conf": {
"type": "boolean",
"description": "If this is true, then a zero-conf channel open will be attempted."
},
"scid_alias": {
"type": "boolean",
"description": "If this is true, then an option-scid-alias channel-type open will be\nattempted."
},
"base_fee": {
"type": "string",
"format": "uint64",
"description": "The base fee charged regardless of the number of milli-satoshis sent."
},
"fee_rate": {
"type": "string",
"format": "uint64",
"description": "The fee rate in ppm (parts per million) that will be charged in\nproportion of the value of each forwarded HTLC."
},
"use_base_fee": {
"type": "boolean",
"description": "If use_base_fee is true the open channel announcement will update the\nchannel base fee with the value specified in base_fee. In the case of\na base_fee of 0 use_base_fee is needed downstream to distinguish whether\nto use the default base fee value specified in the config or 0."
},
"use_fee_rate": {
"type": "boolean",
"description": "If use_fee_rate is true the open channel announcement will update the\nchannel fee rate with the value specified in fee_rate. In the case of\na fee_rate of 0 use_fee_rate is needed downstream to distinguish whether\nto use the default fee rate value specified in the config or 0."
},
"remote_chan_reserve_sat": {
"type": "string",
"format": "uint64",
"description": "The number of satoshis we require the remote peer to reserve. This value,\nif specified, must be above the dust limit and below 20% of the channel\ncapacity."
},
"fund_max": {
"type": "boolean",
"description": "If set, then lnd will attempt to commit all the coins under control of the\ninternal wallet to open the channel, and the LocalFundingAmount field must\nbe zero and is ignored."
},
"memo": {
"type": "string",
"description": "An optional note-to-self to go along with the channel containing some\nuseful information. This is only ever stored locally and in no way impacts\nthe channel's operation."
},
"outpoints": {
"type": "array",
"items": {
"type": "object",
"$ref": "#/definitions/lnrpcOutPoint"
},
"description": "A list of selected outpoints that are allocated for channel funding."
}
}
},
"lnrpcOutPoint": {
"type": "object",
"properties": {
"txid_bytes": {
"type": "string",
"format": "byte",
"description": "Raw bytes representing the transaction id."
},
"txid_str": {
"type": "string",
"description": "Reversed, hex-encoded string representing the transaction id."
},
"output_index": {
"type": "integer",
"format": "int64",
"description": "The index of the output on the transaction."
}
}
},
"lnrpcPsbtShim": {
"type": "object",
"properties": {
"pending_chan_id": {
"type": "string",
"format": "byte",
"description": "A unique identifier of 32 random bytes that will be used as the pending\nchannel ID to identify the PSBT state machine when interacting with it and\non the wire protocol to initiate the funding request."
},
"base_psbt": {
"type": "string",
"format": "byte",
"description": "An optional base PSBT the new channel output will be added to. If this is\nnon-empty, it must be a binary serialized PSBT."
},
"no_publish": {
"type": "boolean",
"description": "If a channel should be part of a batch (multiple channel openings in one\ntransaction), it can be dangerous if the whole batch transaction is\npublished too early before all channel opening negotiations are completed.\nThis flag prevents this particular channel from broadcasting the transaction\nafter the negotiation with the remote peer. In a batch of channel openings\nthis flag should be set to true for every channel but the very last."
}
}
},
"looprpcAbandonSwapResponse": {
"type": "object"
},
@ -1344,10 +1632,12 @@
"HTLC_TIMEOUT_SWEPT",
"PUBLISH_EXPIRED",
"WAIT_FOR_EXPIRY_SWEEP",
"EXPIRED"
"EXPIRED",
"OPENING_CHANNEL",
"CHANNEL_PUBLISHED"
],
"default": "UNKNOWN_STATE",
"description": " - UNKNOWN_STATE: UNKNOWN_STATE is the default state of a deposit.\n - DEPOSITED: DEPOSITED indicates that the deposit has been sufficiently confirmed on\nchain.\n - WITHDRAWING: WITHDRAWING indicates that the deposit is currently being withdrawn. It\nflips to WITHDRAWN once the withdrawal transaction has been sufficiently\nconfirmed.\n - WITHDRAWN: WITHDRAWN indicates that the deposit has been withdrawn.\n - LOOPING_IN: LOOPING_IN indicates that the deposit is currently being used in a static\naddress loop-in swap.\n - LOOPED_IN: LOOPED_IN indicates that the deposit was used in a static address loop-in\nswap.\n - SWEEP_HTLC_TIMEOUT: SWEEP_HTLC_TIMEOUT indicates that the deposit is part of an active loop-in\nof which the respective htlc was published by the server and the timeout\npath has opened up for the client to sweep.\n - HTLC_TIMEOUT_SWEPT: HTLC_TIMEOUT_SWEPT indicates that the timeout path of the htlc has been\nswept by the client.\n - PUBLISH_EXPIRED: PUBLISH_EXPIRED indicates that the deposit has expired and the sweep\ntransaction has been published.\n - WAIT_FOR_EXPIRY_SWEEP: WAIT_FOR_EXPIRY_SWEEP indicates that the deposit has expired and the sweep\ntransaction has not yet been sufficiently confirmed.\n - EXPIRED: EXPIRED indicates that the deposit has expired and the sweep transaction\nhas been sufficiently confirmed."
"description": " - UNKNOWN_STATE: UNKNOWN_STATE is the default state of a deposit.\n - DEPOSITED: DEPOSITED indicates that the deposit has been sufficiently confirmed on\nchain.\n - WITHDRAWING: WITHDRAWING indicates that the deposit is currently being withdrawn. It\nflips to WITHDRAWN once the withdrawal transaction has been sufficiently\nconfirmed.\n - WITHDRAWN: WITHDRAWN indicates that the deposit has been withdrawn.\n - LOOPING_IN: LOOPING_IN indicates that the deposit is currently being used in a static\naddress loop-in swap.\n - LOOPED_IN: LOOPED_IN indicates that the deposit was used in a static address loop-in\nswap.\n - SWEEP_HTLC_TIMEOUT: SWEEP_HTLC_TIMEOUT indicates that the deposit is part of an active loop-in\nof which the respective htlc was published by the server and the timeout\npath has opened up for the client to sweep.\n - HTLC_TIMEOUT_SWEPT: HTLC_TIMEOUT_SWEPT indicates that the timeout path of the htlc has been\nswept by the client.\n - PUBLISH_EXPIRED: PUBLISH_EXPIRED indicates that the deposit has expired and the sweep\ntransaction has been published.\n - WAIT_FOR_EXPIRY_SWEEP: WAIT_FOR_EXPIRY_SWEEP indicates that the deposit has expired and the sweep\ntransaction has not yet been sufficiently confirmed.\n - EXPIRED: EXPIRED indicates that the deposit has expired and the sweep transaction\nhas been sufficiently confirmed.\n - OPENING_CHANNEL: OPENING_CHANNEL indicates that the channel open in which the deposit was\nused is in progress.\n - CHANNEL_PUBLISHED: CHANNEL_PUBLISHED indicates that the channel open was finalized and\npublished and that it should be managed from lnd from now on."
},
"looprpcDisqualified": {
"type": "object",
@ -2225,25 +2515,6 @@
}
}
},
"looprpcOutPoint": {
"type": "object",
"properties": {
"txid_bytes": {
"type": "string",
"format": "byte",
"description": "Raw bytes representing the transaction id."
},
"txid_str": {
"type": "string",
"description": "Reversed, hex-encoded string representing the transaction id."
},
"output_index": {
"type": "integer",
"format": "int64",
"description": "The index of the output on the transaction."
}
}
},
"looprpcOutQuoteResponse": {
"type": "object",
"properties": {
@ -2588,6 +2859,11 @@
"type": "string",
"format": "int64",
"description": "The total value of all htlc timeout sweeps that the client swept."
},
"value_channels_opened": {
"type": "string",
"format": "int64",
"description": "The total value of all deposits that have been used for channel openings."
}
}
},
@ -2628,6 +2904,15 @@
}
}
},
"looprpcStaticOpenChannelResponse": {
"type": "object",
"properties": {
"channel_open_outpoint": {
"type": "string",
"description": "The outpoint of the channel opening transaction in the format\n\"txid:output_index\"."
}
}
},
"looprpcStopDaemonResponse": {
"type": "object"
},
@ -2901,7 +3186,7 @@
"type": "array",
"items": {
"type": "object",
"$ref": "#/definitions/looprpcOutPoint"
"$ref": "#/definitions/lnrpcOutPoint"
},
"description": "The outpoints of the deposits to withdraw."
},

View file

@ -137,9 +137,13 @@ type SwapClientClient interface {
// GetStaticAddressSummary returns a summary of static address related
// statistics.
GetStaticAddressSummary(ctx context.Context, in *StaticAddressSummaryRequest, opts ...grpc.CallOption) (*StaticAddressSummaryResponse, error)
// loop:`static`
// loop:`static in`
// StaticAddressLoopIn initiates a static address loop-in swap.
StaticAddressLoopIn(ctx context.Context, in *StaticAddressLoopInRequest, opts ...grpc.CallOption) (*StaticAddressLoopInResponse, error)
// loop:`static openchannel`
// StaticOpenChannel opens a channel funded by selected static address
// deposits.
StaticOpenChannel(ctx context.Context, in *StaticOpenChannelRequest, opts ...grpc.CallOption) (*StaticOpenChannelResponse, error)
}
type swapClientClient struct {
@ -461,6 +465,15 @@ func (c *swapClientClient) StaticAddressLoopIn(ctx context.Context, in *StaticAd
return out, nil
}
func (c *swapClientClient) StaticOpenChannel(ctx context.Context, in *StaticOpenChannelRequest, opts ...grpc.CallOption) (*StaticOpenChannelResponse, error) {
out := new(StaticOpenChannelResponse)
err := c.cc.Invoke(ctx, "/looprpc.SwapClient/StaticOpenChannel", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
// SwapClientServer is the server API for SwapClient service.
// All implementations must embed UnimplementedSwapClientServer
// for forward compatibility
@ -584,9 +597,13 @@ type SwapClientServer interface {
// GetStaticAddressSummary returns a summary of static address related
// statistics.
GetStaticAddressSummary(context.Context, *StaticAddressSummaryRequest) (*StaticAddressSummaryResponse, error)
// loop:`static`
// loop:`static in`
// StaticAddressLoopIn initiates a static address loop-in swap.
StaticAddressLoopIn(context.Context, *StaticAddressLoopInRequest) (*StaticAddressLoopInResponse, error)
// loop:`static openchannel`
// StaticOpenChannel opens a channel funded by selected static address
// deposits.
StaticOpenChannel(context.Context, *StaticOpenChannelRequest) (*StaticOpenChannelResponse, error)
mustEmbedUnimplementedSwapClientServer()
}
@ -690,6 +707,9 @@ func (UnimplementedSwapClientServer) GetStaticAddressSummary(context.Context, *S
func (UnimplementedSwapClientServer) StaticAddressLoopIn(context.Context, *StaticAddressLoopInRequest) (*StaticAddressLoopInResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method StaticAddressLoopIn not implemented")
}
func (UnimplementedSwapClientServer) StaticOpenChannel(context.Context, *StaticOpenChannelRequest) (*StaticOpenChannelResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method StaticOpenChannel not implemented")
}
func (UnimplementedSwapClientServer) mustEmbedUnimplementedSwapClientServer() {}
// UnsafeSwapClientServer may be embedded to opt out of forward compatibility for this service.
@ -1282,6 +1302,24 @@ func _SwapClient_StaticAddressLoopIn_Handler(srv interface{}, ctx context.Contex
return interceptor(ctx, in, info, handler)
}
func _SwapClient_StaticOpenChannel_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(StaticOpenChannelRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(SwapClientServer).StaticOpenChannel(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/looprpc.SwapClient/StaticOpenChannel",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(SwapClientServer).StaticOpenChannel(ctx, req.(*StaticOpenChannelRequest))
}
return interceptor(ctx, in, info, handler)
}
// SwapClient_ServiceDesc is the grpc.ServiceDesc for SwapClient service.
// It's only intended for direct use with grpc.RegisterService,
// and not to be introspected or modified (even as a copy)
@ -1413,6 +1451,10 @@ var SwapClient_ServiceDesc = grpc.ServiceDesc{
MethodName: "StaticAddressLoopIn",
Handler: _SwapClient_StaticAddressLoopIn_Handler,
},
{
MethodName: "StaticOpenChannel",
Handler: _SwapClient_StaticOpenChannel_Handler,
},
},
Streams: []grpc.StreamDesc{
{

View file

@ -837,4 +837,29 @@ func RegisterSwapClientJSONCallbacks(registry map[string]func(ctx context.Contex
}
callback(string(respBytes), nil)
}
registry["looprpc.SwapClient.StaticOpenChannel"] = func(ctx context.Context,
conn *grpc.ClientConn, reqJSON string, callback func(string, error)) {
req := &StaticOpenChannelRequest{}
err := marshaler.Unmarshal([]byte(reqJSON), req)
if err != nil {
callback("", err)
return
}
client := NewSwapClientClient(conn)
resp, err := client.StaticOpenChannel(ctx, req)
if err != nil {
callback("", err)
return
}
respBytes, err := marshaler.Marshal(resp)
if err != nil {
callback("", err)
return
}
callback(string(respBytes), nil)
}
}