Skip to content
Open
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
85 changes: 82 additions & 3 deletions lib/types/proto/loop/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,10 @@ export enum StaticAddressLoopInSwapState {
UNRECOGNIZED = 'UNRECOGNIZED'
}

export interface StopDaemonRequest {}

export interface StopDaemonResponse {}

export interface LoopOutRequest {
/** Requested swap amount in sat. This does not include the swap and miner fee. */
amt: string;
Expand Down Expand Up @@ -622,7 +626,12 @@ export interface OutTermsResponse {
}

export interface QuoteRequest {
/** The amount to swap in satoshis. */
/**
* The amount to swap in satoshis. In the loop-in case this can either be taken
* from the connected lnd wallet or coin-selected from static address deposits.
* This is controlled by the select_deposits flag. If deposit_outpoints are
* specified, the coins are taken out of that.
*/
amt: string;
/**
* The confirmation target that should be used either for the sweep of the
Expand Down Expand Up @@ -660,15 +669,29 @@ export interface QuoteRequest {
private: boolean;
/**
* Static address deposit outpoints that will be quoted for. This option only
* pertains to loop in swaps. Either this or the amt parameter can be set at
* the same time.
* pertains to loop in swaps. If the amt field is set as well the respective
* partial amount will be swapped. Cannot be used in conjunction with
* auto_select_deposits.
*/
depositOutpoints: string[];
/**
* The optional asset information to use for the swap. If set, the quote will
* be returned in the specified asset.
*/
assetInfo: AssetLoopOutRequest | undefined;
/**
* In the legacy loop-in case this field must be set to false.
* If set to true, the swap amount will be automatically selected from the
* static address deposits. If set to true, deposit_outpoints must be empty.
* This option only pertains to loop in swaps.
*/
autoSelectDeposits: boolean;
/**
* If set to true the server will immediately publish the swap in exchange for
* a higher fee. This can be useful if the client expects change from a swap.
* Note that this feature is only available for static address loop in swaps.
*/
fast: boolean;
}

export interface InQuoteResponse {
Expand All @@ -687,6 +710,12 @@ export interface InQuoteResponse {
cltvDelta: number;
/** The confirmation target to be used to publish the on-chain HTLC. */
confTarget: number;
/**
* If the quote request was for a static address loop in and only contained
* deposit outpoints the quote response will return the total amount of the
* selected deposits.
*/
quotedAmt: string;
}

export interface OutQuoteResponse {
Expand Down Expand Up @@ -947,6 +976,12 @@ export interface LiquidityParameters {
* not be able to be batched with other swaps.
*/
fastSwapPublication: boolean;
/**
* A list of peers (their public keys) that should be excluded from the easy
* autoloop run. If set, channels connected to these peers won't be
* considered for easy autoloop swaps.
*/
easyAutoloopExcludedPeers: Uint8Array | string[];
}

export interface LiquidityParameters_EasyAssetParamsEntry {
Expand Down Expand Up @@ -1282,6 +1317,11 @@ export interface Deposit {
* loop-in swap anymore.
*/
blocksUntilExpiry: string;
/**
* The swap hash of the swap that this deposit is part of. This field is only
* set if the deposit is part of a loop-in swap.
*/
swapHash: Uint8Array | string;
}

export interface StaticAddressWithdrawal {
Expand Down Expand Up @@ -1320,6 +1360,8 @@ export interface StaticAddressLoopInSwap {
* fees.
*/
paymentRequestAmountSatoshis: string;
/** The deposits that were used for this swap. */
deposits: Deposit[];
}

export interface StaticAddressLoopInRequest {
Expand Down Expand Up @@ -1366,6 +1408,22 @@ export interface StaticAddressLoopInRequest {
* side and the client can retry the swap with different parameters.
*/
paymentTimeoutSeconds: number;
/**
* The optional swap amount the client is attempting to swap. It can be
* provided in combination with the outpoints or separately. If provided with
* outpoints the client takes out this amount from the sum of provided
* outpoints and sends the change back to the static address. If the amount is
* provided without outpoints, the client will select deposits automatically.
* The coin selection strategy is simplified by sorting all available deposits
* in descending order by amount, and equal amounts in ascending order of
* blocks until expiry, and then selecting the largest deposits first until the
* amount is reached. The change will be sent back to the static address. If a
* subset of outpoints suffice to cover the specified amount the swap will be
* canceled to allow the user to safe on transaction fees.
*/
amount: string;
/** If set, request the server to use fast publication behavior. */
fast: boolean;
}

export interface StaticAddressLoopInResponse {
Expand Down Expand Up @@ -1402,6 +1460,20 @@ export interface StaticAddressLoopInResponse {
* side and the client can retry the swap with different parameters.
*/
paymentTimeoutSeconds: number;
/** The deposits that are used for this swap. */
usedDeposits: Deposit[];
/**
* The amount that is being swapped (may be less than total deposit value if
* change is returned).
*/
swapAmount: string;
/** The change amount that will be returned to the static address. */
change: string;
/**
* If set, indicates that the server was requested to use fast publication
* behavior.
*/
fast: boolean;
}

export interface AssetLoopOutRequest {
Expand Down Expand Up @@ -1610,6 +1682,13 @@ export interface SwapClient {
* GetInfo gets basic information about the loop daemon.
*/
getInfo(request?: DeepPartial<GetInfoRequest>): Promise<GetInfoResponse>;
/**
* loop: `stop`
* StopDaemon instructs the daemon to shut down gracefully.
*/
stopDaemon(
request?: DeepPartial<StopDaemonRequest>
): Promise<StopDaemonResponse>;
/**
* loop: `getparams`
* GetLiquidityParams gets the parameters that the daemon's liquidity manager
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"types": "./dist/index.d.ts",
"config": {
"lnd_release_tag": "v0.19.1-beta",
"loop_release_tag": "v0.31.2-beta",
"loop_release_tag": "v0.31.7-beta",
"pool_release_tag": "v0.6.6-beta",
"faraday_release_tag": "v0.2.16-alpha",
"tapd_release_tag": "v0.6.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,11 @@ service SwapClient {
*/
rpc GetInfo (GetInfoRequest) returns (GetInfoResponse);

/* loop: `stop`
StopDaemon instructs the daemon to shut down gracefully.
*/
rpc StopDaemon (StopDaemonRequest) returns (StopDaemonResponse);

/* loop: `getparams`
GetLiquidityParams gets the parameters that the daemon's liquidity manager
is currently configured with. This may be nil if nothing is configured.
Expand Down Expand Up @@ -202,6 +207,12 @@ service SwapClient {
returns (StaticAddressLoopInResponse);
}

message StopDaemonRequest {
}

message StopDaemonResponse {
}

message LoopOutRequest {
/*
Requested swap amount in sat. This does not include the swap and miner fee.
Expand Down Expand Up @@ -775,7 +786,10 @@ message OutTermsResponse {

message QuoteRequest {
/*
The amount to swap in satoshis.
The amount to swap in satoshis. In the loop-in case this can either be taken
from the connected lnd wallet or coin-selected from static address deposits.
This is controlled by the select_deposits flag. If deposit_outpoints are
specified, the coins are taken out of that.
*/
int64 amt = 1;

Expand Down Expand Up @@ -823,8 +837,9 @@ message QuoteRequest {

/*
Static address deposit outpoints that will be quoted for. This option only
pertains to loop in swaps. Either this or the amt parameter can be set at
the same time.
pertains to loop in swaps. If the amt field is set as well the respective
partial amount will be swapped. Cannot be used in conjunction with
auto_select_deposits.
*/
repeated string deposit_outpoints = 8;

Expand All @@ -833,6 +848,21 @@ message QuoteRequest {
be returned in the specified asset.
*/
AssetLoopOutRequest asset_info = 9;

/*
In the legacy loop-in case this field must be set to false.
If set to true, the swap amount will be automatically selected from the
static address deposits. If set to true, deposit_outpoints must be empty.
This option only pertains to loop in swaps.
*/
bool auto_select_deposits = 10;

/*
If set to true the server will immediately publish the swap in exchange for
a higher fee. This can be useful if the client expects change from a swap.
Note that this feature is only available for static address loop in swaps.
*/
bool fast = 11;
}

message InQuoteResponse {
Expand Down Expand Up @@ -862,6 +892,13 @@ message InQuoteResponse {
The confirmation target to be used to publish the on-chain HTLC.
*/
int32 conf_target = 6;

/*
If the quote request was for a static address loop in and only contained
deposit outpoints the quote response will return the total amount of the
selected deposits.
*/
int64 quoted_amt = 7;
}

message OutQuoteResponse {
Expand Down Expand Up @@ -1243,6 +1280,13 @@ message LiquidityParameters {
* not be able to be batched with other swaps.
*/
bool fast_swap_publication = 26;

/*
A list of peers (their public keys) that should be excluded from the easy
autoloop run. If set, channels connected to these peers won't be
considered for easy autoloop swaps.
*/
repeated bytes easy_autoloop_excluded_peers = 27;
}

message EasyAssetAutoloopParams {
Expand Down Expand Up @@ -1910,6 +1954,12 @@ message Deposit {
loop-in swap anymore.
*/
int64 blocks_until_expiry = 6;

/*
The swap hash of the swap that this deposit is part of. This field is only
set if the deposit is part of a loop-in swap.
*/
bytes swap_hash = 7;
}

message StaticAddressWithdrawal {
Expand Down Expand Up @@ -1971,6 +2021,11 @@ message StaticAddressLoopInSwap {
fees.
*/
int64 payment_request_amount_satoshis = 5;

/*
The deposits that were used for this swap.
*/
repeated Deposit deposits = 6;
}

enum StaticAddressLoopInSwapState {
Expand Down Expand Up @@ -2078,6 +2133,24 @@ message StaticAddressLoopInRequest {
side and the client can retry the swap with different parameters.
*/
uint32 payment_timeout_seconds = 8;

/*
The optional swap amount the client is attempting to swap. It can be
provided in combination with the outpoints or separately. If provided with
outpoints the client takes out this amount from the sum of provided
outpoints and sends the change back to the static address. If the amount is
provided without outpoints, the client will select deposits automatically.
The coin selection strategy is simplified by sorting all available deposits
in descending order by amount, and equal amounts in ascending order of
blocks until expiry, and then selecting the largest deposits first until the
amount is reached. The change will be sent back to the static address. If a
subset of outpoints suffice to cover the specified amount the swap will be
canceled to allow the user to safe on transaction fees.
*/
int64 amount = 9;

// If set, request the server to use fast publication behavior.
bool fast = 10;
}

message StaticAddressLoopInResponse {
Expand Down Expand Up @@ -2142,6 +2215,28 @@ message StaticAddressLoopInResponse {
side and the client can retry the swap with different parameters.
*/
uint32 payment_timeout_seconds = 11;

/*
The deposits that are used for this swap.
*/
repeated Deposit used_deposits = 12;

/*
The amount that is being swapped (may be less than total deposit value if
change is returned).
*/
uint64 swap_amount = 13;

/*
The change amount that will be returned to the static address.
*/
int64 change = 14;

/*
If set, indicates that the server was requested to use fast publication
behavior.
*/
bool fast = 15;
}

message AssetLoopOutRequest {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,10 @@ message ServerLoopInQuoteRequest {
// service fee. This is to cover for the increased on-chain fee the server
// has to pay when the sweeping transaction is broadcast.
uint32 num_static_address_deposits = 7;

// If set, request the server to use fast publication behavior. Note that
// this falg is only available for static address loop ins.
bool fast = 8;
}

message ServerLoopInQuoteResponse {
Expand Down Expand Up @@ -660,6 +664,12 @@ message FetchL402Response {

// SubscribeNotificationsRequest is a request to subscribe to notifications.
message SubscribeNotificationsRequest {
enum ListenerVersion {
LEGACY = 0;
V1 = 1;
}

ListenerVersion version = 1;
}

// SubscribeNotificationsResponse is a response to a
Expand All @@ -668,6 +678,7 @@ message SubscribeNotificationsResponse {
oneof notification {
ServerReservationNotification reservation_notification = 1;
ServerStaticLoopInSweepNotification static_loop_in_sweep = 2;
ServerUnfinishedSwapNotification unfinished_swap = 3;
}
}

Expand All @@ -687,3 +698,14 @@ message ServerStaticLoopInSweepNotification {
// The prevout information of the sweep txn.
repeated PrevoutInfo prevout_info = 4;
}

// ServerUnfinishedSwapNotification notifies the client about an unfinished
// swap that needs attention. This is useful in client data loss scenarios to
// help the client recover the swap.
message ServerUnfinishedSwapNotification {
// The swap hash of the unfinished swap.
bytes swap_hash = 1;

// Whether the swap is a loop in or loop out.
bool is_loop_in = 2;
}