lightning network 閃電網路

TOC

生成 Google Protocol Buffers 文件

lnd/lnrpc at master · lightningnetwork/lnd

git clone https://github.com/lightningnetwork/lnd.git /tmp/src/lnd
bash tc.sh --gen-proto-doc /tmp/src/lnd/lnrpc /tmp/output.md

Generated Date:2019-09-12T13:49:08+08:00

Protocol Documentation

Table of Contents

Top

chainrpc/chainnotifier.proto

BlockEpoch

FieldTypeLabelDescription
hashbytesThe hash of the block.
heightuint32The height of the block.

ConfDetails

FieldTypeLabelDescription
raw_txbytesThe raw bytes of the confirmed transaction.
block_hashbytesThe hash of the block in which the confirmed transaction was included in.
block_heightuint32The height of the block in which the confirmed transaction was included in.
tx_indexuint32The index of the confirmed transaction within the transaction.

ConfEvent

FieldTypeLabelDescription
confConfDetailsAn event that includes the confirmation details of the request (txid/ouput script).
reorgReorgAn event send when the transaction of the request is reorged out of the chain.

ConfRequest

FieldTypeLabelDescription
txidbytesThe transaction hash for which we should request a confirmation notification for. If set to a hash of all zeros, then the confirmation notification will be requested for the script instead.
scriptbytesAn output script within a transaction with the hash above which will be used by light clients to match block filters. If the transaction hash is set to a hash of all zeros, then a confirmation notification will be requested for this script instead.
num_confsuint32The number of desired confirmations the transaction/output script should reach before dispatching a confirmation notification.
height_hintuint32The earliest height in the chain for which the transaction/output script could have been included in a block. This should in most cases be set to the broadcast height of the transaction/output script.

Outpoint

FieldTypeLabelDescription
hashbytesThe hash of the transaction.
indexuint32The index of the output within the transaction.

Reorg

TODO(wilmer): need to know how the client will use this first.

SpendDetails

FieldTypeLabelDescription
spending_outpointOutpointThe outpoint was that spent.
raw_spending_txbytesThe raw bytes of the spending transaction.
spending_tx_hashbytesThe hash of the spending transaction.
spending_input_indexuint32The input of the spending transaction that fulfilled the spend request.
spending_heightuint32The height at which the spending transaction was included in a block.

SpendEvent

FieldTypeLabelDescription
spendSpendDetailsAn event that includes the details of the spending transaction of the request (outpoint/output script).
reorgReorgAn event sent when the spending transaction of the request was reorged out of the chain.

SpendRequest

FieldTypeLabelDescription
outpointOutpointThe outpoint for which we should request a spend notification for. If set to a zero outpoint, then the spend notification will be requested for the script instead.
scriptbytesThe output script for the outpoint above. This will be used by light clients to match block filters. If the outpoint is set to a zero outpoint, then a spend notification will be requested for this script instead.
height_hintuint32The earliest height in the chain for which the outpoint/output script could have been spent. This should in most cases be set to the broadcast height of the outpoint/output script.

ChainNotifier

Method NameRequest TypeResponse TypeDescription
RegisterConfirmationsNtfnConfRequestConfEvent streamRegisterConfirmationsNtfn is a synchronous response-streaming RPC that registers an intent for a client to be notified once a confirmation request has reached its required number of confirmations on-chain.

A client can specify whether the confirmation request should be for a particular transaction by its hash or for an output script by specifying a zero hash. | | RegisterSpendNtfn | SpendRequest | SpendEvent stream | RegisterSpendNtfn is a synchronous response-streaming RPC that registers an intent for a client to be notification once a spend request has been spent by a transaction that has confirmed on-chain.

A client can specify whether the spend request should be for a particular outpoint or for an output script by specifying a zero outpoint. | | RegisterBlockEpochNtfn | BlockEpoch | BlockEpoch stream | RegisterBlockEpochNtfn is a synchronous response-streaming RPC that registers an intent for a client to be notified of blocks in the chain. The stream will return a hash and height tuple of a block for each new/stale block in the chain. It is the client's responsibility to determine whether the tuple returned is for a new or stale block in the chain.

A client can also request a historical backlog of blocks from a particular point. This allows clients to be idempotent by ensuring that they do not missing processing a single block within the chain. |

Top

walletrpc/walletkit.proto

AddrRequest

No fields, as we always give out a p2wkh address.

AddrResponse

FieldTypeLabelDescription
addrstringThe address encoded using a bech32 format.

BumpFeeRequest

FieldTypeLabelDescription
outpointlnrpc.OutPointThe input we're attempting to bump the fee of.
target_confuint32The target number of blocks that the input should be spent within.
sat_per_byteuint32The fee rate, expressed in sat/byte, that should be used to spend the input with.

BumpFeeResponse

EstimateFeeRequest

FieldTypeLabelDescription
conf_targetint32The number of confirmations to shoot for when estimating the fee.

EstimateFeeResponse

FieldTypeLabelDescription
sat_per_kwint64The amount of satoshis per kw that should be used in order to reach the confirmation target in the request.

KeyReq

FieldTypeLabelDescription
key_finger_printint32Is the key finger print of the root pubkey that this request is targeting. This allows the WalletKit to possibly serve out keys for multiple HD chains via public derivation.
key_familyint32The target key family to derive a key from. In other contexts, this is known as the "account".

PendingSweep

FieldTypeLabelDescription
outpointlnrpc.OutPointThe outpoint of the output we're attempting to sweep.
witness_typeWitnessTypeThe witness type of the output we're attempting to sweep.
amount_satuint32The value of the output we're attempting to sweep.
sat_per_byteuint32The fee rate we'll use to sweep the output. The fee rate is only determined once a sweeping transaction for the output is created, so it's possible for this to be 0 before this.
broadcast_attemptsuint32The number of broadcast attempts we've made to sweep the output.
next_broadcast_heightuint32The next height of the chain at which we'll attempt to broadcast the sweep transaction of the output.

PendingSweepsRequest

PendingSweepsResponse

FieldTypeLabelDescription
pending_sweepsPendingSweeprepeatedThe set of outputs currently being swept by lnd's central batching engine.

PublishResponse

FieldTypeLabelDescription
publish_errorstringIf blank, then no error occurred and the transaction was successfully published. If not the empty string, then a string representation of the broadcast error.

TODO(roasbeef): map to a proper enum type |

SendOutputsRequest

FieldTypeLabelDescription
sat_per_kwint64The number of satoshis per kilo weight that should be used when crafting this transaction.
outputssignrpc.TxOutrepeatedA slice of the outputs that should be created in the transaction produced.

SendOutputsResponse

FieldTypeLabelDescription
raw_txbytesThe serialized transaction sent out on the network.

Transaction

FieldTypeLabelDescription
tx_hexbytesThe raw serialized transaction.

WitnessType

NameNumberDescription
UNKNOWN_WITNESS0
COMMITMENT_TIME_LOCK1A witness that allows us to spend the output of a commitment transaction after a relative lock-time lockout.
COMMITMENT_NO_DELAY2A witness that allows us to spend a settled no-delay output immediately on a counterparty's commitment transaction.
COMMITMENT_REVOKE3A witness that allows us to sweep the settled output of a malicious counterparty's who broadcasts a revoked commitment transaction.
HTLC_OFFERED_REVOKE4A witness that allows us to sweep an HTLC which we offered to the remote party in the case that they broadcast a revoked commitment state.
HTLC_ACCEPTED_REVOKE5A witness that allows us to sweep an HTLC output sent to us in the case that the remote party broadcasts a revoked commitment state.
HTLC_OFFERED_TIMEOUT_SECOND_LEVEL6A witness that allows us to sweep an HTLC output that we extended to a party, but was never fulfilled. This HTLC output isn't directly on the commitment transaction, but is the result of a confirmed second-level HTLC transaction. As a result, we can only spend this after a CSV delay.
HTLC_ACCEPTED_SUCCESS_SECOND_LEVEL7A witness that allows us to sweep an HTLC output that was offered to us, and for which we have a payment preimage. This HTLC output isn't directly on our commitment transaction, but is the result of confirmed second-level HTLC transaction. As a result, we can only spend this after a CSV delay.
HTLC_OFFERED_REMOTE_TIMEOUT8A witness that allows us to sweep an HTLC that we offered to the remote party which lies in the commitment transaction of the remote party. We can spend this output after the absolute CLTV timeout of the HTLC as passed.
HTLC_ACCEPTED_REMOTE_SUCCESS9A witness that allows us to sweep an HTLC that was offered to us by the remote party. We use this witness in the case that the remote party goes to chain, and we know the pre-image to the HTLC. We can sweep this without any additional timeout.
HTLC_SECOND_LEVEL_REVOKE10A witness that allows us to sweep an HTLC from the remote party's commitment transaction in the case that the broadcast a revoked commitment, but then also immediately attempt to go to the second level to claim the HTLC.
WITNESS_KEY_HASH11A witness type that allows us to spend a regular p2wkh output that's sent to an output which is under complete control of the backing wallet.
NESTED_WITNESS_KEY_HASH12A witness type that allows us to sweep an output that sends to a nested P2SH script that pays to a key solely under our control.

WalletKit

Method NameRequest TypeResponse TypeDescription
DeriveNextKeyKeyReq.signrpc.KeyDescriptorDeriveNextKey attempts to derive the next key within the key family (account in BIP43) specified. This method should return the next external child within this branch.
DeriveKey.signrpc.KeyLocator.signrpc.KeyDescriptorDeriveKey attempts to derive an arbitrary key specified by the passed KeyLocator.
NextAddrAddrRequestAddrResponseNextAddr returns the next unused address within the wallet.
PublishTransactionTransactionPublishResponsePublishTransaction attempts to publish the passed transaction to the network. Once this returns without an error, the wallet will continually attempt to re-broadcast the transaction on start up, until it enters the chain.
SendOutputsSendOutputsRequestSendOutputsResponseSendOutputs is similar to the existing sendmany call in Bitcoind, and allows the caller to create a transaction that sends to several outputs at once. This is ideal when wanting to batch create a set of transactions.
EstimateFeeEstimateFeeRequestEstimateFeeResponseEstimateFee attempts to query the internal fee estimator of the wallet to determine the fee (in sat/kw) to attach to a transaction in order to achieve the confirmation target.
PendingSweepsPendingSweepsRequestPendingSweepsResponsePendingSweeps returns lists of on-chain outputs that lnd is currently attempting to sweep within its central batching engine. Outputs with similar fee rates are batched together in order to sweep them within a single transaction.

NOTE: Some of the fields within PendingSweepsRequest are not guaranteed to remain supported. This is an advanced API that depends on the internals of the UtxoSweeper, so things may change. | | BumpFee | BumpFeeRequest | BumpFeeResponse | BumpFee bumps the fee of an arbitrary input within a transaction. This RPC takes a different approach than bitcoind's bumpfee command. lnd has a central batching engine in which inputs with similar fee rates are batched together to save on transaction fees. Due to this, we cannot rely on bumping the fee on a specific transaction, since transactions can change at any point with the addition of new inputs. The list of inputs that currently exist within lnd's central batching engine can be retrieved through the PendingSweeps RPC.

When bumping the fee of an input that currently exists within lnd's central batching engine, a higher fee transaction will be created that replaces the lower fee transaction through the Replace-By-Fee (RBF) policy. If it

This RPC also serves useful when wanting to perform a Child-Pays-For-Parent (CPFP), where the child transaction pays for its parent's fee. This can be done by specifying an outpoint within the low fee transaction that is under the control of the wallet.

The fee preference can be expressed either as a specific fee rate or a delta of blocks in which the output should be swept on-chain within. If a fee preference is not explicitly specified, then an error is returned.

Note that this RPC currently doesn't perform any validation checks on the fee preference being provided. For now, the responsibility of ensuring that the new fee preference is sufficient is delegated to the user. |

Top

autopilotrpc/autopilot.proto

ModifyStatusRequest

FieldTypeLabelDescription
enableboolWhether the autopilot agent should be enabled or not.

ModifyStatusResponse

QueryScoresRequest

FieldTypeLabelDescription
pubkeysstringrepeated
ignore_local_stateboolIf set, we will ignore the local channel state when calculating scores.

QueryScoresResponse

FieldTypeLabelDescription
resultsQueryScoresResponse.HeuristicResultrepeated

QueryScoresResponse.HeuristicResult

FieldTypeLabelDescription
heuristicstring
scoresQueryScoresResponse.HeuristicResult.ScoresEntryrepeated

QueryScoresResponse.HeuristicResult.ScoresEntry

FieldTypeLabelDescription
keystring
valuedouble

SetScoresRequest

FieldTypeLabelDescription
heuristicstringThe name of the heuristic to provide scores to.
scoresSetScoresRequest.ScoresEntryrepeatedA map from hex-encoded public keys to scores. Scores must be in the range [0.0, 1.0].

SetScoresRequest.ScoresEntry

FieldTypeLabelDescription
keystring
valuedouble

SetScoresResponse

StatusRequest

StatusResponse

FieldTypeLabelDescription
activeboolIndicates whether the autopilot is active or not.

Autopilot

Autopilot is a service that can be used to get information about the current state of the daemon's autopilot agent, and also supply it with information that can be used when deciding where to open channels.

Method NameRequest TypeResponse TypeDescription
StatusStatusRequestStatusResponseStatus returns whether the daemon's autopilot agent is active.
ModifyStatusModifyStatusRequestModifyStatusResponseModifyStatus is used to modify the status of the autopilot agent, like enabling or disabling it.
QueryScoresQueryScoresRequestQueryScoresResponseQueryScores queries all available autopilot heuristics, in addition to any active combination of these heruristics, for the scores they would give to the given nodes.
SetScoresSetScoresRequestSetScoresResponseSetScores attempts to set the scores used by the running autopilot agent, if the external scoring heuristic is enabled.

Top

invoicesrpc/invoices.proto

AddHoldInvoiceRequest

FieldTypeLabelDescription
memostringAn optional memo to attach along with the invoice. Used for record keeping purposes for the invoice's creator, and will also be set in the description field of the encoded payment request if the description_hash field is not being used.
hashbytesThe hash of the preimage
valueint64The value of this invoice in satoshis
description_hashbytesHash (SHA-256) of a description of the payment. Used if the description of payment (memo) is too long to naturally fit within the description field of an encoded payment request.
expiryint64Payment request expiry time in seconds. Default is 3600 (1 hour).
fallback_addrstringFallback on-chain address.
cltv_expiryuint64Delta to use for the time-lock of the CLTV extended to the final hop.
route_hintslnrpc.RouteHintrepeatedRoute hints that can each be individually used to assist in reaching the invoice's destination.
privateboolWhether this invoice should include routing hints for private channels.

AddHoldInvoiceResp

FieldTypeLabelDescription
payment_requeststringA bare-bones invoice for a payment within the Lightning Network. With the details of the invoice, the sender has all the data necessary to send a payment to the recipient.

CancelInvoiceMsg

FieldTypeLabelDescription
payment_hashbytesHash corresponding to the (hold) invoice to cancel.

CancelInvoiceResp

SettleInvoiceMsg

FieldTypeLabelDescription
preimagebytesExternally discovered pre-image that should be used to settle the hold invoice.

SettleInvoiceResp

SubscribeSingleInvoiceRequest

FieldTypeLabelDescription
r_hashbytesHash corresponding to the (hold) invoice to subscribe to.

Invoices

Invoices is a service that can be used to create, accept, settle and cancel invoices.

Method NameRequest TypeResponse TypeDescription
SubscribeSingleInvoiceSubscribeSingleInvoiceRequest.lnrpc.Invoice streamSubscribeSingleInvoice returns a uni-directional stream (server -> client) to notify the client of state transitions of the specified invoice. Initially the current invoice state is always sent out.
CancelInvoiceCancelInvoiceMsgCancelInvoiceRespCancelInvoice cancels a currently open invoice. If the invoice is already canceled, this call will succeed. If the invoice is already settled, it will fail.
AddHoldInvoiceAddHoldInvoiceRequestAddHoldInvoiceRespAddHoldInvoice creates a hold invoice. It ties the invoice to the hash supplied in the request.
SettleInvoiceSettleInvoiceMsgSettleInvoiceRespSettleInvoice settles an accepted invoice. If the invoice is already settled, this call will succeed.

Top

rpc.proto

AbandonChannelRequest

FieldTypeLabelDescription
channel_pointChannelPoint

AbandonChannelResponse

AddInvoiceResponse

FieldTypeLabelDescription
r_hashbytes
payment_requeststringA bare-bones invoice for a payment within the Lightning Network. With the details of the invoice, the sender has all the data necessary to send a payment to the recipient.
add_indexuint64The "add" index of this invoice. Each newly created invoice will increment this index making it monotonically increasing. Callers to the SubscribeInvoices call can use this to instantly get notified of all added invoices with an add_index greater than this one.

Chain

FieldTypeLabelDescription
chainstringThe blockchain the node is on (eg bitcoin, litecoin)
networkstringThe network the node is on (eg regtest, testnet, mainnet)

ChanBackupExportRequest

ChanBackupSnapshot

FieldTypeLabelDescription
single_chan_backupsChannelBackupsThe set of new channels that have been added since the last channel backup snapshot was requested.
multi_chan_backupMultiChanBackupA multi-channel backup that covers all open channels currently known to lnd.

ChanInfoRequest

FieldTypeLabelDescription
chan_iduint64The unique channel ID for the channel. The first 3 bytes are the block height, the next 3 the index within the block, and the last 2 bytes are the output index for the channel.

ChangePasswordRequest

FieldTypeLabelDescription
current_passwordbytescurrent_password should be the current valid passphrase used to unlock the daemon.
new_passwordbytesnew_password should be the new passphrase that will be needed to unlock the daemon.

ChangePasswordResponse

Channel

FieldTypeLabelDescription
activeboolWhether this channel is active or not
remote_pubkeystringThe identity pubkey of the remote node
channel_pointstringThe outpoint (txid:index) of the funding transaction. With this value, Bob will be able to generate a signature for Alice's version of the commitment transaction.
chan_iduint64The unique channel ID for the channel. The first 3 bytes are the block height, the next 3 the index within the block, and the last 2 bytes are the output index for the channel.
capacityint64The total amount of funds held in this channel
local_balanceint64This node's current balance in this channel
remote_balanceint64The counterparty's current balance in this channel
commit_feeint64The amount calculated to be paid in fees for the current set of commitment transactions. The fee amount is persisted with the channel in order to allow the fee amount to be removed and recalculated with each channel state update, including updates that happen after a system restart.
commit_weightint64The weight of the commitment transaction
fee_per_kwint64The required number of satoshis per kilo-weight that the requester will pay at all times, for both the funding transaction and commitment transaction. This value can later be updated once the channel is open.
unsettled_balanceint64The unsettled balance in this channel
total_satoshis_sentint64The total number of satoshis we've sent within this channel.
total_satoshis_receivedint64The total number of satoshis we've received within this channel.
num_updatesuint64The total number of updates conducted within this channel.
pending_htlcsHTLCrepeatedThe list of active, uncleared HTLCs currently pending within the channel.
csv_delayuint32The CSV delay expressed in relative blocks. If the channel is force closed, we will need to wait for this many blocks before we can regain our funds.
privateboolWhether this channel is advertised to the network or not.
initiatorboolTrue if we were the ones that created the channel.
chan_status_flagsstringA set of flags showing the current state of the channel.
local_chan_reserve_satint64The minimum satoshis this node is required to reserve in its balance.
remote_chan_reserve_satint64The minimum satoshis the other node is required to reserve in its balance.

ChannelBackup

FieldTypeLabelDescription
chan_pointChannelPointIdentifies the channel that this backup belongs to.
chan_backupbytesIs an encrypted single-chan backup. this can be passed to RestoreChannelBackups, or the WalletUnlocker Init and Unlock methods in order to trigger the recovery protocol.

ChannelBackupSubscription

ChannelBackups

FieldTypeLabelDescription
chan_backupsChannelBackuprepeatedA set of single-chan static channel backups.

ChannelBalanceRequest

ChannelBalanceResponse

FieldTypeLabelDescription
balanceint64Sum of channels balances denominated in satoshis
pending_open_balanceint64Sum of channels pending balances denominated in satoshis

ChannelCloseSummary

FieldTypeLabelDescription
channel_pointstringThe outpoint (txid:index) of the funding transaction.
chan_iduint64The unique channel ID for the channel.
chain_hashstringThe hash of the genesis block that this channel resides within.
closing_tx_hashstringThe txid of the transaction which ultimately closed this channel.
remote_pubkeystringPublic key of the remote peer that we formerly had a channel with.
capacityint64Total capacity of the channel.
close_heightuint32Height at which the funding transaction was spent.
settled_balanceint64Settled balance at the time of channel closure
time_locked_balanceint64The sum of all the time-locked outputs at the time of channel closure
close_typeChannelCloseSummary.ClosureTypeDetails on how the channel was closed.

ChannelCloseUpdate

FieldTypeLabelDescription
closing_txidbytes
successbool

ChannelEdge

A fully authenticated channel along with all its unique attributes. Once an authenticated channel announcement has been processed on the network, then an instance of ChannelEdgeInfo encapsulating the channels attributes is stored. The other portions relevant to routing policy of a channel are stored within a ChannelEdgePolicy for each direction of the channel.

FieldTypeLabelDescription
channel_iduint64The unique channel ID for the channel. The first 3 bytes are the block height, the next 3 the index within the block, and the last 2 bytes are the output index for the channel.
chan_pointstring
last_updateuint32
node1_pubstring
node2_pubstring
capacityint64
node1_policyRoutingPolicy
node2_policyRoutingPolicy

ChannelEdgeUpdate

FieldTypeLabelDescription
chan_iduint64The unique channel ID for the channel. The first 3 bytes are the block height, the next 3 the index within the block, and the last 2 bytes are the output index for the channel.
chan_pointChannelPoint
capacityint64
routing_policyRoutingPolicy
advertising_nodestring
connecting_nodestring

ChannelEventSubscription

ChannelEventUpdate

FieldTypeLabelDescription
open_channelChannel
closed_channelChannelCloseSummary
active_channelChannelPoint
inactive_channelChannelPoint
typeChannelEventUpdate.UpdateType

ChannelFeeReport

FieldTypeLabelDescription
chan_pointstringThe channel that this fee report belongs to.
base_fee_msatint64The base fee charged regardless of the number of milli-satoshis sent.
fee_per_milint64The amount charged per milli-satoshis transferred expressed in millionths of a satoshi.
fee_ratedoubleThe effective fee rate in milli-satoshis. Computed by dividing the fee_per_mil value by 1 million.

ChannelGraph

Returns a new instance of the directed channel graph.

FieldTypeLabelDescription
nodesLightningNoderepeatedThe list of LightningNodes in this channel graph
edgesChannelEdgerepeatedThe list of ChannelEdges in this channel graph

ChannelGraphRequest

FieldTypeLabelDescription
include_unannouncedboolWhether unannounced channels are included in the response or not. If set, unannounced channels are included. Unannounced channels are both private channels, and public channels that are not yet announced to the network.

ChannelOpenUpdate

FieldTypeLabelDescription
channel_pointChannelPoint

ChannelPoint

FieldTypeLabelDescription
funding_txid_bytesbytesTxid of the funding transaction
funding_txid_strstringHex-encoded string representing the funding transaction
output_indexuint32The index of the output of the funding transaction

CloseChannelRequest

FieldTypeLabelDescription
channel_pointChannelPointThe outpoint (txid:index) of the funding transaction. With this value, Bob will be able to generate a signature for Alice's version of the commitment transaction.
forceboolIf true, then the channel will be closed forcibly. This means the current commitment transaction will be signed and broadcast.
target_confint32The target number of blocks that the closure transaction should be confirmed by.
sat_per_byteint64A manual fee rate set in sat/byte that should be used when crafting the closure transaction.

CloseStatusUpdate

FieldTypeLabelDescription
close_pendingPendingUpdate
chan_closeChannelCloseUpdate

ClosedChannelUpdate

FieldTypeLabelDescription
chan_iduint64The unique channel ID for the channel. The first 3 bytes are the block height, the next 3 the index within the block, and the last 2 bytes are the output index for the channel.
capacityint64
closed_heightuint32
chan_pointChannelPoint

ClosedChannelsRequest

FieldTypeLabelDescription
cooperativebool
local_forcebool
remote_forcebool
breachbool
funding_canceledbool
abandonedbool

ClosedChannelsResponse

FieldTypeLabelDescription
channelsChannelCloseSummaryrepeated

ConfirmationUpdate

FieldTypeLabelDescription
block_shabytes
block_heightint32
num_confs_leftuint32

ConnectPeerRequest

FieldTypeLabelDescription
addrLightningAddressLightning address of the peer, in the format <pubkey>@host
permboolIf set, the daemon will attempt to persistently connect to the target peer. Otherwise, the call will be synchronous.

ConnectPeerResponse

DebugLevelRequest

FieldTypeLabelDescription
showbool
level_specstring

DebugLevelResponse

FieldTypeLabelDescription
sub_systemsstring

DeleteAllPaymentsRequest

DeleteAllPaymentsResponse

DisconnectPeerRequest

FieldTypeLabelDescription
pub_keystringThe pubkey of the node to disconnect from

DisconnectPeerResponse

EdgeLocator

FieldTypeLabelDescription
channel_iduint64The short channel id of this edge.
direction_reverseboolThe direction of this edge. If direction_reverse is false, the direction of this edge is from the channel endpoint with the lexicographically smaller pub key to the endpoint with the larger pub key. If direction_reverse is is true, the edge goes the other way.

EstimateFeeRequest

FieldTypeLabelDescription
AddrToAmountEstimateFeeRequest.AddrToAmountEntryrepeatedThe map from addresses to amounts for the transaction.
target_confint32The target number of blocks that this transaction should be confirmed by.

EstimateFeeRequest.AddrToAmountEntry

FieldTypeLabelDescription
keystring
valueint64

EstimateFeeResponse

FieldTypeLabelDescription
fee_satint64The total fee in satoshis.
feerate_sat_per_byteint64The fee rate in satoshi/byte.

ExportChannelBackupRequest

FieldTypeLabelDescription
chan_pointChannelPointThe target channel point to obtain a back up for.

FeeLimit

FieldTypeLabelDescription
fixedint64The fee limit expressed as a fixed amount of satoshis.
percentint64The fee limit expressed as a percentage of the payment amount.

FeeReportRequest

FeeReportResponse

FieldTypeLabelDescription
channel_feesChannelFeeReportrepeatedAn array of channel fee reports which describes the current fee schedule for each channel.
day_fee_sumuint64The total amount of fee revenue (in satoshis) the switch has collected over the past 24 hrs.
week_fee_sumuint64The total amount of fee revenue (in satoshis) the switch has collected over the past 1 week.
month_fee_sumuint64The total amount of fee revenue (in satoshis) the switch has collected over the past 1 month.

ForwardingEvent

FieldTypeLabelDescription
timestampuint64Timestamp is the time (unix epoch offset) that this circuit was completed.
chan_id_inuint64The incoming channel ID that carried the HTLC that created the circuit.
chan_id_outuint64The outgoing channel ID that carried the preimage that completed the circuit.
amt_inuint64The total amount (in satoshis) of the incoming HTLC that created half the circuit.
amt_outuint64The total amount (in satoshis) of the outgoing HTLC that created the second half of the circuit.
feeuint64The total fee (in satoshis) that this payment circuit carried.
fee_msatuint64The total fee (in milli-satoshis) that this payment circuit carried.

ForwardingHistoryRequest

FieldTypeLabelDescription
start_timeuint64Start time is the starting point of the forwarding history request. All records beyond this point will be included, respecting the end time, and the index offset.
end_timeuint64End time is the end point of the forwarding history request. The response will carry at most 50k records between the start time and the end time. The index offset can be used to implement pagination.
index_offsetuint32Index offset is the offset in the time series to start at. As each response can only contain 50k records, callers can use this to skip around within a packed time series.
num_max_eventsuint32The max number of events to return in the response to this query.

ForwardingHistoryResponse

FieldTypeLabelDescription
forwarding_eventsForwardingEventrepeatedA list of forwarding events from the time slice of the time series specified in the request.
last_offset_indexuint32The index of the last time in the set of returned forwarding events. Can be used to seek further, pagination style.

GenSeedRequest

FieldTypeLabelDescription
aezeed_passphrasebytesaezeed_passphrase is an optional user provided passphrase that will be used to encrypt the generated aezeed cipher seed.
seed_entropybytesseed_entropy is an optional 16-bytes generated via CSPRNG. If not specified, then a fresh set of randomness will be used to create the seed.

GenSeedResponse

FieldTypeLabelDescription
cipher_seed_mnemonicstringrepeatedcipher_seed_mnemonic is a 24-word mnemonic that encodes a prior aezeed cipher seed obtained by the user. This field is optional, as if not provided, then the daemon will generate a new cipher seed for the user. Otherwise, then the daemon will attempt to recover the wallet state linked to this cipher seed.
enciphered_seedbytesenciphered_seed are the raw aezeed cipher seed bytes. This is the raw cipher text before run through our mnemonic encoding scheme.

GetInfoRequest

GetInfoResponse

FieldTypeLabelDescription
identity_pubkeystringThe identity pubkey of the current node.
aliasstringIf applicable, the alias of the current node, e.g. "bob"
num_pending_channelsuint32Number of pending channels
num_active_channelsuint32Number of active channels
num_peersuint32Number of peers
block_heightuint32The node's current view of the height of the best block
block_hashstringThe node's current view of the hash of the best block
synced_to_chainboolWhether the wallet's view is synced to the main chain
testnetboolWhether the current node is connected to testnet. This field is deprecated and the network field should be used instead
urisstringrepeatedThe URIs of the current node.
best_header_timestampint64Timestamp of the block best known to the wallet
versionstringThe version of the LND software that the node is running.
num_inactive_channelsuint32Number of inactive channels
chainsChainrepeatedA list of active chains the node is connected to
colorstringThe color of the current node in hex code format
synced_to_graphboolWhether we consider ourselves synced with the public channel graph.

GetTransactionsRequest

GraphTopologySubscription

GraphTopologyUpdate

FieldTypeLabelDescription
node_updatesNodeUpdaterepeated
channel_updatesChannelEdgeUpdaterepeated
closed_chansClosedChannelUpdaterepeated

HTLC

FieldTypeLabelDescription
incomingbool
amountint64
hash_lockbytes
expiration_heightuint32

Hop

FieldTypeLabelDescription
chan_iduint64The unique channel ID for the channel. The first 3 bytes are the block height, the next 3 the index within the block, and the last 2 bytes are the output index for the channel.
chan_capacityint64
amt_to_forwardint64
feeint64
expiryuint32
amt_to_forward_msatint64
fee_msatint64
pub_keystringAn optional public key of the hop. If the public key is given, the payment can be executed without relying on a copy of the channel graph.
tlv_payloadboolIf set to true, then this hop will be encoded using the new variable length TLV format. Note that if any custom tlv_records below are specified, then this field MUST be set to true for them to be encoded properly.
tlv_recordsHop.TlvRecordsEntryrepeatedAn optional set of key-value TLV records. This is useful within the context of the SendToRoute call as it allows callers to specify arbitrary K-V pairs to drop off at each hop within the onion.

Hop.TlvRecordsEntry

FieldTypeLabelDescription
keyuint64
valuebytes

HopHint

FieldTypeLabelDescription
node_idstringThe public key of the node at the start of the channel.
chan_iduint64The unique identifier of the channel.
fee_base_msatuint32The base fee of the channel denominated in millisatoshis.
fee_proportional_millionthsuint32The fee rate of the channel for sending one satoshi across it denominated in millionths of a satoshi.
cltv_expiry_deltauint32The time-lock delta of the channel.

InitWalletRequest

FieldTypeLabelDescription
wallet_passwordbyteswallet_password is the passphrase that should be used to encrypt the wallet. This MUST be at least 8 chars in length. After creation, this password is required to unlock the daemon.
cipher_seed_mnemonicstringrepeatedcipher_seed_mnemonic is a 24-word mnemonic that encodes a prior aezeed cipher seed obtained by the user. This may have been generated by the GenSeed method, or be an existing seed.
aezeed_passphrasebytesaezeed_passphrase is an optional user provided passphrase that will be used to encrypt the generated aezeed cipher seed.
recovery_windowint32recovery_window is an optional argument specifying the address lookahead when restoring a wallet seed. The recovery window applies to each individual branch of the BIP44 derivation paths. Supplying a recovery window of zero indicates that no addresses should be recovered, such after the first initialization of the wallet.
channel_backupsChanBackupSnapshotchannel_backups is an optional argument that allows clients to recover the settled funds within a set of channels. This should be populated if the user was unable to close out all channels and sweep funds before partial or total data loss occurred. If specified, then after on-chain recovery of funds, lnd begin to carry out the data loss recovery protocol in order to recover the funds in each channel from a remote force closed transaction.

InitWalletResponse

Invoice

FieldTypeLabelDescription
memostringAn optional memo to attach along with the invoice. Used for record keeping purposes for the invoice's creator, and will also be set in the description field of the encoded payment request if the description_hash field is not being used.
receiptbytesDeprecated. An optional cryptographic receipt of payment which is not implemented.
r_preimagebytesThe hex-encoded preimage (32 byte) which will allow settling an incoming HTLC payable to this preimage
r_hashbytesThe hash of the preimage
valueint64The value of this invoice in satoshis
settledboolWhether this invoice has been fulfilled
creation_dateint64When this invoice was created
settle_dateint64When this invoice was settled
payment_requeststringA bare-bones invoice for a payment within the Lightning Network. With the details of the invoice, the sender has all the data necessary to send a payment to the recipient.
description_hashbytesHash (SHA-256) of a description of the payment. Used if the description of payment (memo) is too long to naturally fit within the description field of an encoded payment request.
expiryint64Payment request expiry time in seconds. Default is 3600 (1 hour).
fallback_addrstringFallback on-chain address.
cltv_expiryuint64Delta to use for the time-lock of the CLTV extended to the final hop.
route_hintsRouteHintrepeatedRoute hints that can each be individually used to assist in reaching the invoice's destination.
privateboolWhether this invoice should include routing hints for private channels.
add_indexuint64The "add" index of this invoice. Each newly created invoice will increment this index making it monotonically increasing. Callers to the SubscribeInvoices call can use this to instantly get notified of all added invoices with an add_index greater than this one.
settle_indexuint64The "settle" index of this invoice. Each newly settled invoice will increment this index making it monotonically increasing. Callers to the SubscribeInvoices call can use this to instantly get notified of all settled invoices with an settle_index greater than this one.
amt_paidint64Deprecated, use amt_paid_sat or amt_paid_msat.
amt_paid_satint64The amount that was accepted for this invoice, in satoshis. This will ONLY be set if this invoice has been settled. We provide this field as if the invoice was created with a zero value, then we need to record what amount was ultimately accepted. Additionally, it's possible that the sender paid MORE that was specified in the original invoice. So we'll record that here as well.
amt_paid_msatint64The amount that was accepted for this invoice, in millisatoshis. This will ONLY be set if this invoice has been settled. We provide this field as if the invoice was created with a zero value, then we need to record what amount was ultimately accepted. Additionally, it's possible that the sender paid MORE that was specified in the original invoice. So we'll record that here as well.
stateInvoice.InvoiceStateThe state the invoice is in.
htlcsInvoiceHTLCrepeatedList of HTLCs paying to this invoice [EXPERIMENTAL].

InvoiceHTLC

Details of an HTLC that paid to an invoice

FieldTypeLabelDescription
chan_iduint64Short channel id over which the htlc was received.
htlc_indexuint64Index identifying the htlc on the channel.
amt_msatuint64The amount of the htlc in msat.
accept_heightint32Block height at which this htlc was accepted.
accept_timeint64Time at which this htlc was accepted.
resolve_timeint64Time at which this htlc was settled or cancelled.
expiry_heightint32Block height at which this htlc expires.
stateInvoiceHTLCStateCurrent state the htlc is in.

InvoiceSubscription

FieldTypeLabelDescription
add_indexuint64If specified (non-zero), then we'll first start by sending out notifications for all added indexes with an add_index greater than this value. This allows callers to catch up on any events they missed while they weren't connected to the streaming RPC.
settle_indexuint64If specified (non-zero), then we'll first start by sending out notifications for all settled indexes with an settle_index greater than this value. This allows callers to catch up on any events they missed while they weren't connected to the streaming RPC.

LightningAddress

FieldTypeLabelDescription
pubkeystringThe identity pubkey of the Lightning node
hoststringThe network location of the lightning node, e.g. 69.69.69.69:1337 or localhost:10011

LightningNode

An individual vertex/node within the channel graph. A node is connected to other nodes by one or more channel edges emanating from it. As the graph is directed, a node will also have an incoming edge attached to it for each outgoing edge.

FieldTypeLabelDescription
last_updateuint32
pub_keystring
aliasstring
addressesNodeAddressrepeated
colorstring

ListChannelsRequest

FieldTypeLabelDescription
active_onlybool
inactive_onlybool
public_onlybool
private_onlybool

ListChannelsResponse

FieldTypeLabelDescription
channelsChannelrepeatedThe list of active channels

ListInvoiceRequest

FieldTypeLabelDescription
pending_onlyboolIf set, only unsettled invoices will be returned in the response.
index_offsetuint64The index of an invoice that will be used as either the start or end of a query to determine which invoices should be returned in the response.
num_max_invoicesuint64The max number of invoices to return in the response to this query.
reversedboolIf set, the invoices returned will result from seeking backwards from the specified index offset. This can be used to paginate backwards.

ListInvoiceResponse

FieldTypeLabelDescription
invoicesInvoicerepeatedA list of invoices from the time slice of the time series specified in the request.
last_index_offsetuint64The index of the last item in the set of returned invoices. This can be used to seek further, pagination style.
first_index_offsetuint64The index of the last item in the set of returned invoices. This can be used to seek backwards, pagination style.

ListPaymentsRequest

FieldTypeLabelDescription
include_incompleteboolIf true, then return payments that have not yet fully completed. This means that pending payments, as well as failed payments will show up if this field is set to True.

ListPaymentsResponse

FieldTypeLabelDescription
paymentsPaymentrepeatedThe list of payments

ListPeersRequest

ListPeersResponse

FieldTypeLabelDescription
peersPeerrepeatedThe list of currently connected peers

ListUnspentRequest

FieldTypeLabelDescription
min_confsint32The minimum number of confirmations to be included.
max_confsint32The maximum number of confirmations to be included.

ListUnspentResponse

FieldTypeLabelDescription
utxosUtxorepeatedA list of utxos

MultiChanBackup

FieldTypeLabelDescription
chan_pointsChannelPointrepeatedIs the set of all channels that are included in this multi-channel backup.
multi_chan_backupbytesA single encrypted blob containing all the static channel backups of the channel listed above. This can be stored as a single file or blob, and safely be replaced with any prior/future versions.

NetworkInfo

FieldTypeLabelDescription
graph_diameteruint32
avg_out_degreedouble
max_out_degreeuint32
num_nodesuint32
num_channelsuint32
total_network_capacityint64
avg_channel_sizedouble
min_channel_sizeint64
max_channel_sizeint64
median_channel_size_satint64
num_zombie_chansuint64The number of edges marked as zombies.

NetworkInfoRequest

NewAddressRequest

FieldTypeLabelDescription
typeAddressTypeThe address type

NewAddressResponse

FieldTypeLabelDescription
addressstringThe newly generated wallet address

NodeAddress

FieldTypeLabelDescription
networkstring
addrstring

NodeInfo

FieldTypeLabelDescription
nodeLightningNodeAn individual vertex/node within the channel graph. A node is connected to other nodes by one or more channel edges emanating from it. As the graph is directed, a node will also have an incoming edge attached to it for each outgoing edge.
num_channelsuint32The total number of channels for the node.
total_capacityint64The sum of all channels capacity for the node, denominated in satoshis.
channelsChannelEdgerepeatedA list of all public channels for the node.

NodeInfoRequest

FieldTypeLabelDescription
pub_keystringThe 33-byte hex-encoded compressed public of the target node
include_channelsboolIf true, will include all known channels associated with the node.

NodePair

FieldTypeLabelDescription
frombytesThe sending node of the pair.
tobytesThe receiving node of the pair.

NodeUpdate

FieldTypeLabelDescription
addressesstringrepeated
identity_keystring
global_featuresbytes
aliasstring
colorstring

OpenChannelRequest

FieldTypeLabelDescription
node_pubkeybytesThe pubkey of the node to open a channel with
node_pubkey_stringstringThe hex encoded pubkey of the node to open a channel with
local_funding_amountint64The number of satoshis the wallet should commit to the channel
push_satint64The number of satoshis to push to the remote side as part of the initial commitment state
target_confint32The target number of blocks that the funding transaction should be confirmed by.
sat_per_byteint64A manual fee rate set in sat/byte that should be used when crafting the funding transaction.
privateboolWhether this channel should be private, not announced to the greater network.
min_htlc_msatint64The minimum value in millisatoshi we will require for incoming HTLCs on the channel.
remote_csv_delayuint32The delay we require on the remote's commitment transaction. If this is not set, it will be scaled automatically with the channel size.
min_confsint32The minimum number of confirmations each one of your outputs used for the funding transaction must satisfy.
spend_unconfirmedboolWhether unconfirmed outputs should be used as inputs for the funding transaction.

OpenStatusUpdate

FieldTypeLabelDescription
chan_pendingPendingUpdate
chan_openChannelOpenUpdate

OutPoint

FieldTypeLabelDescription
txid_bytesbytesRaw bytes representing the transaction id.
txid_strstringReversed, hex-encoded string representing the transaction id.
output_indexuint32The index of the output on the transaction.

PayReq

FieldTypeLabelDescription
destinationstring
payment_hashstring
num_satoshisint64
timestampint64
expiryint64
descriptionstring
description_hashstring
fallback_addrstring
cltv_expiryint64
route_hintsRouteHintrepeated

PayReqString

FieldTypeLabelDescription
pay_reqstringThe payment request string to be decoded

Payment

FieldTypeLabelDescription
payment_hashstringThe payment hash
valueint64Deprecated, use value_sat or value_msat.
creation_dateint64The date of this payment
pathstringrepeatedThe path this payment took
feeint64Deprecated, use fee_sat or fee_msat.
payment_preimagestringThe payment preimage
value_satint64The value of the payment in satoshis
value_msatint64The value of the payment in milli-satoshis
payment_requeststringThe optional payment request being fulfilled.
statusPayment.PaymentStatusThe status of the payment.
fee_satint64The fee paid for this payment in satoshis
fee_msatint64The fee paid for this payment in milli-satoshis

PaymentHash

FieldTypeLabelDescription
r_hash_strstringThe hex-encoded payment hash of the invoice to be looked up. The passed payment hash must be exactly 32 bytes, otherwise an error is returned.
r_hashbytesThe payment hash of the invoice to be looked up.

Peer

FieldTypeLabelDescription
pub_keystringThe identity pubkey of the peer
addressstringNetwork address of the peer; eg 127.0.0.1:10011
bytes_sentuint64Bytes of data transmitted to this peer
bytes_recvuint64Bytes of data transmitted from this peer
sat_sentint64Satoshis sent to this peer
sat_recvint64Satoshis received from this peer
inboundboolA channel is inbound if the counterparty initiated the channel
ping_timeint64Ping time to this peer
sync_typePeer.SyncTypeThe type of sync we are currently performing with this peer.

PendingChannelsRequest

PendingChannelsResponse

FieldTypeLabelDescription
total_limbo_balanceint64The balance in satoshis encumbered in pending channels
pending_open_channelsPendingChannelsResponse.PendingOpenChannelrepeatedChannels pending opening
pending_closing_channelsPendingChannelsResponse.ClosedChannelrepeatedChannels pending closing
pending_force_closing_channelsPendingChannelsResponse.ForceClosedChannelrepeatedChannels pending force closing
waiting_close_channelsPendingChannelsResponse.WaitingCloseChannelrepeatedChannels waiting for closing tx to confirm

PendingChannelsResponse.ClosedChannel

FieldTypeLabelDescription
channelPendingChannelsResponse.PendingChannelThe pending channel to be closed
closing_txidstringThe transaction id of the closing transaction

PendingChannelsResponse.ForceClosedChannel

FieldTypeLabelDescription
channelPendingChannelsResponse.PendingChannelThe pending channel to be force closed
closing_txidstringThe transaction id of the closing transaction
limbo_balanceint64The balance in satoshis encumbered in this pending channel
maturity_heightuint32The height at which funds can be swept into the wallet
blocks_til_maturityint32Remaining # of blocks until the commitment output can be swept. Negative values indicate how many blocks have passed since becoming mature.
recovered_balanceint64The total value of funds successfully recovered from this channel
pending_htlcsPendingHTLCrepeated

PendingChannelsResponse.PendingChannel

FieldTypeLabelDescription
remote_node_pubstring
channel_pointstring
capacityint64
local_balanceint64
remote_balanceint64
local_chan_reserve_satint64The minimum satoshis this node is required to reserve in its balance.
remote_chan_reserve_satint64The minimum satoshis the other node is required to reserve in its balance.

PendingChannelsResponse.PendingOpenChannel

FieldTypeLabelDescription
channelPendingChannelsResponse.PendingChannelThe pending channel
confirmation_heightuint32The height at which this channel will be confirmed
commit_feeint64The amount calculated to be paid in fees for the current set of commitment transactions. The fee amount is persisted with the channel in order to allow the fee amount to be removed and recalculated with each channel state update, including updates that happen after a system restart.
commit_weightint64The weight of the commitment transaction
fee_per_kwint64The required number of satoshis per kilo-weight that the requester will pay at all times, for both the funding transaction and commitment transaction. This value can later be updated once the channel is open.

PendingChannelsResponse.WaitingCloseChannel

FieldTypeLabelDescription
channelPendingChannelsResponse.PendingChannelThe pending channel waiting for closing tx to confirm
limbo_balanceint64The balance in satoshis encumbered in this channel

PendingHTLC

FieldTypeLabelDescription
incomingboolThe direction within the channel that the htlc was sent
amountint64The total value of the htlc
outpointstringThe final output to be swept back to the user's wallet
maturity_heightuint32The next block height at which we can spend the current stage
blocks_til_maturityint32The number of blocks remaining until the current stage can be swept. Negative values indicate how many blocks have passed since becoming mature.
stageuint32Indicates whether the htlc is in its first or second stage of recovery

PendingUpdate

FieldTypeLabelDescription
txidbytes
output_indexuint32

PolicyUpdateRequest

FieldTypeLabelDescription
globalboolIf set, then this update applies to all currently active channels.
chan_pointChannelPointIf set, this update will target a specific channel.
base_fee_msatint64The base fee charged regardless of the number of milli-satoshis sent.
fee_ratedoubleThe effective fee rate in milli-satoshis. The precision of this value goes up to 6 decimal places, so 1e-6.
time_lock_deltauint32The required timelock delta for HTLCs forwarded over the channel.

PolicyUpdateResponse

QueryRoutesRequest

FieldTypeLabelDescription
pub_keystringThe 33-byte hex-encoded public key for the payment destination
amtint64The amount to send expressed in satoshis
final_cltv_deltaint32An optional CLTV delta from the current height that should be used for the timelock of the final hop
fee_limitFeeLimitThe maximum number of satoshis that will be paid as a fee of the payment. This value can be represented either as a percentage of the amount being sent, or as a fixed amount of the maximum fee the user is willing the pay to send the payment.
ignored_nodesbytesrepeatedA list of nodes to ignore during path finding.
ignored_edgesEdgeLocatorrepeatedDeprecated. A list of edges to ignore during path finding.
source_pub_keystringThe source node where the request route should originated from. If empty, self is assumed.
use_mission_controlboolIf set to true, edge probabilities from mission control will be used to get the optimal route.
ignored_pairsNodePairrepeatedA list of directed node pairs that will be ignored during path finding.
dest_tlvQueryRoutesRequest.DestTlvEntryrepeatedAn optional field that can be used to pass an arbitrary set of TLV records to a peer which understands the new records. This can be used to pass application specific data during the payment attempt. If the destination does not support the specified recrods, and error will be returned.

QueryRoutesRequest.DestTlvEntry

FieldTypeLabelDescription
keyuint64
valuebytes

QueryRoutesResponse

FieldTypeLabelDescription
routesRouterepeatedThe route that results from the path finding operation. This is still a repeated field to retain backwards compatibility.
success_probdoubleThe success probability of the returned route based on the current mission control state. [EXPERIMENTAL]

RestoreBackupResponse

RestoreChanBackupRequest

FieldTypeLabelDescription
chan_backupsChannelBackups
multi_chan_backupbytes

Route

A path through the channel graph which runs over one or more channels in succession. This struct carries all the information required to craft the Sphinx onion packet, and send the payment along the first hop in the path. A route is only selected as valid if all the channels have sufficient capacity to carry the initial payment amount after fees are accounted for.

FieldTypeLabelDescription
total_time_lockuint32The cumulative (final) time lock across the entire route. This is the CLTV value that should be extended to the first hop in the route. All other hops will decrement the time-lock as advertised, leaving enough time for all hops to wait for or present the payment preimage to complete the payment.
total_feesint64The sum of the fees paid at each hop within the final route. In the case of a one-hop payment, this value will be zero as we don't need to pay a fee to ourselves.
total_amtint64The total amount of funds required to complete a payment over this route. This value includes the cumulative fees at each hop. As a result, the HTLC extended to the first-hop in the route will need to have at least this many satoshis, otherwise the route will fail at an intermediate node due to an insufficient amount of fees.
hopsHoprepeatedContains details concerning the specific forwarding details at each hop.
total_fees_msatint64The total fees in millisatoshis.
total_amt_msatint64The total amount in millisatoshis.

RouteHint

FieldTypeLabelDescription
hop_hintsHopHintrepeatedA list of hop hints that when chained together can assist in reaching a specific destination.

RoutingPolicy

FieldTypeLabelDescription
time_lock_deltauint32
min_htlcint64
fee_base_msatint64
fee_rate_milli_msatint64
disabledbool
max_htlc_msatuint64
last_updateuint32

SendCoinsRequest

FieldTypeLabelDescription
addrstringThe address to send coins to
amountint64The amount in satoshis to send
target_confint32The target number of blocks that this transaction should be confirmed by.
sat_per_byteint64A manual fee rate set in sat/byte that should be used when crafting the transaction.
send_allboolIf set, then the amount field will be ignored, and lnd will attempt to send all the coins under control of the internal wallet to the specified address.

SendCoinsResponse

FieldTypeLabelDescription
txidstringThe transaction ID of the transaction

SendManyRequest

FieldTypeLabelDescription
AddrToAmountSendManyRequest.AddrToAmountEntryrepeatedThe map from addresses to amounts
target_confint32The target number of blocks that this transaction should be confirmed by.
sat_per_byteint64A manual fee rate set in sat/byte that should be used when crafting the transaction.

SendManyRequest.AddrToAmountEntry

FieldTypeLabelDescription
keystring
valueint64

SendManyResponse

FieldTypeLabelDescription
txidstringThe id of the transaction

SendRequest

FieldTypeLabelDescription
destbytesThe identity pubkey of the payment recipient
dest_stringstringThe hex-encoded identity pubkey of the payment recipient
amtint64Number of satoshis to send.
payment_hashbytesThe hash to use within the payment's HTLC
payment_hash_stringstringThe hex-encoded hash to use within the payment's HTLC
payment_requeststringA bare-bones invoice for a payment within the Lightning Network. With the details of the invoice, the sender has all the data necessary to send a payment to the recipient.
final_cltv_deltaint32The CLTV delta from the current height that should be used to set the timelock for the final hop.
fee_limitFeeLimitThe maximum number of satoshis that will be paid as a fee of the payment. This value can be represented either as a percentage of the amount being sent, or as a fixed amount of the maximum fee the user is willing the pay to send the payment.
outgoing_chan_iduint64The channel id of the channel that must be taken to the first hop. If zero, any channel may be used.
cltv_limituint32An optional maximum total time lock for the route. If zero, there is no maximum enforced.
dest_tlvSendRequest.DestTlvEntryrepeatedAn optional field that can be used to pass an arbitrary set of TLV records to a peer which understands the new records. This can be used to pass application specific data during the payment attempt.

SendRequest.DestTlvEntry

FieldTypeLabelDescription
keyuint64
valuebytes

SendResponse

FieldTypeLabelDescription
payment_errorstring
payment_preimagebytes
payment_routeRoute
payment_hashbytes

SendToRouteRequest

FieldTypeLabelDescription
payment_hashbytesThe payment hash to use for the HTLC.
payment_hash_stringstringAn optional hex-encoded payment hash to be used for the HTLC.
routeRouteRoute that should be used to attempt to complete the payment.

SignMessageRequest

FieldTypeLabelDescription
msgbytesThe message to be signed

SignMessageResponse

FieldTypeLabelDescription
signaturestringThe signature for the given message

StopRequest

StopResponse

Transaction

FieldTypeLabelDescription
tx_hashstringThe transaction hash
amountint64The transaction amount, denominated in satoshis
num_confirmationsint32The number of confirmations
block_hashstringThe hash of the block this transaction was included in
block_heightint32The height of the block this transaction was included in
time_stampint64Timestamp of this transaction
total_feesint64Fees paid for this transaction
dest_addressesstringrepeatedAddresses that received funds for this transaction
raw_tx_hexstringThe raw transaction hex.

TransactionDetails

FieldTypeLabelDescription
transactionsTransactionrepeatedThe list of transactions relevant to the wallet.

UnlockWalletRequest

FieldTypeLabelDescription
wallet_passwordbyteswallet_password should be the current valid passphrase for the daemon. This will be required to decrypt on-disk material that the daemon requires to function properly.
recovery_windowint32recovery_window is an optional argument specifying the address lookahead when restoring a wallet seed. The recovery window applies to each individual branch of the BIP44 derivation paths. Supplying a recovery window of zero indicates that no addresses should be recovered, such after the first initialization of the wallet.
channel_backupsChanBackupSnapshotchannel_backups is an optional argument that allows clients to recover the settled funds within a set of channels. This should be populated if the user was unable to close out all channels and sweep funds before partial or total data loss occurred. If specified, then after on-chain recovery of funds, lnd begin to carry out the data loss recovery protocol in order to recover the funds in each channel from a remote force closed transaction.

UnlockWalletResponse

Utxo

FieldTypeLabelDescription
typeAddressTypeThe type of address
addressstringThe address
amount_satint64The value of the unspent coin in satoshis
pk_scriptstringThe pkscript in hex
outpointOutPointThe outpoint in format txid:n
confirmationsint64The number of confirmations for the Utxo

VerifyChanBackupResponse

VerifyMessageRequest

FieldTypeLabelDescription
msgbytesThe message over which the signature is to be verified
signaturestringThe signature to be verified over the given message

VerifyMessageResponse

FieldTypeLabelDescription
validboolWhether the signature was valid over the given message
pubkeystringThe pubkey recovered from the signature

WalletBalanceRequest

WalletBalanceResponse

FieldTypeLabelDescription
total_balanceint64The balance of the wallet
confirmed_balanceint64The confirmed balance of a wallet(with >= 1 confirmations)
unconfirmed_balanceint64The unconfirmed balance of a wallet(with 0 confirmations)

AddressType

AddressType has to be one of:

  • p2wkh: Pay to witness key hash (WITNESS_PUBKEY_HASH = 0)
  • np2wkh: Pay to nested witness key hash (NESTED_PUBKEY_HASH = 1)
NameNumberDescription
WITNESS_PUBKEY_HASH0
NESTED_PUBKEY_HASH1
UNUSED_WITNESS_PUBKEY_HASH2
UNUSED_NESTED_PUBKEY_HASH3

ChannelCloseSummary.ClosureType

NameNumberDescription
COOPERATIVE_CLOSE0
LOCAL_FORCE_CLOSE1
REMOTE_FORCE_CLOSE2
BREACH_CLOSE3
FUNDING_CANCELED4
ABANDONED5

ChannelEventUpdate.UpdateType

NameNumberDescription
OPEN_CHANNEL0
CLOSED_CHANNEL1
ACTIVE_CHANNEL2
INACTIVE_CHANNEL3

Invoice.InvoiceState

NameNumberDescription
OPEN0
SETTLED1
CANCELED2
ACCEPTED3

InvoiceHTLCState

NameNumberDescription
ACCEPTED0
SETTLED1
CANCELLED2

Payment.PaymentStatus

NameNumberDescription
UNKNOWN0
IN_FLIGHT1
SUCCEEDED2
FAILED3

Peer.SyncType

NameNumberDescription
UNKNOWN_SYNC0Denotes that we cannot determine the peer's current sync type.
ACTIVE_SYNC1Denotes that we are actively receiving new graph updates from the peer.
PASSIVE_SYNC2Denotes that we are not receiving new graph updates from the peer.

Lightning

Method NameRequest TypeResponse TypeDescription
WalletBalanceWalletBalanceRequestWalletBalanceResponselncli: walletbalance WalletBalance returns total unspent outputs(confirmed and unconfirmed), all confirmed unspent outputs and all unconfirmed unspent outputs under control of the wallet.
ChannelBalanceChannelBalanceRequestChannelBalanceResponselncli: channelbalance ChannelBalance returns the total funds available across all open channels in satoshis.
GetTransactionsGetTransactionsRequestTransactionDetailslncli: listchaintxns GetTransactions returns a list describing all the known transactions relevant to the wallet.
EstimateFeeEstimateFeeRequestEstimateFeeResponselncli: estimatefee EstimateFee asks the chain backend to estimate the fee rate and total fees for a transaction that pays to multiple specified outputs.
SendCoinsSendCoinsRequestSendCoinsResponselncli: sendcoins SendCoins executes a request to send coins to a particular address. Unlike SendMany, this RPC call only allows creating a single output at a time. If neither target_conf, or sat_per_byte are set, then the internal wallet will consult its fee model to determine a fee for the default confirmation target.
ListUnspentListUnspentRequestListUnspentResponselncli: listunspent ListUnspent returns a list of all utxos spendable by the wallet with a number of confirmations between the specified minimum and maximum.
SubscribeTransactionsGetTransactionsRequestTransaction streamSubscribeTransactions creates a uni-directional stream from the server to the client in which any newly discovered transactions relevant to the wallet are sent over.
SendManySendManyRequestSendManyResponselncli: sendmany SendMany handles a request for a transaction that creates multiple specified outputs in parallel. If neither target_conf, or sat_per_byte are set, then the internal wallet will consult its fee model to determine a fee for the default confirmation target.
NewAddressNewAddressRequestNewAddressResponselncli: newaddress NewAddress creates a new address under control of the local wallet.
SignMessageSignMessageRequestSignMessageResponselncli: signmessage SignMessage signs a message with this node's private key. The returned signature string is zbase32 encoded and pubkey recoverable, meaning that only the message digest and signature are needed for verification.
VerifyMessageVerifyMessageRequestVerifyMessageResponselncli: verifymessage VerifyMessage verifies a signature over a msg. The signature must be zbase32 encoded and signed by an active node in the resident node's channel database. In addition to returning the validity of the signature, VerifyMessage also returns the recovered pubkey from the signature.
ConnectPeerConnectPeerRequestConnectPeerResponselncli: connect ConnectPeer attempts to establish a connection to a remote peer. This is at the networking level, and is used for communication between nodes. This is distinct from establishing a channel with a peer.
DisconnectPeerDisconnectPeerRequestDisconnectPeerResponselncli: disconnect DisconnectPeer attempts to disconnect one peer from another identified by a given pubKey. In the case that we currently have a pending or active channel with the target peer, then this action will be not be allowed.
ListPeersListPeersRequestListPeersResponselncli: listpeers ListPeers returns a verbose listing of all currently active peers.
GetInfoGetInfoRequestGetInfoResponselncli: getinfo GetInfo returns general information concerning the lightning node including it's identity pubkey, alias, the chains it is connected to, and information concerning the number of open+pending channels.
PendingChannelsPendingChannelsRequestPendingChannelsResponselncli: pendingchannels PendingChannels returns a list of all the channels that are currently considered "pending". A channel is pending if it has finished the funding workflow and is waiting for confirmations for the funding txn, or is in the process of closure, either initiated cooperatively or non-cooperatively.
ListChannelsListChannelsRequestListChannelsResponselncli: listchannels ListChannels returns a description of all the open channels that this node is a participant in.
SubscribeChannelEventsChannelEventSubscriptionChannelEventUpdate streamSubscribeChannelEvents creates a uni-directional stream from the server to the client in which any updates relevant to the state of the channels are sent over. Events include new active channels, inactive channels, and closed channels.
ClosedChannelsClosedChannelsRequestClosedChannelsResponselncli: closedchannels ClosedChannels returns a description of all the closed channels that this node was a participant in.
OpenChannelSyncOpenChannelRequestChannelPointOpenChannelSync is a synchronous version of the OpenChannel RPC call. This call is meant to be consumed by clients to the REST proxy. As with all other sync calls, all byte slices are intended to be populated as hex encoded strings.
OpenChannelOpenChannelRequestOpenStatusUpdate streamlncli: openchannel OpenChannel attempts to open a singly funded channel specified in the request to a remote peer. Users are able to specify a target number of blocks that the funding transaction should be confirmed in, or a manual fee rate to us for the funding transaction. If neither are specified, then a lax block confirmation target is used.
CloseChannelCloseChannelRequestCloseStatusUpdate streamlncli: closechannel CloseChannel attempts to close an active channel identified by its channel outpoint (ChannelPoint). The actions of this method can additionally be augmented to attempt a force close after a timeout period in the case of an inactive peer. If a non-force close (cooperative closure) is requested, then the user can specify either a target number of blocks until the closure transaction is confirmed, or a manual fee rate. If neither are specified, then a default lax, block confirmation target is used.
AbandonChannelAbandonChannelRequestAbandonChannelResponselncli: abandonchannel AbandonChannel removes all channel state from the database except for a close summary. This method can be used to get rid of permanently unusable channels due to bugs fixed in newer versions of lnd. Only available when in debug builds of lnd.
SendPaymentSendRequest streamSendResponse streamlncli: sendpayment SendPayment dispatches a bi-directional streaming RPC for sending payments through the Lightning Network. A single RPC invocation creates a persistent bi-directional stream allowing clients to rapidly send payments through the Lightning Network with a single persistent connection.
SendPaymentSyncSendRequestSendResponseSendPaymentSync is the synchronous non-streaming version of SendPayment. This RPC is intended to be consumed by clients of the REST proxy. Additionally, this RPC expects the destination's public key and the payment hash (if any) to be encoded as hex strings.
SendToRouteSendToRouteRequest streamSendResponse streamlncli: sendtoroute SendToRoute is a bi-directional streaming RPC for sending payment through the Lightning Network. This method differs from SendPayment in that it allows users to specify a full route manually. This can be used for things like rebalancing, and atomic swaps.
SendToRouteSyncSendToRouteRequestSendResponseSendToRouteSync is a synchronous version of SendToRoute. It Will block until the payment either fails or succeeds.
AddInvoiceInvoiceAddInvoiceResponselncli: addinvoice AddInvoice attempts to add a new invoice to the invoice database. Any duplicated invoices are rejected, therefore all invoices must have a unique payment preimage.
ListInvoicesListInvoiceRequestListInvoiceResponselncli: listinvoices ListInvoices returns a list of all the invoices currently stored within the database. Any active debug invoices are ignored. It has full support for paginated responses, allowing users to query for specific invoices through their add_index. This can be done by using either the first_index_offset or last_index_offset fields included in the response as the index_offset of the next request. By default, the first 100 invoices created will be returned. Backwards pagination is also supported through the Reversed flag.
LookupInvoicePaymentHashInvoicelncli: lookupinvoice LookupInvoice attempts to look up an invoice according to its payment hash. The passed payment hash must be exactly 32 bytes, if not, an error is returned.
SubscribeInvoicesInvoiceSubscriptionInvoice streamSubscribeInvoices returns a uni-directional stream (server -> client) for notifying the client of newly added/settled invoices. The caller can optionally specify the add_index and/or the settle_index. If the add_index is specified, then we'll first start by sending add invoice events for all invoices with an add_index greater than the specified value. If the settle_index is specified, the next, we'll send out all settle events for invoices with a settle_index greater than the specified value. One or both of these fields can be set. If no fields are set, then we'll only send out the latest add/settle events.
DecodePayReqPayReqStringPayReqlncli: decodepayreq DecodePayReq takes an encoded payment request string and attempts to decode it, returning a full description of the conditions encoded within the payment request.
ListPaymentsListPaymentsRequestListPaymentsResponselncli: listpayments ListPayments returns a list of all outgoing payments.
DeleteAllPaymentsDeleteAllPaymentsRequestDeleteAllPaymentsResponseDeleteAllPayments deletes all outgoing payments from DB.
DescribeGraphChannelGraphRequestChannelGraphlncli: describegraph DescribeGraph returns a description of the latest graph state from the point of view of the node. The graph information is partitioned into two components: all the nodes/vertexes, and all the edges that connect the vertexes themselves. As this is a directed graph, the edges also contain the node directional specific routing policy which includes: the time lock delta, fee information, etc.
GetChanInfoChanInfoRequestChannelEdgelncli: getchaninfo GetChanInfo returns the latest authenticated network announcement for the given channel identified by its channel ID: an 8-byte integer which uniquely identifies the location of transaction's funding output within the blockchain.
GetNodeInfoNodeInfoRequestNodeInfolncli: getnodeinfo GetNodeInfo returns the latest advertised, aggregated, and authenticated channel information for the specified node identified by its public key.
QueryRoutesQueryRoutesRequestQueryRoutesResponselncli: queryroutes QueryRoutes attempts to query the daemon's Channel Router for a possible route to a target destination capable of carrying a specific amount of satoshis. The returned route contains the full details required to craft and send an HTLC, also including the necessary information that should be present within the Sphinx packet encapsulated within the HTLC.
GetNetworkInfoNetworkInfoRequestNetworkInfolncli: getnetworkinfo GetNetworkInfo returns some basic stats about the known channel graph from the point of view of the node.
StopDaemonStopRequestStopResponselncli: stop StopDaemon will send a shutdown request to the interrupt handler, triggering a graceful shutdown of the daemon.
SubscribeChannelGraphGraphTopologySubscriptionGraphTopologyUpdate streamSubscribeChannelGraph launches a streaming RPC that allows the caller to receive notifications upon any changes to the channel graph topology from the point of view of the responding node. Events notified include: new nodes coming online, nodes updating their authenticated attributes, new channels being advertised, updates in the routing policy for a directional channel edge, and when channels are closed on-chain.
DebugLevelDebugLevelRequestDebugLevelResponselncli: debuglevel DebugLevel allows a caller to programmatically set the logging verbosity of lnd. The logging can be targeted according to a coarse daemon-wide logging level, or in a granular fashion to specify the logging for a target sub-system.
FeeReportFeeReportRequestFeeReportResponselncli: feereport FeeReport allows the caller to obtain a report detailing the current fee schedule enforced by the node globally for each channel.
UpdateChannelPolicyPolicyUpdateRequestPolicyUpdateResponselncli: updatechanpolicy UpdateChannelPolicy allows the caller to update the fee schedule and channel policies for all channels globally, or a particular channel.
ForwardingHistoryForwardingHistoryRequestForwardingHistoryResponselncli: fwdinghistory ForwardingHistory allows the caller to query the htlcswitch for a record of all HTLCs forwarded within the target time range, and integer offset within that time range. If no time-range is specified, then the first chunk of the past 24 hrs of forwarding history are returned.

A list of forwarding events are returned. The size of each forwarding event is 40 bytes, and the max message size able to be returned in gRPC is 4 MiB. As a result each message can only contain 50k entries. Each response has the index offset of the last entry. The index offset can be provided to the request to allow the caller to skip a series of records. | | ExportChannelBackup | ExportChannelBackupRequest | ChannelBackup | lncli: exportchanbackup ExportChannelBackup attempts to return an encrypted static channel backup for the target channel identified by it channel point. The backup is encrypted with a key generated from the aezeed seed of the user. The returned backup can either be restored using the RestoreChannelBackup method once lnd is running, or via the InitWallet and UnlockWallet methods from the WalletUnlocker service. | | ExportAllChannelBackups | ChanBackupExportRequest | ChanBackupSnapshot | ExportAllChannelBackups returns static channel backups for all existing channels known to lnd. A set of regular singular static channel backups for each channel are returned. Additionally, a multi-channel backup is returned as well, which contains a single encrypted blob containing the backups of each channel. | | VerifyChanBackup | ChanBackupSnapshot | VerifyChanBackupResponse | VerifyChanBackup allows a caller to verify the integrity of a channel backup snapshot. This method will accept either a packed Single or a packed Multi. Specifying both will result in an error. | | RestoreChannelBackups | RestoreChanBackupRequest | RestoreBackupResponse | lncli: restorechanbackup RestoreChannelBackups accepts a set of singular channel backups, or a single encrypted multi-chan backup and attempts to recover any funds remaining within the channel. If we are able to unpack the backup, then the new channel will be shown under listchannels, as well as pending channels. | | SubscribeChannelBackups | ChannelBackupSubscription | ChanBackupSnapshot stream | SubscribeChannelBackups allows a client to sub-subscribe to the most up to date information concerning the state of all channel backups. Each time a new channel is added, we return the new set of channels, along with a multi-chan backup containing the backup info for all channels. Each time a channel is closed, we send a new update, which contains new new chan back ups, but the updated set of encrypted multi-chan backups with the closed channel(s) removed. |

WalletUnlocker

The WalletUnlocker service is used to set up a wallet password for lnd at first startup, and unlock a previously set up wallet.

Method NameRequest TypeResponse TypeDescription
GenSeedGenSeedRequestGenSeedResponseGenSeed is the first method that should be used to instantiate a new lnd instance. This method allows a caller to generate a new aezeed cipher seed given an optional passphrase. If provided, the passphrase will be necessary to decrypt the cipherseed to expose the internal wallet seed.

Once the cipherseed is obtained and verified by the user, the InitWallet method should be used to commit the newly generated seed, and create the wallet. | | InitWallet | InitWalletRequest | InitWalletResponse | InitWallet is used when lnd is starting up for the first time to fully initialize the daemon and its internal wallet. At the very least a wallet password must be provided. This will be used to encrypt sensitive material on disk.

In the case of a recovery scenario, the user can also specify their aezeed mnemonic and passphrase. If set, then the daemon will use this prior state to initialize its internal wallet.

Alternatively, this can be used along with the GenSeed RPC to obtain a seed, then present it to the user. Once it has been verified by the user, the seed can be fed into this RPC in order to commit the new wallet. | | UnlockWallet | UnlockWalletRequest | UnlockWalletResponse | lncli: unlock UnlockWallet is used at startup of lnd to provide a password to unlock the wallet database. | | ChangePassword | ChangePasswordRequest | ChangePasswordResponse | lncli: changepassword ChangePassword changes the password of the encrypted wallet. This will automatically unlock the wallet database if successful. |

Top

wtclientrpc/wtclient.proto

AddTowerRequest

FieldTypeLabelDescription
pubkeybytesThe identifying public key of the watchtower to add.
addressstringA network address the watchtower is reachable over.

AddTowerResponse

GetTowerInfoRequest

FieldTypeLabelDescription
pubkeybytesThe identifying public key of the watchtower to retrieve information for.
include_sessionsboolWhether we should include sessions with the watchtower in the response.

ListTowersRequest

FieldTypeLabelDescription
include_sessionsboolWhether we should include sessions with the watchtower in the response.

ListTowersResponse

FieldTypeLabelDescription
towersTowerrepeatedThe list of watchtowers available for new backups.

PolicyRequest

PolicyResponse

FieldTypeLabelDescription
max_updatesuint32The maximum number of updates each session we negotiate with watchtowers should allow.
sweep_sat_per_byteuint32The fee rate, in satoshis per vbyte, that will be used by watchtowers for justice transactions in response to channel breaches.

RemoveTowerRequest

FieldTypeLabelDescription
pubkeybytesThe identifying public key of the watchtower to remove.
addressstringIf set, then the record for this address will be removed, indicating that is is stale. Otherwise, the watchtower will no longer be used for future session negotiations and backups.

RemoveTowerResponse

StatsRequest

StatsResponse

FieldTypeLabelDescription
num_backupsuint32The total number of backups made to all active and exhausted watchtower sessions.
num_pending_backupsuint32The total number of backups that are pending to be acknowledged by all active and exhausted watchtower sessions.
num_failed_backupsuint32The total number of backups that all active and exhausted watchtower sessions have failed to acknowledge.
num_sessions_acquireduint32The total number of new sessions made to watchtowers.
num_sessions_exhausteduint32The total number of watchtower sessions that have been exhausted.

Tower

FieldTypeLabelDescription
pubkeybytesThe identifying public key of the watchtower.
addressesstringrepeatedThe list of addresses the watchtower is reachable over.
active_session_candidateboolWhether the watchtower is currently a candidate for new sessions.
num_sessionsuint32The number of sessions that have been negotiated with the watchtower.
sessionsTowerSessionrepeatedThe list of sessions that have been negotiated with the watchtower.

TowerSession

FieldTypeLabelDescription
num_backupsuint32The total number of successful backups that have been made to the watchtower session.
num_pending_backupsuint32The total number of backups in the session that are currently pending to be acknowledged by the watchtower.
max_backupsuint32The maximum number of backups allowed by the watchtower session.
sweep_sat_per_byteuint32The fee rate, in satoshis per vbyte, that will be used by the watchtower for the justice transaction in the event of a channel breach.

WatchtowerClient

Method NameRequest TypeResponse TypeDescription
AddTowerAddTowerRequestAddTowerResponseAddTower adds a new watchtower reachable at the given address and considers it for new sessions. If the watchtower already exists, then any new addresses included will be considered when dialing it for session negotiations and backups.
RemoveTowerRemoveTowerRequestRemoveTowerResponseRemoveTower removes a watchtower from being considered for future session negotiations and from being used for any subsequent backups until it's added again. If an address is provided, then this RPC only serves as a way of removing the address from the watchtower instead.
ListTowersListTowersRequestListTowersResponseListTowers returns the list of watchtowers registered with the client.
GetTowerInfoGetTowerInfoRequestTowerGetTowerInfo retrieves information for a registered watchtower.
StatsStatsRequestStatsResponseStats returns the in-memory statistics of the client since startup.
PolicyPolicyRequestPolicyResponsePolicy returns the active watchtower client policy configuration.

Top

routerrpc/router.proto

ChannelUpdate

FieldTypeLabelDescription
signaturebytesThe signature that validates the announced data and proves the ownership of node id.
chain_hashbytesThe target chain that this channel was opened within. This value should be the genesis hash of the target chain. Along with the short channel ID, this uniquely identifies the channel globally in a blockchain.
chan_iduint64The unique description of the funding transaction.
timestampuint32A timestamp that allows ordering in the case of multiple announcements. We should ignore the message if timestamp is not greater than the last-received.
message_flagsuint32The bitfield that describes whether optional fields are present in this update. Currently, the least-significant bit must be set to 1 if the optional field MaxHtlc is present.
channel_flagsuint32The bitfield that describes additional meta-data concerning how the update is to be interpreted. Currently, the least-significant bit must be set to 0 if the creating node corresponds to the first node in the previously sent channel announcement and 1 otherwise. If the second bit is set, then the channel is set to be disabled.
time_lock_deltauint32The minimum number of blocks this node requires to be added to the expiry of HTLCs. This is a security parameter determined by the node operator. This value represents the required gap between the time locks of the incoming and outgoing HTLC's set to this node.
htlc_minimum_msatuint64The minimum HTLC value which will be accepted.
base_feeuint32The base fee that must be used for incoming HTLC's to this particular channel. This value will be tacked onto the required for a payment independent of the size of the payment.
fee_rateuint32The fee rate that will be charged per millionth of a satoshi.
htlc_maximum_msatuint64The maximum HTLC value which will be accepted.
extra_opaque_databytesThe set of data that was appended to this message, some of which we may not actually know how to iterate or parse. By holding onto this data, we ensure that we're able to properly validate the set of signatures that cover these new fields, and ensure we're able to make upgrades to the network in a forwards compatible manner.

Failure

FieldTypeLabelDescription
codeFailure.FailureCodeFailure code as defined in the Lightning spec
channel_updateChannelUpdateAn optional channel update message.
htlc_msatuint64A failure type-dependent htlc value.
onion_sha_256bytesThe sha256 sum of the onion payload.
cltv_expiryuint32A failure type-dependent cltv expiry value.
flagsuint32A failure type-dependent flags value.
failure_source_indexuint32The position in the path of the intermediate or final node that generated the failure message. Position zero is the sender node.

NodeHistory

NodeHistory contains the mission control state for a particular node.

FieldTypeLabelDescription
pubkeybytesNode pubkey
last_fail_timeint64Time stamp of last failure. Set to zero if no failure happened yet.
other_success_probfloatEstimation of success probability of forwarding towards peers of this node for which no specific history is available.

PairHistory

PairHistory contains the mission control state for a particular node pair.

FieldTypeLabelDescription
node_frombytesThe source node pubkey of the pair.
node_tobytesThe destination node pubkey of the pair.
timestampint64Time stamp of last result.
min_penalize_amt_satint64Minimum penalization amount (only applies to failed attempts).
success_probfloatEstimation of success probability for this pair.
last_attempt_successfulboolWhether the last payment attempt through this pair was successful.

PaymentStatus

FieldTypeLabelDescription
statePaymentStateCurrent state the payment is in.
preimagebytesThe pre-image of the payment when state is SUCCEEDED.
routelnrpc.RouteThe taken route when state is SUCCEEDED.

QueryMissionControlRequest

QueryMissionControlResponse

QueryMissionControlResponse contains mission control state.

FieldTypeLabelDescription
nodesNodeHistoryrepeatedNode-level mission control state.
pairsPairHistoryrepeatedNode pair-level mission control state.

ResetMissionControlRequest

ResetMissionControlResponse

RouteFeeRequest

FieldTypeLabelDescription
destbytesThe destination once wishes to obtain a routing fee quote to.
amt_satint64The amount one wishes to send to the target destination.

RouteFeeResponse

FieldTypeLabelDescription
routing_fee_msatint64A lower bound of the estimated fee to the target destination within the network, expressed in milli-satoshis.
time_lock_delayint64An estimate of the worst case time delay that can occur. Note that callers will still need to factor in the final CLTV delta of the last hop into this value.

SendPaymentRequest

FieldTypeLabelDescription
destbytesThe identity pubkey of the payment recipient
amtint64Number of satoshis to send.
payment_hashbytesThe hash to use within the payment's HTLC
final_cltv_deltaint32The CLTV delta from the current height that should be used to set the timelock for the final hop.
payment_requeststringA bare-bones invoice for a payment within the Lightning Network. With the details of the invoice, the sender has all the data necessary to send a payment to the recipient. The amount in the payment request may be zero. In that case it is required to set the amt field as well. If no payment request is specified, the following fields are required: dest, amt and payment_hash.
timeout_secondsint32An upper limit on the amount of time we should spend when attempting to fulfill the payment. This is expressed in seconds. If we cannot make a successful payment within this time frame, an error will be returned. This field must be non-zero.
fee_limit_satint64The maximum number of satoshis that will be paid as a fee of the payment. If this field is left to the default value of 0, only zero-fee routes will be considered. This usually means single hop routes connecting directly to the destination. To send the payment without a fee limit, use max int here.
outgoing_chan_iduint64The channel id of the channel that must be taken to the first hop. If zero, any channel may be used.
cltv_limitint32An optional maximum total time lock for the route. If zero, there is no maximum enforced.
route_hintslnrpc.RouteHintrepeatedOptional route hints to reach the destination through private channels.
dest_tlvSendPaymentRequest.DestTlvEntryrepeatedAn optional field that can be used to pass an arbitrary set of TLV records to a peer which understands the new records. This can be used to pass application specific data during the payment attempt.

SendPaymentRequest.DestTlvEntry

FieldTypeLabelDescription
keyuint64
valuebytes

SendToRouteRequest

FieldTypeLabelDescription
payment_hashbytesThe payment hash to use for the HTLC.
routelnrpc.RouteRoute that should be used to attempt to complete the payment.

SendToRouteResponse

FieldTypeLabelDescription
preimagebytesThe preimage obtained by making the payment.
failureFailureThe failure message in case the payment failed.

TrackPaymentRequest

FieldTypeLabelDescription
payment_hashbytesThe hash of the payment to look up.

Failure.FailureCode

NameNumberDescription
RESERVED0The numbers assigned in this enumeration match the failure codes as defined in BOLT #4. Because protobuf 3 requires enums to start with 0, a RESERVED value is added.
INCORRECT_OR_UNKNOWN_PAYMENT_DETAILS1
INCORRECT_PAYMENT_AMOUNT2
FINAL_INCORRECT_CLTV_EXPIRY3
FINAL_INCORRECT_HTLC_AMOUNT4
FINAL_EXPIRY_TOO_SOON5
INVALID_REALM6
EXPIRY_TOO_SOON7
INVALID_ONION_VERSION8
INVALID_ONION_HMAC9
INVALID_ONION_KEY10
AMOUNT_BELOW_MINIMUM11
FEE_INSUFFICIENT12
INCORRECT_CLTV_EXPIRY13
CHANNEL_DISABLED14
TEMPORARY_CHANNEL_FAILURE15
REQUIRED_NODE_FEATURE_MISSING16
REQUIRED_CHANNEL_FEATURE_MISSING17
UNKNOWN_NEXT_PEER18
TEMPORARY_NODE_FAILURE19
PERMANENT_NODE_FAILURE20
PERMANENT_CHANNEL_FAILURE21
UNKNOWN_FAILURE998The error source is known, but the failure itself couldn't be decoded.
UNREADABLE_FAILURE999An unreadable failure result is returned if the received failure message cannot be decrypted. In that case the error source is unknown.

PaymentState

NameNumberDescription
IN_FLIGHT0Payment is still in flight.
SUCCEEDED1Payment completed successfully.
FAILED_TIMEOUT2There are more routes to try, but the payment timeout was exceeded.
FAILED_NO_ROUTE3All possible routes were tried and failed permanently. Or were no routes to the destination at all.
FAILED_ERROR4A non-recoverable error has occured.
FAILED_INCORRECT_PAYMENT_DETAILS5Payment details incorrect (unknown hash, invalid amt or invalid final cltv delta)

Router

Method NameRequest TypeResponse TypeDescription
SendPaymentSendPaymentRequestPaymentStatus streamSendPayment attempts to route a payment described by the passed PaymentRequest to the final destination. The call returns a stream of payment status updates.
TrackPaymentTrackPaymentRequestPaymentStatus streamTrackPayment returns an update stream for the payment identified by the payment hash.
EstimateRouteFeeRouteFeeRequestRouteFeeResponseEstimateRouteFee allows callers to obtain a lower bound w.r.t how much it may cost to send an HTLC to the target end destination.
SendToRouteSendToRouteRequestSendToRouteResponseSendToRoute attempts to make a payment via the specified route. This method differs from SendPayment in that it allows users to specify a full route manually. This can be used for things like rebalancing, and atomic swaps.
ResetMissionControlResetMissionControlRequestResetMissionControlResponseResetMissionControl clears all mission control state and starts with a clean slate.
QueryMissionControlQueryMissionControlRequestQueryMissionControlResponseQueryMissionControl exposes the internal mission control state to callers. It is a development feature.

Top

watchtowerrpc/watchtower.proto

GetInfoRequest

GetInfoResponse

FieldTypeLabelDescription
pubkeybytesThe public key of the watchtower.
listenersstringrepeatedThe listening addresses of the watchtower.
urisstringrepeatedThe URIs of the watchtower.

Watchtower

Method NameRequest TypeResponse TypeDescription
GetInfoGetInfoRequestGetInfoResponselncli: tower info GetInfo returns general information concerning the companion watchtower including it's public key and URIs where the server is currently listening for clients.

Top

signrpc/signer.proto

InputScript

FieldTypeLabelDescription
witnessbytesrepeatedThe serializes witness stack for the specified input.
sig_scriptbytesThe optional sig script for the specified witness that will only be set if the input specified is a nested p2sh witness program.

InputScriptResp

FieldTypeLabelDescription
input_scriptsInputScriptrepeatedThe set of fully valid input scripts requested.

KeyDescriptor

FieldTypeLabelDescription
raw_key_bytesbytesThe raw bytes of the key being identified. Either this or the KeyLocator must be specified.
key_locKeyLocatorThe key locator that identifies which key to use for signing. Either this or the raw bytes of the target key must be specified.

KeyLocator

FieldTypeLabelDescription
key_familyint32The family of key being identified.
key_indexint32The precise index of the key being identified.

SignDescriptor

FieldTypeLabelDescription
key_descKeyDescriptorA descriptor that precisely describes which key to use for signing. This may provide the raw public key directly, or require the Signer to re-derive the key according to the populated derivation path.
single_tweakbytesA scalar value that will be added to the private key corresponding to the above public key to obtain the private key to be used to sign this input. This value is typically derived via the following computation:

derivedKey = privkey + sha256(perCommitmentPoint || pubKey) mod N | | double_tweak | bytes | | A private key that will be used in combination with its corresponding private key to derive the private key that is to be used to sign the target input. Within the Lightning protocol, this value is typically the commitment secret from a previously revoked commitment transaction. This value is in combination with two hash values, and the original private key to derive the private key to be used when signing.

k = (privKeysha256(pubKey || tweakPub) + tweakPrivsha256(tweakPub || pubKey)) mod N | | witness_script | bytes | | The full script required to properly redeem the output. This field will only be populated if a p2wsh or a p2sh output is being signed. | | output | TxOut | | A description of the output being spent. The value and script MUST be provided. | | sighash | uint32 | | The target sighash type that should be used when generating the final sighash, and signature. | | input_index | int32 | | The target input within the transaction that should be signed. |

SignReq

FieldTypeLabelDescription
raw_tx_bytesbytesThe raw bytes of the transaction to be signed.
sign_descsSignDescriptorrepeatedA set of sign descriptors, for each input to be signed.

SignResp

FieldTypeLabelDescription
raw_sigsbytesrepeatedA set of signatures realized in a fixed 64-byte format ordered in ascending input order.

TxOut

FieldTypeLabelDescription
valueint64The value of the output being spent.
pk_scriptbytesThe script of the output being spent.

Signer

Method NameRequest TypeResponse TypeDescription
SignOutputRawSignReqSignRespSignOutputRaw is a method that can be used to generated a signature for a set of inputs/outputs to a transaction. Each request specifies details concerning how the outputs should be signed, which keys they should be signed with, and also any optional tweaks. The return value is a fixed 64-byte signature (the same format as we use on the wire in Lightning).

If we are unable to sign using the specified keys, then an error will be returned. | | ComputeInputScript | SignReq | InputScriptResp | ComputeInputScript generates a complete InputIndex for the passed transaction with the signature as defined within the passed SignDescriptor. This method should be capable of generating the proper input script for both regular p2wkh output and p2wkh outputs nested within a regular p2sh output.

Note that when using this method to sign inputs belonging to the wallet, the only items of the SignDescriptor that need to be populated are pkScript in the TxOut field, the value in that same field, and finally the input index. |

Scalar Value Types

.proto TypeNotesC++ TypeJava TypePython Type
doubledoubledoublefloat
floatfloatfloatfloat
int32Uses variable-length encoding. Inefficient for encoding negative numbers – if your field is likely to have negative values, use sint32 instead.int32intint
int64Uses variable-length encoding. Inefficient for encoding negative numbers – if your field is likely to have negative values, use sint64 instead.int64longint/long
uint32Uses variable-length encoding.uint32intint/long
uint64Uses variable-length encoding.uint64longint/long
sint32Uses variable-length encoding. Signed int value. These more efficiently encode negative numbers than regular int32s.int32intint
sint64Uses variable-length encoding. Signed int value. These more efficiently encode negative numbers than regular int64s.int64longint/long
fixed32Always four bytes. More efficient than uint32 if values are often greater than 2^28.uint32intint
fixed64Always eight bytes. More efficient than uint64 if values are often greater than 2^56.uint64longint/long
sfixed32Always four bytes.int32intint
sfixed64Always eight bytes.int64longint/long
boolboolbooleanboolean
stringA string must always contain UTF-8 encoded or 7-bit ASCII text.stringStringstr/unicode
bytesMay contain any arbitrary sequence of bytes.stringByteStringstr

Protos File Tree


.
├── autopilotrpc
│   └── autopilot.proto
├── chainrpc
│   └── chainnotifier.proto
├── invoicesrpc
│   └── invoices.proto
├── routerrpc
│   └── router.proto
├── rpc.proto
├── signrpc
│   └── signer.proto
├── walletrpc
│   └── walletkit.proto
├── watchtowerrpc
│   └── watchtower.proto
└── wtclientrpc
    └── wtclient.proto

8 directories, 9 files

Protobuf sources

src:./chainrpc/chainnotifier.proto


syntax = "proto3";

package chainrpc;

message ConfRequest {
    /*
    The transaction hash for which we should request a confirmation notification
    for. If set to a hash of all zeros, then the confirmation notification will
    be requested for the script instead.
    */
    bytes txid = 1;

    /*
    An output script within a transaction with the hash above which will be used
    by light clients to match block filters. If the transaction hash is set to a
    hash of all zeros, then a confirmation notification will be requested for
    this script instead.
    */
    bytes script = 2;

    /*
    The number of desired confirmations the transaction/output script should
    reach before dispatching a confirmation notification.
    */
    uint32 num_confs = 3;

    /*
    The earliest height in the chain for which the transaction/output script
    could have been included in a block. This should in most cases be set to the
    broadcast height of the transaction/output script.
    */
    uint32 height_hint = 4;
}

message ConfDetails {
    // The raw bytes of the confirmed transaction.
    bytes raw_tx = 1;

    // The hash of the block in which the confirmed transaction was included in.
    bytes block_hash = 2;

    // The height of the block in which the confirmed transaction was included in.
    uint32 block_height = 3;

    // The index of the confirmed transaction within the transaction.
    uint32 tx_index = 4;
}

message Reorg {
    // TODO(wilmer): need to know how the client will use this first.
}

message ConfEvent {
    oneof event {
        /*
        An event that includes the confirmation details of the request
        (txid/ouput script).
        */
        ConfDetails conf = 1;

        /*
        An event send when the transaction of the request is reorged out of the
        chain.
        */
        Reorg reorg = 2;
    }
}

message Outpoint {
    // The hash of the transaction.
    bytes hash = 1;

    // The index of the output within the transaction.
    uint32 index = 2;
}

message SpendRequest {
    /*
    The outpoint for which we should request a spend notification for. If set to
    a zero outpoint, then the spend notification will be requested for the
    script instead.
    */
    Outpoint outpoint = 1;

    /*
    The output script for the outpoint above. This will be used by light clients
    to match block filters. If the outpoint is set to a zero outpoint, then a
    spend notification will be requested for this script instead.
    */
    bytes script = 2;

    /*
    The earliest height in the chain for which the outpoint/output script could
    have been spent. This should in most cases be set to the broadcast height of
    the outpoint/output script.
    */
    uint32 height_hint = 3;

    // TODO(wilmer): extend to support num confs on spending tx.
}

message SpendDetails {
    // The outpoint was that spent.
    Outpoint spending_outpoint = 1;

    // The raw bytes of the spending transaction.
    bytes raw_spending_tx = 2;

    // The hash of the spending transaction.
    bytes spending_tx_hash = 3;

    // The input of the spending transaction that fulfilled the spend request.
    uint32 spending_input_index = 4;

    // The height at which the spending transaction was included in a block.
    uint32 spending_height = 5;
}

message SpendEvent {
    oneof event {
        /*
        An event that includes the details of the spending transaction of the
        request (outpoint/output script).
        */
        SpendDetails spend = 1;

        /*
        An event sent when the spending transaction of the request was
        reorged out of the chain.
        */
        Reorg reorg = 2;
    }
}

message BlockEpoch {
    // The hash of the block.
    bytes hash = 1;

    // The height of the block.
    uint32 height = 2;
}

service ChainNotifier {
    /*
    RegisterConfirmationsNtfn is a synchronous response-streaming RPC that
    registers an intent for a client to be notified once a confirmation request
    has reached its required number of confirmations on-chain.

    A client can specify whether the confirmation request should be for a
    particular transaction by its hash or for an output script by specifying a
    zero hash.
    */
    rpc RegisterConfirmationsNtfn(ConfRequest) returns (stream ConfEvent);

    /*
    RegisterSpendNtfn is a synchronous response-streaming RPC that registers an
    intent for a client to be notification once a spend request has been spent
    by a transaction that has confirmed on-chain.

    A client can specify whether the spend request should be for a particular
    outpoint  or for an output script by specifying a zero outpoint.
    */
    rpc RegisterSpendNtfn(SpendRequest) returns (stream SpendEvent);

    /*
    RegisterBlockEpochNtfn is a synchronous response-streaming RPC that
    registers an intent for a client to be notified of blocks in the chain. The
    stream will return a hash and height tuple of a block for each new/stale
    block in the chain. It is the client's responsibility to determine whether
    the tuple returned is for a new or stale block in the chain.

    A client can also request a historical backlog of blocks from a particular
    point. This allows clients to be idempotent by ensuring that they do not
    missing processing a single block within the chain.
    */
    rpc RegisterBlockEpochNtfn(BlockEpoch) returns (stream BlockEpoch);
}

src:./walletrpc/walletkit.proto


syntax = "proto3";

import "rpc.proto";
import "signrpc/signer.proto";

package walletrpc;

option go_package = "github.com/lightningnetwork/lnd/lnrpc/walletrpc";

message KeyReq {
    /**
    Is the key finger print of the root pubkey that this request is targeting.
    This allows the WalletKit to possibly serve out keys for multiple HD chains
    via public derivation.
    */
    int32 key_finger_print = 1;

    /**
    The target key family to derive a key from. In other contexts, this is
    known as the "account".
    */
    int32 key_family = 2;
}

message AddrRequest{
    // No fields, as we always give out a p2wkh address.
}
message AddrResponse {
    /**
    The address encoded using a bech32 format.
    */
    string addr = 1;
}

message Transaction {
    /**
    The raw serialized transaction.
    */
    bytes tx_hex = 1;
}
message PublishResponse {
    /**
    If blank, then no error occurred and the transaction was successfully
    published. If not the empty string, then a string representation of the
    broadcast error.

    TODO(roasbeef): map to a proper enum type
    */
    string publish_error = 1;
}

message SendOutputsRequest {
    /**
    The number of satoshis per kilo weight that should be used when crafting
    this transaction.
    */
    int64 sat_per_kw = 1;

    /**
    A slice of the outputs that should be created in the transaction produced.
    */
    repeated signrpc.TxOut outputs = 2;
}
message SendOutputsResponse {
    /**
    The serialized transaction sent out on the network.
    */
    bytes raw_tx = 1;
}

message EstimateFeeRequest {
    /**
    The number of confirmations to shoot for when estimating the fee.
    */
    int32 conf_target = 1;
}
message EstimateFeeResponse {
    /**
    The amount of satoshis per kw that should be used in order to reach the
    confirmation target in the request.
    */
    int64 sat_per_kw = 1;
}

enum WitnessType {
    UNKNOWN_WITNESS = 0;

    /*
    A witness that allows us to spend the output of a commitment transaction
    after a relative lock-time lockout.
    */
    COMMITMENT_TIME_LOCK = 1;

    /*
    A witness that allows us to spend a settled no-delay output immediately on a
    counterparty's commitment transaction.
    */
    COMMITMENT_NO_DELAY = 2;

    /*
    A witness that allows us to sweep the settled output of a malicious
    counterparty's who broadcasts a revoked commitment transaction.
    */
    COMMITMENT_REVOKE = 3;

    /*
    A witness that allows us to sweep an HTLC which we offered to the remote
    party in the case that they broadcast a revoked commitment state.
    */
    HTLC_OFFERED_REVOKE = 4;

    /*
    A witness that allows us to sweep an HTLC output sent to us in the case that
    the remote party broadcasts a revoked commitment state.
    */
    HTLC_ACCEPTED_REVOKE = 5;

    /*
    A witness that allows us to sweep an HTLC output that we extended to a
    party, but was never fulfilled.  This HTLC output isn't directly on the
    commitment transaction, but is the result of a confirmed second-level HTLC
    transaction. As a result, we can only spend this after a CSV delay.
    */
    HTLC_OFFERED_TIMEOUT_SECOND_LEVEL = 6;

    /*
    A witness that allows us to sweep an HTLC output that was offered to us, and
    for which we have a payment preimage. This HTLC output isn't directly on our
    commitment transaction, but is the result of confirmed second-level HTLC
    transaction. As a result, we can only spend this after a CSV delay.
    */
    HTLC_ACCEPTED_SUCCESS_SECOND_LEVEL = 7;

    /*
    A witness that allows us to sweep an HTLC that we offered to the remote
    party which lies in the commitment transaction of the remote party. We can
    spend this output after the absolute CLTV timeout of the HTLC as passed.
    */
    HTLC_OFFERED_REMOTE_TIMEOUT = 8;

    /*
    A witness that allows us to sweep an HTLC that was offered to us by the
    remote party. We use this witness in the case that the remote party goes to
    chain, and we know the pre-image to the HTLC. We can sweep this without any
    additional timeout.
    */
    HTLC_ACCEPTED_REMOTE_SUCCESS = 9;

    /*
    A witness that allows us to sweep an HTLC from the remote party's commitment
    transaction in the case that the broadcast a revoked commitment, but then
    also immediately attempt to go to the second level to claim the HTLC.
    */
    HTLC_SECOND_LEVEL_REVOKE = 10;

    /*
    A witness type that allows us to spend a regular p2wkh output that's sent to
    an output which is under complete control of the backing wallet.
    */
    WITNESS_KEY_HASH = 11;

    /*
    A witness type that allows us to sweep an output that sends to a nested P2SH
    script that pays to a key solely under our control.
    */
    NESTED_WITNESS_KEY_HASH = 12;
}

message PendingSweep {
    // The outpoint of the output we're attempting to sweep.
    lnrpc.OutPoint outpoint = 1 [json_name = "outpoint"];

    // The witness type of the output we're attempting to sweep.
    WitnessType witness_type = 2 [json_name = "witness_type"];

    // The value of the output we're attempting to sweep.
    uint32 amount_sat = 3 [json_name = "amount_sat"];

    /*
    The fee rate we'll use to sweep the output. The fee rate is only determined
    once a sweeping transaction for the output is created, so it's possible for
    this to be 0 before this.
    */
    uint32 sat_per_byte = 4 [json_name = "sat_per_byte"];

    // The number of broadcast attempts we've made to sweep the output.
    uint32 broadcast_attempts = 5 [json_name = "broadcast_attempts"];

    /*
    The next height of the chain at which we'll attempt to broadcast the
    sweep transaction of the output.
    */
    uint32 next_broadcast_height = 6 [json_name = "next_broadcast_height"];
}

message PendingSweepsRequest {
}

message PendingSweepsResponse {
    /*
    The set of outputs currently being swept by lnd's central batching engine.
    */
    repeated PendingSweep pending_sweeps = 1 [json_name = "pending_sweeps"];
}

message BumpFeeRequest {
    // The input we're attempting to bump the fee of.
    lnrpc.OutPoint outpoint = 1 [json_name = "outpoint"];

    // The target number of blocks that the input should be spent within.
    uint32 target_conf = 2 [json_name = "target_conf"];

    /*
    The fee rate, expressed in sat/byte, that should be used to spend the input
    with.
    */
    uint32 sat_per_byte = 3 [json_name = "sat_per_byte"];
}

message BumpFeeResponse {
}

service WalletKit {
    /**
    DeriveNextKey attempts to derive the *next* key within the key family
    (account in BIP43) specified. This method should return the next external
    child within this branch.
    */
    rpc DeriveNextKey(KeyReq) returns (signrpc.KeyDescriptor);

    /**
    DeriveKey attempts to derive an arbitrary key specified by the passed
    KeyLocator. 
    */
    rpc DeriveKey(signrpc.KeyLocator) returns (signrpc.KeyDescriptor);

    /**
    NextAddr returns the next unused address within the wallet.
    */
    rpc NextAddr(AddrRequest) returns (AddrResponse);

    /**
    PublishTransaction attempts to publish the passed transaction to the
    network. Once this returns without an error, the wallet will continually
    attempt to re-broadcast the transaction on start up, until it enters the
    chain.
    */
    rpc PublishTransaction(Transaction) returns (PublishResponse);

    /**
    SendOutputs is similar to the existing sendmany call in Bitcoind, and
    allows the caller to create a transaction that sends to several outputs at
    once. This is ideal when wanting to batch create a set of transactions.
    */
    rpc SendOutputs(SendOutputsRequest) returns (SendOutputsResponse);

    /**
    EstimateFee attempts to query the internal fee estimator of the wallet to
    determine the fee (in sat/kw) to attach to a transaction in order to
    achieve the confirmation target.
    */
    rpc EstimateFee(EstimateFeeRequest) returns (EstimateFeeResponse);

    /*
    PendingSweeps returns lists of on-chain outputs that lnd is currently
    attempting to sweep within its central batching engine. Outputs with similar
    fee rates are batched together in order to sweep them within a single
    transaction.

    NOTE: Some of the fields within PendingSweepsRequest are not guaranteed to
    remain supported. This is an advanced API that depends on the internals of
    the UtxoSweeper, so things may change.
    */
    rpc PendingSweeps(PendingSweepsRequest) returns (PendingSweepsResponse);

    /*
    BumpFee bumps the fee of an arbitrary input within a transaction. This RPC
    takes a different approach than bitcoind's bumpfee command. lnd has a
    central batching engine in which inputs with similar fee rates are batched
    together to save on transaction fees. Due to this, we cannot rely on
    bumping the fee on a specific transaction, since transactions can change at
    any point with the addition of new inputs. The list of inputs that
    currently exist within lnd's central batching engine can be retrieved
    through the PendingSweeps RPC.

    When bumping the fee of an input that currently exists within lnd's central
    batching engine, a higher fee transaction will be created that replaces the
    lower fee transaction through the Replace-By-Fee (RBF) policy. If it

    This RPC also serves useful when wanting to perform a Child-Pays-For-Parent
    (CPFP), where the child transaction pays for its parent's fee. This can be
    done by specifying an outpoint within the low fee transaction that is under
    the control of the wallet.

    The fee preference can be expressed either as a specific fee rate or a delta
    of blocks in which the output should be swept on-chain within. If a fee
    preference is not explicitly specified, then an error is returned.

    Note that this RPC currently doesn't perform any validation checks on the
    fee preference being provided. For now, the responsibility of ensuring that
    the new fee preference is sufficient is delegated to the user.
    */
    rpc BumpFee(BumpFeeRequest) returns (BumpFeeResponse);
}

src:./autopilotrpc/autopilot.proto


syntax = "proto3";

package autopilotrpc;

option go_package = "github.com/lightningnetwork/lnd/lnrpc/autopilotrpc";

// Autopilot is a service that can be used to get information about the current
// state of the daemon's autopilot agent, and also supply it with information
// that can be used when deciding where to open channels.
service Autopilot {
    /**
    Status returns whether the daemon's autopilot agent is active.
    */
    rpc Status(StatusRequest) returns (StatusResponse);

    /**
    ModifyStatus is used to modify the status of the autopilot agent, like
    enabling or disabling it.
    */
    rpc ModifyStatus(ModifyStatusRequest) returns (ModifyStatusResponse);

    /**
    QueryScores queries all available autopilot heuristics, in addition to any
    active combination of these heruristics, for the scores they would give to
    the given nodes.
    */
    rpc QueryScores(QueryScoresRequest) returns (QueryScoresResponse);

    /**
    SetScores attempts to set the scores used by the running autopilot agent,
    if the external scoring heuristic is enabled.
    */
    rpc SetScores(SetScoresRequest) returns (SetScoresResponse);
}

message StatusRequest{
}

message StatusResponse{
    /// Indicates whether the autopilot is active or not.
    bool active = 1 [json_name = "active"];
}

message ModifyStatusRequest{
    /// Whether the autopilot agent should be enabled or not.
    bool enable = 1 [json_name = "enable"];
}

message ModifyStatusResponse {}

message QueryScoresRequest{
    repeated string pubkeys = 1 [json_name = "pubkeys"];

    /// If set, we will ignore the local channel state when calculating scores.
    bool ignore_local_state = 2 [json_name = "no_state"];
}

message QueryScoresResponse {
    message HeuristicResult {
        string heuristic = 1 [json_name = "heuristic"];
        map<string, double> scores= 2 [json_name = "scores"];
    }

    repeated HeuristicResult results = 1 [json_name = "results"];
}

message SetScoresRequest{
    /// The name of the heuristic to provide scores to.
    string heuristic = 1 [json_name = "heuristic"];

    /**
    A map from hex-encoded public keys to scores. Scores must be in the range
    [0.0, 1.0].
    */
    map<string, double> scores = 2 [json_name = "scores"];
}

message SetScoresResponse {}

src:./invoicesrpc/invoices.proto


syntax = "proto3";

import "google/api/annotations.proto";
import "rpc.proto";

package invoicesrpc;

option go_package = "github.com/lightningnetwork/lnd/lnrpc/invoicesrpc";

// Invoices is a service that can be used to create, accept, settle and cancel
// invoices.
service Invoices {
    /**
    SubscribeSingleInvoice returns a uni-directional stream (server -> client)
    to notify the client of state transitions of the specified invoice.
    Initially the current invoice state is always sent out.
    */
    rpc SubscribeSingleInvoice (SubscribeSingleInvoiceRequest) returns (stream lnrpc.Invoice);

    /**
    CancelInvoice cancels a currently open invoice. If the invoice is already 
    canceled, this call will succeed. If the invoice is already settled, it will
    fail.
    */
    rpc CancelInvoice(CancelInvoiceMsg) returns (CancelInvoiceResp);

    /**
    AddHoldInvoice creates a hold invoice. It ties the invoice to the hash
    supplied in the request.
    */
    rpc AddHoldInvoice(AddHoldInvoiceRequest) returns (AddHoldInvoiceResp);
 
    /**
    SettleInvoice settles an accepted invoice. If the invoice is already
    settled, this call will succeed.
    */
    rpc SettleInvoice(SettleInvoiceMsg) returns (SettleInvoiceResp);
}

message CancelInvoiceMsg {
    /// Hash corresponding to the (hold) invoice to cancel.
    bytes payment_hash = 1;
} 
message CancelInvoiceResp {}

message AddHoldInvoiceRequest {
    /**
    An optional memo to attach along with the invoice. Used for record keeping
    purposes for the invoice's creator, and will also be set in the description
    field of the encoded payment request if the description_hash field is not
    being used.
    */
    string memo = 1 [json_name = "memo"];

    /// The hash of the preimage
    bytes hash = 2 [json_name = "hash"];

    /// The value of this invoice in satoshis
    int64 value = 3 [json_name = "value"];

    /**
    Hash (SHA-256) of a description of the payment. Used if the description of
    payment (memo) is too long to naturally fit within the description field
    of an encoded payment request.
    */
    bytes description_hash = 4 [json_name = "description_hash"];

    /// Payment request expiry time in seconds. Default is 3600 (1 hour).
    int64 expiry = 5 [json_name = "expiry"];

    /// Fallback on-chain address.
    string fallback_addr = 6 [json_name = "fallback_addr"];

    /// Delta to use for the time-lock of the CLTV extended to the final hop.
    uint64 cltv_expiry = 7 [json_name = "cltv_expiry"];

    /**
    Route hints that can each be individually used to assist in reaching the
    invoice's destination.
    */
    repeated lnrpc.RouteHint route_hints = 8 [json_name = "route_hints"];

    /// Whether this invoice should include routing hints for private channels.
    bool private = 9 [json_name = "private"];
}

message AddHoldInvoiceResp {
    /**
    A bare-bones invoice for a payment within the Lightning Network.  With the
    details of the invoice, the sender has all the data necessary to send a
    payment to the recipient.
    */
    string payment_request = 1 [json_name = "payment_request"];
}

message SettleInvoiceMsg {
    /// Externally discovered pre-image that should be used to settle the hold invoice.
    bytes preimage = 1;
} 

message SettleInvoiceResp {}

message SubscribeSingleInvoiceRequest {
    reserved 1;

    /// Hash corresponding to the (hold) invoice to subscribe to.
    bytes r_hash = 2 [json_name = "r_hash"];
}

src:./rpc.proto


syntax = "proto3";

import "google/api/annotations.proto";

package lnrpc;

option go_package = "github.com/lightningnetwork/lnd/lnrpc";

/**
 * Comments in this file will be directly parsed into the API
 * Documentation as descriptions of the associated method, message, or field.
 * These descriptions should go right above the definition of the object, and
 * can be in either block or /// comment format. 
 * 
 * One edge case exists where a // comment followed by a /// comment in the
 * next line will cause the description not to show up in the documentation. In
 * that instance, simply separate the two comments with a blank line.
 * 
 * An RPC method can be matched to an lncli command by placing a line in the
 * beginning of the description in exactly the following format:
 * lncli: `methodname`
 * 
 * Failure to specify the exact name of the command will cause documentation
 * generation to fail.
 * 
 * More information on how exactly the gRPC documentation is generated from
 * this proto file can be found here:
 * https://github.com/lightninglabs/lightning-api
 */

// The WalletUnlocker service is used to set up a wallet password for
// lnd at first startup, and unlock a previously set up wallet.
service WalletUnlocker {
    /**
    GenSeed is the first method that should be used to instantiate a new lnd
    instance. This method allows a caller to generate a new aezeed cipher seed
    given an optional passphrase. If provided, the passphrase will be necessary
    to decrypt the cipherseed to expose the internal wallet seed.

    Once the cipherseed is obtained and verified by the user, the InitWallet
    method should be used to commit the newly generated seed, and create the
    wallet.
    */
    rpc GenSeed(GenSeedRequest) returns (GenSeedResponse) {
        option (google.api.http) = {
            get: "/v1/genseed"
        };
    }

    /** 
    InitWallet is used when lnd is starting up for the first time to fully
    initialize the daemon and its internal wallet. At the very least a wallet
    password must be provided. This will be used to encrypt sensitive material
    on disk.

    In the case of a recovery scenario, the user can also specify their aezeed
    mnemonic and passphrase. If set, then the daemon will use this prior state
    to initialize its internal wallet.

    Alternatively, this can be used along with the GenSeed RPC to obtain a
    seed, then present it to the user. Once it has been verified by the user,
    the seed can be fed into this RPC in order to commit the new wallet.
    */
    rpc InitWallet(InitWalletRequest) returns (InitWalletResponse) {
        option (google.api.http) = {
            post: "/v1/initwallet"
            body: "*"
        };
    }

    /** lncli: `unlock`
    UnlockWallet is used at startup of lnd to provide a password to unlock
    the wallet database.
    */
    rpc UnlockWallet(UnlockWalletRequest) returns (UnlockWalletResponse) {
        option (google.api.http) = {
            post: "/v1/unlockwallet"
            body: "*"
        };
    }

    /** lncli: `changepassword`
    ChangePassword changes the password of the encrypted wallet. This will
    automatically unlock the wallet database if successful.
    */
    rpc ChangePassword (ChangePasswordRequest) returns (ChangePasswordResponse) {
        option (google.api.http) = {
            post: "/v1/changepassword"
            body: "*"
        };
    }
}

message GenSeedRequest {
    /**
    aezeed_passphrase is an optional user provided passphrase that will be used
    to encrypt the generated aezeed cipher seed.
    */
    bytes aezeed_passphrase = 1;

    /**
    seed_entropy is an optional 16-bytes generated via CSPRNG. If not
    specified, then a fresh set of randomness will be used to create the seed.
    */
    bytes seed_entropy = 2;
}
message GenSeedResponse {
    /**
    cipher_seed_mnemonic is a 24-word mnemonic that encodes a prior aezeed
    cipher seed obtained by the user. This field is optional, as if not
    provided, then the daemon will generate a new cipher seed for the user.
    Otherwise, then the daemon will attempt to recover the wallet state linked
    to this cipher seed.
    */
    repeated string cipher_seed_mnemonic = 1;

    /**
    enciphered_seed are the raw aezeed cipher seed bytes. This is the raw
    cipher text before run through our mnemonic encoding scheme.
    */
    bytes enciphered_seed = 2;
}

message InitWalletRequest {
    /**
    wallet_password is the passphrase that should be used to encrypt the
    wallet. This MUST be at least 8 chars in length. After creation, this
    password is required to unlock the daemon.
    */
    bytes wallet_password = 1;

    /**
    cipher_seed_mnemonic is a 24-word mnemonic that encodes a prior aezeed
    cipher seed obtained by the user. This may have been generated by the
    GenSeed method, or be an existing seed.
    */
    repeated string cipher_seed_mnemonic = 2;

    /**
    aezeed_passphrase is an optional user provided passphrase that will be used
    to encrypt the generated aezeed cipher seed.
    */
    bytes aezeed_passphrase = 3;

    /**
    recovery_window is an optional argument specifying the address lookahead
    when restoring a wallet seed. The recovery window applies to each
    individual branch of the BIP44 derivation paths. Supplying a recovery
    window of zero indicates that no addresses should be recovered, such after
    the first initialization of the wallet.
    */
    int32 recovery_window = 4;

    /**
    channel_backups is an optional argument that allows clients to recover the
    settled funds within a set of channels. This should be populated if the
    user was unable to close out all channels and sweep funds before partial or
    total data loss occurred. If specified, then after on-chain recovery of
    funds, lnd begin to carry out the data loss recovery protocol in order to
    recover the funds in each channel from a remote force closed transaction.
    */
    ChanBackupSnapshot channel_backups = 5;
}
message InitWalletResponse {
}

message UnlockWalletRequest {
    /**
    wallet_password should be the current valid passphrase for the daemon. This
    will be required to decrypt on-disk material that the daemon requires to
    function properly.
    */
    bytes wallet_password = 1;

    /**
    recovery_window is an optional argument specifying the address lookahead
    when restoring a wallet seed. The recovery window applies to each
    individual branch of the BIP44 derivation paths. Supplying a recovery
    window of zero indicates that no addresses should be recovered, such after
    the first initialization of the wallet.
    */
    int32 recovery_window = 2;

    /**
    channel_backups is an optional argument that allows clients to recover the
    settled funds within a set of channels. This should be populated if the
    user was unable to close out all channels and sweep funds before partial or
    total data loss occurred. If specified, then after on-chain recovery of
    funds, lnd begin to carry out the data loss recovery protocol in order to
    recover the funds in each channel from a remote force closed transaction.
    */
    ChanBackupSnapshot channel_backups = 3;
}
message UnlockWalletResponse {}

message ChangePasswordRequest {
    /**
    current_password should be the current valid passphrase used to unlock the
    daemon.
    */
    bytes current_password = 1;

    /**
    new_password should be the new passphrase that will be needed to unlock the
    daemon.
    */
    bytes new_password = 2;
}
message ChangePasswordResponse {}

service Lightning {
    /** lncli: `walletbalance`
    WalletBalance returns total unspent outputs(confirmed and unconfirmed), all
    confirmed unspent outputs and all unconfirmed unspent outputs under control
    of the wallet.
    */
    rpc WalletBalance (WalletBalanceRequest) returns (WalletBalanceResponse) {
        option (google.api.http) = {
            get: "/v1/balance/blockchain"
        };
    }

    /** lncli: `channelbalance`
    ChannelBalance returns the total funds available across all open channels
    in satoshis.
    */
    rpc ChannelBalance (ChannelBalanceRequest) returns (ChannelBalanceResponse) {
        option (google.api.http) = {
            get: "/v1/balance/channels"
        };
    }

    /** lncli: `listchaintxns`
    GetTransactions returns a list describing all the known transactions
    relevant to the wallet.
    */
    rpc GetTransactions (GetTransactionsRequest) returns (TransactionDetails) {
        option (google.api.http) = {
            get: "/v1/transactions"
        };
    }

    /** lncli: `estimatefee`
    EstimateFee asks the chain backend to estimate the fee rate and total fees
    for a transaction that pays to multiple specified outputs.
    */
    rpc EstimateFee (EstimateFeeRequest) returns (EstimateFeeResponse) {
        option (google.api.http) = {
            get: "/v1/transactions/fee"
        };
    }

    /** lncli: `sendcoins`
    SendCoins executes a request to send coins to a particular address. Unlike
    SendMany, this RPC call only allows creating a single output at a time. If
    neither target_conf, or sat_per_byte are set, then the internal wallet will
    consult its fee model to determine a fee for the default confirmation
    target.
    */
    rpc SendCoins (SendCoinsRequest) returns (SendCoinsResponse) {
        option (google.api.http) = {
            post: "/v1/transactions"
            body: "*"
        };
    }

    /** lncli: `listunspent`
    ListUnspent returns a list of all utxos spendable by the wallet with a
	number of confirmations between the specified minimum and maximum.
    */
    rpc ListUnspent (ListUnspentRequest) returns (ListUnspentResponse) {
        option (google.api.http) = {
            get: "/v1/utxos"
        };
    }

    /**
    SubscribeTransactions creates a uni-directional stream from the server to
    the client in which any newly discovered transactions relevant to the
    wallet are sent over.
    */
    rpc SubscribeTransactions (GetTransactionsRequest) returns (stream Transaction);

    /** lncli: `sendmany`
    SendMany handles a request for a transaction that creates multiple specified
    outputs in parallel. If neither target_conf, or sat_per_byte are set, then
    the internal wallet will consult its fee model to determine a fee for the
    default confirmation target.
    */
    rpc SendMany (SendManyRequest) returns (SendManyResponse);

    /** lncli: `newaddress`
    NewAddress creates a new address under control of the local wallet.
    */
    rpc NewAddress (NewAddressRequest) returns (NewAddressResponse) {
        option (google.api.http) = {
            get: "/v1/newaddress"
        };
    }

    /** lncli: `signmessage`
    SignMessage signs a message with this node's private key. The returned
    signature string is `zbase32` encoded and pubkey recoverable, meaning that
    only the message digest and signature are needed for verification.
    */
    rpc SignMessage (SignMessageRequest) returns (SignMessageResponse) {
        option (google.api.http) = {
            post: "/v1/signmessage"
            body: "*"
        };
    }

    /** lncli: `verifymessage`
    VerifyMessage verifies a signature over a msg. The signature must be
    zbase32 encoded and signed by an active node in the resident node's
    channel database. In addition to returning the validity of the signature,
    VerifyMessage also returns the recovered pubkey from the signature.
    */
    rpc VerifyMessage (VerifyMessageRequest) returns (VerifyMessageResponse) {
        option (google.api.http) = {
            post: "/v1/verifymessage"
            body: "*"
        };
    }

    /** lncli: `connect`
    ConnectPeer attempts to establish a connection to a remote peer. This is at
    the networking level, and is used for communication between nodes. This is
    distinct from establishing a channel with a peer.
    */
    rpc ConnectPeer (ConnectPeerRequest) returns (ConnectPeerResponse) {
        option (google.api.http) = {
            post: "/v1/peers"
            body: "*"
        };
    }

    /** lncli: `disconnect`
    DisconnectPeer attempts to disconnect one peer from another identified by a
    given pubKey. In the case that we currently have a pending or active channel
    with the target peer, then this action will be not be allowed.
    */
    rpc DisconnectPeer (DisconnectPeerRequest) returns (DisconnectPeerResponse) {
        option (google.api.http) = {
            delete: "/v1/peers/{pub_key}"
        };
    }

    /** lncli: `listpeers`
    ListPeers returns a verbose listing of all currently active peers.
    */
    rpc ListPeers (ListPeersRequest) returns (ListPeersResponse) {
        option (google.api.http) = {
            get: "/v1/peers"
        };
    }

    /** lncli: `getinfo`
    GetInfo returns general information concerning the lightning node including
    it's identity pubkey, alias, the chains it is connected to, and information
    concerning the number of open+pending channels.
    */
    rpc GetInfo (GetInfoRequest) returns (GetInfoResponse) {
        option (google.api.http) = {
            get: "/v1/getinfo"
        };
    }

    // TODO(roasbeef): merge with below with bool?
    /** lncli: `pendingchannels`
    PendingChannels returns a list of all the channels that are currently
    considered "pending". A channel is pending if it has finished the funding
    workflow and is waiting for confirmations for the funding txn, or is in the
    process of closure, either initiated cooperatively or non-cooperatively.
    */
    rpc PendingChannels (PendingChannelsRequest) returns (PendingChannelsResponse) {
        option (google.api.http) = {
           get: "/v1/channels/pending"
        };
    }

    /** lncli: `listchannels`
    ListChannels returns a description of all the open channels that this node
    is a participant in.
    */
    rpc ListChannels (ListChannelsRequest) returns (ListChannelsResponse) {
        option (google.api.http) = {
            get: "/v1/channels"
        };
    }

    /**
    SubscribeChannelEvents creates a uni-directional stream from the server to
    the client in which any updates relevant to the state of the channels are
    sent over. Events include new active channels, inactive channels, and closed
    channels.
    */
    rpc SubscribeChannelEvents (ChannelEventSubscription) returns (stream ChannelEventUpdate);

    /** lncli: `closedchannels`
    ClosedChannels returns a description of all the closed channels that
    this node was a participant in.
    */
    rpc ClosedChannels (ClosedChannelsRequest) returns (ClosedChannelsResponse) {
        option (google.api.http) = {
            get: "/v1/channels/closed"
        };
    }


    /**
    OpenChannelSync is a synchronous version of the OpenChannel RPC call. This
    call is meant to be consumed by clients to the REST proxy. As with all
    other sync calls, all byte slices are intended to be populated as hex
    encoded strings.
    */
    rpc OpenChannelSync (OpenChannelRequest) returns (ChannelPoint) {
        option (google.api.http) = {
            post: "/v1/channels"
            body: "*"
        };
    }

    /** lncli: `openchannel`
    OpenChannel attempts to open a singly funded channel specified in the
    request to a remote peer. Users are able to specify a target number of
    blocks that the funding transaction should be confirmed in, or a manual fee
    rate to us for the funding transaction. If neither are specified, then a
    lax block confirmation target is used.
    */
    rpc OpenChannel (OpenChannelRequest) returns (stream OpenStatusUpdate);

    /** lncli: `closechannel`
    CloseChannel attempts to close an active channel identified by its channel
    outpoint (ChannelPoint). The actions of this method can additionally be
    augmented to attempt a force close after a timeout period in the case of an
    inactive peer. If a non-force close (cooperative closure) is requested,
    then the user can specify either a target number of blocks until the
    closure transaction is confirmed, or a manual fee rate. If neither are
    specified, then a default lax, block confirmation target is used.
    */
    rpc CloseChannel (CloseChannelRequest) returns (stream CloseStatusUpdate) {
        option (google.api.http) = {
            delete: "/v1/channels/{channel_point.funding_txid_str}/{channel_point.output_index}"
        };
    }

    /** lncli: `abandonchannel`
    AbandonChannel removes all channel state from the database except for a
    close summary. This method can be used to get rid of permanently unusable
    channels due to bugs fixed in newer versions of lnd. Only available
    when in debug builds of lnd.
    */
    rpc AbandonChannel (AbandonChannelRequest) returns (AbandonChannelResponse) {
        option (google.api.http) = {
            delete: "/v1/channels/abandon/{channel_point.funding_txid_str}/{channel_point.output_index}"
        };
    }


    /** lncli: `sendpayment`
    SendPayment dispatches a bi-directional streaming RPC for sending payments
    through the Lightning Network. A single RPC invocation creates a persistent
    bi-directional stream allowing clients to rapidly send payments through the
    Lightning Network with a single persistent connection.
    */
    rpc SendPayment (stream SendRequest) returns (stream SendResponse);

    /**
    SendPaymentSync is the synchronous non-streaming version of SendPayment.
    This RPC is intended to be consumed by clients of the REST proxy.
    Additionally, this RPC expects the destination's public key and the payment
    hash (if any) to be encoded as hex strings.
    */
    rpc SendPaymentSync (SendRequest) returns (SendResponse) {
        option (google.api.http) = {
            post: "/v1/channels/transactions"
            body: "*"
        };
    }

    /** lncli: `sendtoroute`
    SendToRoute is a bi-directional streaming RPC for sending payment through
    the Lightning Network. This method differs from SendPayment in that it
    allows users to specify a full route manually. This can be used for things
    like rebalancing, and atomic swaps.
    */
    rpc SendToRoute(stream SendToRouteRequest) returns (stream SendResponse);

    /**
    SendToRouteSync is a synchronous version of SendToRoute. It Will block
    until the payment either fails or succeeds.
    */
    rpc SendToRouteSync (SendToRouteRequest) returns (SendResponse) {
        option (google.api.http) = {
            post: "/v1/channels/transactions/route"
            body: "*"
        };
    }

    /** lncli: `addinvoice`
    AddInvoice attempts to add a new invoice to the invoice database. Any
    duplicated invoices are rejected, therefore all invoices *must* have a
    unique payment preimage.
    */
    rpc AddInvoice (Invoice) returns (AddInvoiceResponse) {
        option (google.api.http) = {
            post: "/v1/invoices"
            body: "*"
        };
    }

    /** lncli: `listinvoices`
    ListInvoices returns a list of all the invoices currently stored within the
    database. Any active debug invoices are ignored. It has full support for
    paginated responses, allowing users to query for specific invoices through
    their add_index. This can be done by using either the first_index_offset or
    last_index_offset fields included in the response as the index_offset of the
    next request. By default, the first 100 invoices created will be returned.
    Backwards pagination is also supported through the Reversed flag.
    */
    rpc ListInvoices (ListInvoiceRequest) returns (ListInvoiceResponse) {
        option (google.api.http) = {
            get: "/v1/invoices"
        };
    }

    /** lncli: `lookupinvoice`
    LookupInvoice attempts to look up an invoice according to its payment hash.
    The passed payment hash *must* be exactly 32 bytes, if not, an error is
    returned.
    */
    rpc LookupInvoice (PaymentHash) returns (Invoice) {
        option (google.api.http) = {
            get: "/v1/invoice/{r_hash_str}"
        };
    }

    /**
    SubscribeInvoices returns a uni-directional stream (server -> client) for
    notifying the client of newly added/settled invoices. The caller can
    optionally specify the add_index and/or the settle_index. If the add_index
    is specified, then we'll first start by sending add invoice events for all
    invoices with an add_index greater than the specified value.  If the
    settle_index is specified, the next, we'll send out all settle events for
    invoices with a settle_index greater than the specified value.  One or both
    of these fields can be set. If no fields are set, then we'll only send out
    the latest add/settle events.
    */
    rpc SubscribeInvoices (InvoiceSubscription) returns (stream Invoice) {
        option (google.api.http) = {
            get: "/v1/invoices/subscribe"
        };
    }

    /** lncli: `decodepayreq`
    DecodePayReq takes an encoded payment request string and attempts to decode
    it, returning a full description of the conditions encoded within the
    payment request.
    */
    rpc DecodePayReq (PayReqString) returns (PayReq) {
        option (google.api.http) = {
            get: "/v1/payreq/{pay_req}"
        };
    }

    /** lncli: `listpayments`
    ListPayments returns a list of all outgoing payments.
    */
    rpc ListPayments (ListPaymentsRequest) returns (ListPaymentsResponse) {
        option (google.api.http) = {
            get: "/v1/payments"
        };
    };

    /**
    DeleteAllPayments deletes all outgoing payments from DB.
    */
    rpc DeleteAllPayments (DeleteAllPaymentsRequest) returns (DeleteAllPaymentsResponse) {
        option (google.api.http) = {
            delete: "/v1/payments"
        };
    };

    /** lncli: `describegraph`
    DescribeGraph returns a description of the latest graph state from the
    point of view of the node. The graph information is partitioned into two
    components: all the nodes/vertexes, and all the edges that connect the
    vertexes themselves.  As this is a directed graph, the edges also contain
    the node directional specific routing policy which includes: the time lock
    delta, fee information, etc.
    */
    rpc DescribeGraph (ChannelGraphRequest) returns (ChannelGraph) {
        option (google.api.http) = {
            get: "/v1/graph"
        };
    }

    /** lncli: `getchaninfo`
    GetChanInfo returns the latest authenticated network announcement for the
    given channel identified by its channel ID: an 8-byte integer which
    uniquely identifies the location of transaction's funding output within the
    blockchain.
    */
    rpc GetChanInfo (ChanInfoRequest) returns (ChannelEdge) {
        option (google.api.http) = {
            get: "/v1/graph/edge/{chan_id}"
        };
    }

    /** lncli: `getnodeinfo`
    GetNodeInfo returns the latest advertised, aggregated, and authenticated
    channel information for the specified node identified by its public key.
    */
    rpc GetNodeInfo (NodeInfoRequest) returns (NodeInfo) {
        option (google.api.http) = {
            get: "/v1/graph/node/{pub_key}"
        };
    }

    /** lncli: `queryroutes`
    QueryRoutes attempts to query the daemon's Channel Router for a possible
    route to a target destination capable of carrying a specific amount of
    satoshis. The returned route contains the full details required to craft and
    send an HTLC, also including the necessary information that should be
    present within the Sphinx packet encapsulated within the HTLC.
    */
    rpc QueryRoutes(QueryRoutesRequest) returns (QueryRoutesResponse) {
        option (google.api.http) = {
            get: "/v1/graph/routes/{pub_key}/{amt}"
        };
    }

    /** lncli: `getnetworkinfo`
    GetNetworkInfo returns some basic stats about the known channel graph from
    the point of view of the node.
    */
    rpc GetNetworkInfo (NetworkInfoRequest) returns (NetworkInfo) {
        option (google.api.http) = {
            get: "/v1/graph/info"
        };
    }

    /** lncli: `stop`
    StopDaemon will send a shutdown request to the interrupt handler, triggering
    a graceful shutdown of the daemon.
    */
    rpc StopDaemon(StopRequest) returns (StopResponse);

    /**
    SubscribeChannelGraph launches a streaming RPC that allows the caller to
    receive notifications upon any changes to the channel graph topology from
    the point of view of the responding node. Events notified include: new
    nodes coming online, nodes updating their authenticated attributes, new
    channels being advertised, updates in the routing policy for a directional
    channel edge, and when channels are closed on-chain.
    */
    rpc SubscribeChannelGraph(GraphTopologySubscription) returns (stream GraphTopologyUpdate);

    /** lncli: `debuglevel`
    DebugLevel allows a caller to programmatically set the logging verbosity of
    lnd. The logging can be targeted according to a coarse daemon-wide logging
    level, or in a granular fashion to specify the logging for a target
    sub-system.
    */
    rpc DebugLevel (DebugLevelRequest) returns (DebugLevelResponse);

    /** lncli: `feereport`
    FeeReport allows the caller to obtain a report detailing the current fee
    schedule enforced by the node globally for each channel.
    */
    rpc FeeReport(FeeReportRequest) returns (FeeReportResponse) {
        option (google.api.http) = {
            get: "/v1/fees"
        };
    }

    /** lncli: `updatechanpolicy`
    UpdateChannelPolicy allows the caller to update the fee schedule and
    channel policies for all channels globally, or a particular channel.
    */
    rpc UpdateChannelPolicy(PolicyUpdateRequest) returns (PolicyUpdateResponse) {
        option (google.api.http) = {
            post: "/v1/chanpolicy"
            body: "*"
        };
    }

    /** lncli: `fwdinghistory`
    ForwardingHistory allows the caller to query the htlcswitch for a record of
    all HTLCs forwarded within the target time range, and integer offset
    within that time range. If no time-range is specified, then the first chunk
    of the past 24 hrs of forwarding history are returned.

    A list of forwarding events are returned. The size of each forwarding event
    is 40 bytes, and the max message size able to be returned in gRPC is 4 MiB.
    As a result each message can only contain 50k entries.  Each response has
    the index offset of the last entry. The index offset can be provided to the
    request to allow the caller to skip a series of records.
    */
    rpc ForwardingHistory(ForwardingHistoryRequest) returns (ForwardingHistoryResponse) {
        option (google.api.http) = {
            post: "/v1/switch"
            body: "*"
        };
    };

    /** lncli: `exportchanbackup`
    ExportChannelBackup attempts to return an encrypted static channel backup
    for the target channel identified by it channel point. The backup is
    encrypted with a key generated from the aezeed seed of the user. The
    returned backup can either be restored using the RestoreChannelBackup
    method once lnd is running, or via the InitWallet and UnlockWallet methods
    from the WalletUnlocker service.
    */
    rpc ExportChannelBackup(ExportChannelBackupRequest) returns (ChannelBackup) {
        option (google.api.http) = {
            get: "/v1/channels/backup/{chan_point.funding_txid_str}/{chan_point.output_index}"
        };
    };

    /**
    ExportAllChannelBackups returns static channel backups for all existing
    channels known to lnd. A set of regular singular static channel backups for
    each channel are returned. Additionally, a multi-channel backup is returned
    as well, which contains a single encrypted blob containing the backups of
    each channel.
    */
    rpc ExportAllChannelBackups(ChanBackupExportRequest) returns (ChanBackupSnapshot) {
        option (google.api.http) = {
            get: "/v1/channels/backup"
        };
    };

    /**
    VerifyChanBackup allows a caller to verify the integrity of a channel backup
    snapshot. This method will accept either a packed Single or a packed Multi.
    Specifying both will result in an error.
    */
    rpc VerifyChanBackup(ChanBackupSnapshot) returns (VerifyChanBackupResponse) {
        option (google.api.http) = {
            post: "/v1/channels/backup/verify"
            body: "*"
        };
    };

    /** lncli: `restorechanbackup`
    RestoreChannelBackups accepts a set of singular channel backups, or a
    single encrypted multi-chan backup and attempts to recover any funds
    remaining within the channel. If we are able to unpack the backup, then the
    new channel will be shown under listchannels, as well as pending channels.
    */
    rpc RestoreChannelBackups(RestoreChanBackupRequest) returns (RestoreBackupResponse)  {
        option (google.api.http) = {
            post: "/v1/channels/backup/restore"
            body: "*"
        };
    };

    /**
    SubscribeChannelBackups allows a client to sub-subscribe to the most up to
    date information concerning the state of all channel backups. Each time a
    new channel is added, we return the new set of channels, along with a
    multi-chan backup containing the backup info for all channels. Each time a
    channel is closed, we send a new update, which contains new new chan back
    ups, but the updated set of encrypted multi-chan backups with the closed
    channel(s) removed.
    */
    rpc SubscribeChannelBackups(ChannelBackupSubscription) returns (stream ChanBackupSnapshot) {
    };
}

message Utxo {
    /// The type of address
    AddressType type = 1 [json_name = "address_type"];

    /// The address
    string address = 2 [json_name = "address"];

    /// The value of the unspent coin in satoshis
    int64 amount_sat = 3 [json_name = "amount_sat"];

    /// The pkscript in hex
    string pk_script = 4 [json_name = "pk_script"];

    /// The outpoint in format txid:n
    OutPoint outpoint = 5 [json_name = "outpoint"];

    /// The number of confirmations for the Utxo
    int64 confirmations = 6 [json_name = "confirmations"];
}

message Transaction {
    /// The transaction hash
    string tx_hash = 1 [ json_name = "tx_hash" ];

    /// The transaction amount, denominated in satoshis
    int64 amount = 2 [ json_name = "amount" ];

    /// The number of confirmations
    int32 num_confirmations = 3 [ json_name = "num_confirmations" ];

    /// The hash of the block this transaction was included in
    string block_hash = 4 [ json_name = "block_hash" ];

    /// The height of the block this transaction was included in
    int32 block_height = 5 [ json_name = "block_height" ];

    /// Timestamp of this transaction 
    int64 time_stamp = 6 [ json_name = "time_stamp" ];

    /// Fees paid for this transaction
    int64 total_fees = 7 [ json_name = "total_fees" ];

    /// Addresses that received funds for this transaction
    repeated string dest_addresses = 8 [ json_name = "dest_addresses" ];

    /// The raw transaction hex.
    string raw_tx_hex = 9 [ json_name = "raw_tx_hex" ];
}
message GetTransactionsRequest {
}
message TransactionDetails {
    /// The list of transactions relevant to the wallet.
    repeated Transaction transactions = 1 [json_name = "transactions"];
}

message FeeLimit {
    oneof limit {
        /// The fee limit expressed as a fixed amount of satoshis.
        int64 fixed = 1;

        /// The fee limit expressed as a percentage of the payment amount.
        int64 percent = 2;
    }
}

message SendRequest {
    /// The identity pubkey of the payment recipient
    bytes dest = 1;

    /// The hex-encoded identity pubkey of the payment recipient
    string dest_string = 2;

    /// Number of satoshis to send.
    int64 amt = 3;

    /// The hash to use within the payment's HTLC
    bytes payment_hash = 4;

    /// The hex-encoded hash to use within the payment's HTLC
    string payment_hash_string = 5;

    /**
    A bare-bones invoice for a payment within the Lightning Network.  With the
    details of the invoice, the sender has all the data necessary to send a
    payment to the recipient.
    */
    string payment_request = 6;

    /**
    The CLTV delta from the current height that should be used to set the
    timelock for the final hop.
    */
    int32 final_cltv_delta = 7;

    /**
    The maximum number of satoshis that will be paid as a fee of the payment.
    This value can be represented either as a percentage of the amount being
    sent, or as a fixed amount of the maximum fee the user is willing the pay to
    send the payment.
    */
    FeeLimit fee_limit = 8;

    /**
    The channel id of the channel that must be taken to the first hop. If zero,
    any channel may be used.
    */
    uint64 outgoing_chan_id = 9;

    /** 
    An optional maximum total time lock for the route. If zero, there is no
    maximum enforced.
    */
    uint32 cltv_limit = 10;

    /** 
    An optional field that can be used to pass an arbitrary set of TLV records
    to a peer which understands the new records. This can be used to pass
    application specific data during the payment attempt.
    */
    map<uint64, bytes> dest_tlv = 11;
}

message SendResponse {
    string payment_error = 1 [json_name = "payment_error"];
    bytes payment_preimage = 2 [json_name = "payment_preimage"];
    Route payment_route = 3 [json_name = "payment_route"];
    bytes payment_hash = 4 [json_name = "payment_hash"];
}

message SendToRouteRequest {
    /// The payment hash to use for the HTLC.
    bytes payment_hash = 1;

    /// An optional hex-encoded payment hash to be used for the HTLC.
    string payment_hash_string = 2;

    reserved 3;

    /// Route that should be used to attempt to complete the payment.
    Route route = 4;
}

message ChannelPoint {
    oneof funding_txid {
        /// Txid of the funding transaction
        bytes funding_txid_bytes = 1 [json_name = "funding_txid_bytes"];

        /// Hex-encoded string representing the funding transaction
        string funding_txid_str = 2 [json_name = "funding_txid_str"];
    }

    /// The index of the output of the funding transaction
    uint32 output_index = 3 [json_name = "output_index"];
}

message OutPoint {
    /// Raw bytes representing the transaction id.
    bytes txid_bytes = 1 [json_name = "txid_bytes"];

    /// Reversed, hex-encoded string representing the transaction id.
    string txid_str = 2 [json_name = "txid_str"];

    /// The index of the output on the transaction.
    uint32 output_index = 3 [json_name = "output_index"];
}

message LightningAddress {
    /// The identity pubkey of the Lightning node
    string pubkey = 1 [json_name = "pubkey"];

    /// The network location of the lightning node, e.g. `69.69.69.69:1337` or `localhost:10011`
    string host = 2 [json_name = "host"];
}

message EstimateFeeRequest {
    /// The map from addresses to amounts for the transaction.
    map<string, int64> AddrToAmount = 1;

    /// The target number of blocks that this transaction should be confirmed by.
    int32 target_conf = 2;
}

message EstimateFeeResponse {
    /// The total fee in satoshis.
    int64 fee_sat = 1 [json_name = "fee_sat"];

    /// The fee rate in satoshi/byte.
    int64 feerate_sat_per_byte = 2 [json_name = "feerate_sat_per_byte"];
}

message SendManyRequest {
    /// The map from addresses to amounts
    map<string, int64> AddrToAmount = 1;

    /// The target number of blocks that this transaction should be confirmed by.
    int32 target_conf = 3;

    /// A manual fee rate set in sat/byte that should be used when crafting the transaction.
    int64 sat_per_byte = 5;
}
message SendManyResponse {
    /// The id of the transaction
    string txid = 1 [json_name = "txid"];
}

message SendCoinsRequest {
    /// The address to send coins to 
    string addr = 1;

    /// The amount in satoshis to send
    int64 amount = 2;

    /// The target number of blocks that this transaction should be confirmed by.
    int32 target_conf = 3;

    /// A manual fee rate set in sat/byte that should be used when crafting the transaction.
    int64 sat_per_byte = 5;

    /**
    If set, then the amount field will be ignored, and lnd will attempt to
    send all the coins under control of the internal wallet to the specified
    address.
    */
    bool send_all = 6; 
}
message SendCoinsResponse {
    /// The transaction ID of the transaction
    string txid = 1 [json_name = "txid"];
}

message ListUnspentRequest {
    /// The minimum number of confirmations to be included.
    int32 min_confs = 1;

    /// The maximum number of confirmations to be included.
    int32 max_confs = 2;
}
message ListUnspentResponse {
    /// A list of utxos
    repeated Utxo utxos = 1 [json_name = "utxos"];
}

/** 
`AddressType` has to be one of:

- `p2wkh`: Pay to witness key hash (`WITNESS_PUBKEY_HASH` = 0)
- `np2wkh`: Pay to nested witness key hash (`NESTED_PUBKEY_HASH` = 1)
*/
enum AddressType {
        WITNESS_PUBKEY_HASH = 0;
        NESTED_PUBKEY_HASH = 1;
        UNUSED_WITNESS_PUBKEY_HASH = 2;
        UNUSED_NESTED_PUBKEY_HASH = 3;
}

message NewAddressRequest {
    /// The address type
    AddressType type = 1;
}
message NewAddressResponse {
    /// The newly generated wallet address
    string address = 1 [json_name = "address"];
}

message SignMessageRequest {
    /// The message to be signed
    bytes msg = 1 [ json_name = "msg" ];
}
message SignMessageResponse {
    /// The signature for the given message
    string signature = 1 [ json_name = "signature" ];
}

message VerifyMessageRequest {
    /// The message over which the signature is to be verified
    bytes msg = 1 [ json_name = "msg" ];

    /// The signature to be verified over the given message
    string signature = 2 [ json_name = "signature" ];
}
message VerifyMessageResponse {
    /// Whether the signature was valid over the given message
    bool valid = 1 [ json_name = "valid" ];

    /// The pubkey recovered from the signature
    string pubkey = 2 [ json_name = "pubkey" ];
}

message ConnectPeerRequest {
    /// Lightning address of the peer, in the format `<pubkey>@host`
    LightningAddress addr = 1;

    /** If set, the daemon will attempt to persistently connect to the target
     * peer.  Otherwise, the call will be synchronous. */
    bool perm = 2;
}
message ConnectPeerResponse {
}

message DisconnectPeerRequest {
    /// The pubkey of the node to disconnect from
    string pub_key = 1 [json_name = "pub_key"];
}
message DisconnectPeerResponse {
}

message HTLC {
    bool incoming = 1 [json_name = "incoming"];
    int64 amount = 2 [json_name = "amount"];
    bytes hash_lock = 3 [json_name = "hash_lock"];
    uint32 expiration_height = 4 [json_name = "expiration_height"];
}

message Channel {
    /// Whether this channel is active or not
    bool active = 1 [json_name = "active"];

    /// The identity pubkey of the remote node
    string remote_pubkey = 2 [json_name = "remote_pubkey"];

    /**
    The outpoint (txid:index) of the funding transaction. With this value, Bob
    will be able to generate a signature for Alice's version of the commitment
    transaction.
    */
    string channel_point = 3 [json_name = "channel_point"];

    /**
    The unique channel ID for the channel. The first 3 bytes are the block
    height, the next 3 the index within the block, and the last 2 bytes are the
    output index for the channel.
    */
    uint64 chan_id = 4 [json_name = "chan_id"];

    /// The total amount of funds held in this channel
    int64 capacity = 5 [json_name = "capacity"];

    /// This node's current balance in this channel
    int64 local_balance = 6 [json_name = "local_balance"];

    /// The counterparty's current balance in this channel
    int64 remote_balance = 7 [json_name = "remote_balance"];

    /**
    The amount calculated to be paid in fees for the current set of commitment
    transactions. The fee amount is persisted with the channel in order to
    allow the fee amount to be removed and recalculated with each channel state
    update, including updates that happen after a system restart.
    */
    int64 commit_fee = 8 [json_name = "commit_fee"];

    /// The weight of the commitment transaction
    int64 commit_weight = 9 [json_name = "commit_weight"];

    /**
    The required number of satoshis per kilo-weight that the requester will pay
    at all times, for both the funding transaction and commitment transaction.
    This value can later be updated once the channel is open.
    */
    int64 fee_per_kw = 10 [json_name = "fee_per_kw"];

    /// The unsettled balance in this channel
    int64 unsettled_balance = 11 [json_name = "unsettled_balance"];

    /**
    The total number of satoshis we've sent within this channel.
    */
    int64 total_satoshis_sent = 12 [json_name = "total_satoshis_sent"];

    /**
    The total number of satoshis we've received within this channel.
    */
    int64 total_satoshis_received = 13 [json_name = "total_satoshis_received"];

    /**
    The total number of updates conducted within this channel.
    */
    uint64 num_updates = 14 [json_name = "num_updates"];

    /**
    The list of active, uncleared HTLCs currently pending within the channel.
    */
    repeated HTLC pending_htlcs = 15 [json_name = "pending_htlcs"];

    /**
    The CSV delay expressed in relative blocks. If the channel is force closed,
    we will need to wait for this many blocks before we can regain our funds.
    */
    uint32 csv_delay = 16 [json_name = "csv_delay"];

    /// Whether this channel is advertised to the network or not.
    bool private = 17 [json_name = "private"];

    /// True if we were the ones that created the channel.
    bool initiator = 18 [json_name = "initiator"];

    /// A set of flags showing the current state of the channel.
    string chan_status_flags = 19 [json_name = "chan_status_flags"];

    /// The minimum satoshis this node is required to reserve in its balance.
    int64 local_chan_reserve_sat = 20 [json_name = "local_chan_reserve_sat"];

    /**
    The minimum satoshis the other node is required to reserve in its balance.
    */
    int64 remote_chan_reserve_sat = 21 [json_name = "remote_chan_reserve_sat"];
}


message ListChannelsRequest {
    bool active_only = 1;
    bool inactive_only = 2;
    bool public_only = 3;
    bool private_only = 4;
}
message ListChannelsResponse {
    /// The list of active channels
    repeated Channel channels = 11 [json_name = "channels"];
}

message ChannelCloseSummary {
    /// The outpoint (txid:index) of the funding transaction. 
    string channel_point = 1 [json_name = "channel_point"];

    ///  The unique channel ID for the channel. 
    uint64 chan_id = 2 [json_name = "chan_id"];

    /// The hash of the genesis block that this channel resides within.
    string chain_hash = 3 [json_name = "chain_hash"];

    /// The txid of the transaction which ultimately closed this channel.
    string closing_tx_hash = 4 [json_name = "closing_tx_hash"];

    /// Public key of the remote peer that we formerly had a channel with.
    string remote_pubkey = 5 [json_name = "remote_pubkey"];

    /// Total capacity of the channel.
    int64 capacity = 6 [json_name = "capacity"];

    /// Height at which the funding transaction was spent.
    uint32 close_height = 7 [json_name = "close_height"];

    /// Settled balance at the time of channel closure
    int64 settled_balance = 8 [json_name = "settled_balance"];

    /// The sum of all the time-locked outputs at the time of channel closure
    int64 time_locked_balance = 9 [json_name = "time_locked_balance"];

    enum ClosureType {
        COOPERATIVE_CLOSE = 0;
        LOCAL_FORCE_CLOSE = 1;
        REMOTE_FORCE_CLOSE = 2;
        BREACH_CLOSE = 3;
        FUNDING_CANCELED = 4;
        ABANDONED = 5;
    }

    /// Details on how the channel was closed.
    ClosureType close_type = 10 [json_name = "close_type"];
}

message ClosedChannelsRequest {
    bool cooperative = 1;
    bool local_force = 2;
    bool remote_force = 3;
    bool breach = 4;
    bool funding_canceled = 5;
    bool abandoned = 6;
}

message ClosedChannelsResponse { 
    repeated ChannelCloseSummary channels = 1 [json_name = "channels"];
}

message Peer {
    /// The identity pubkey of the peer
    string pub_key = 1 [json_name = "pub_key"];

    /// Network address of the peer; eg `127.0.0.1:10011`
    string address = 3 [json_name = "address"];

    /// Bytes of data transmitted to this peer
    uint64 bytes_sent = 4 [json_name = "bytes_sent"];

    /// Bytes of data transmitted from this peer
    uint64 bytes_recv = 5 [json_name = "bytes_recv"];

    /// Satoshis sent to this peer
    int64 sat_sent = 6 [json_name = "sat_sent"];

    /// Satoshis received from this peer
    int64 sat_recv = 7 [json_name = "sat_recv"];

    /// A channel is inbound if the counterparty initiated the channel
    bool inbound = 8 [json_name = "inbound"];

    /// Ping time to this peer
    int64 ping_time = 9 [json_name = "ping_time"];

    enum SyncType {
        /**
        Denotes that we cannot determine the peer's current sync type.
        */
        UNKNOWN_SYNC = 0;

        /**
        Denotes that we are actively receiving new graph updates from the peer.
        */
        ACTIVE_SYNC = 1;

        /**
        Denotes that we are not receiving new graph updates from the peer.
        */
        PASSIVE_SYNC = 2;
    }

    // The type of sync we are currently performing with this peer.
    SyncType sync_type = 10 [json_name = "sync_type"];
}

message ListPeersRequest {
}
message ListPeersResponse {
    /// The list of currently connected peers
    repeated Peer peers = 1 [json_name = "peers"];
}

message GetInfoRequest {
}
message GetInfoResponse {

    /// The identity pubkey of the current node.
    string identity_pubkey = 1 [json_name = "identity_pubkey"];

    /// If applicable, the alias of the current node, e.g. "bob"
    string alias = 2 [json_name = "alias"];

    /// Number of pending channels
    uint32 num_pending_channels = 3 [json_name = "num_pending_channels"];

    /// Number of active channels
    uint32 num_active_channels = 4 [json_name = "num_active_channels"];

    /// Number of peers
    uint32 num_peers = 5 [json_name = "num_peers"];

    /// The node's current view of the height of the best block
    uint32 block_height = 6 [json_name = "block_height"];

    /// The node's current view of the hash of the best block
    string block_hash = 8 [json_name = "block_hash"];

    /// Whether the wallet's view is synced to the main chain
    bool synced_to_chain = 9 [json_name = "synced_to_chain"];

    /** 
    Whether the current node is connected to testnet. This field is 
    deprecated and the network field should be used instead 
    **/
    bool testnet = 10 [json_name = "testnet", deprecated = true];

    reserved 11;

    /// The URIs of the current node.
    repeated string uris = 12 [json_name = "uris"];

    /// Timestamp of the block best known to the wallet
    int64 best_header_timestamp = 13 [ json_name = "best_header_timestamp" ];

    /// The version of the LND software that the node is running.
    string version = 14 [ json_name = "version" ];

    /// Number of inactive channels
    uint32 num_inactive_channels = 15 [json_name = "num_inactive_channels"];

    /// A list of active chains the node is connected to
    repeated Chain chains = 16 [json_name = "chains"];

    /// The color of the current node in hex code format
    string color = 17 [json_name = "color"];

    // Whether we consider ourselves synced with the public channel graph.
    bool synced_to_graph = 18 [json_name = "synced_to_graph"];
}

message Chain {
    /// The blockchain the node is on (eg bitcoin, litecoin)
    string chain = 1 [json_name = "chain"];

    /// The network the node is on (eg regtest, testnet, mainnet)
    string network = 2 [json_name = "network"];
}

message ConfirmationUpdate {
    bytes block_sha = 1;
    int32 block_height = 2;

    uint32 num_confs_left = 3;
}

message ChannelOpenUpdate {
    ChannelPoint channel_point = 1 [json_name = "channel_point"];
}

message ChannelCloseUpdate {
    bytes closing_txid = 1 [json_name = "closing_txid"];

    bool success = 2 [json_name = "success"];
}

message CloseChannelRequest {
    /**
    The outpoint (txid:index) of the funding transaction. With this value, Bob
    will be able to generate a signature for Alice's version of the commitment
    transaction.
    */
    ChannelPoint channel_point = 1;

    /// If true, then the channel will be closed forcibly. This means the current commitment transaction will be signed and broadcast.
    bool force = 2;

    /// The target number of blocks that the closure transaction should be confirmed by.
    int32 target_conf = 3;

    /// A manual fee rate set in sat/byte that should be used when crafting the closure transaction.
    int64 sat_per_byte = 4;
}

message CloseStatusUpdate {
    oneof update {
        PendingUpdate close_pending = 1 [json_name = "close_pending"];
        ChannelCloseUpdate chan_close = 3 [json_name = "chan_close"];
    }
}

message PendingUpdate {
    bytes txid = 1 [json_name = "txid"];
    uint32 output_index = 2 [json_name = "output_index"];
}

message OpenChannelRequest {
    /// The pubkey of the node to open a channel with
    bytes node_pubkey = 2 [json_name = "node_pubkey"];

    /// The hex encoded pubkey of the node to open a channel with
    string node_pubkey_string = 3 [json_name = "node_pubkey_string"];

    /// The number of satoshis the wallet should commit to the channel
    int64 local_funding_amount = 4 [json_name = "local_funding_amount"];

    /// The number of satoshis to push to the remote side as part of the initial commitment state
    int64 push_sat = 5 [json_name = "push_sat"];

    /// The target number of blocks that the funding transaction should be confirmed by.
    int32 target_conf = 6;

    /// A manual fee rate set in sat/byte that should be used when crafting the funding transaction.
    int64 sat_per_byte = 7;

    /// Whether this channel should be private, not announced to the greater network.
    bool private = 8 [json_name = "private"];

    /// The minimum value in millisatoshi we will require for incoming HTLCs on the channel.
    int64 min_htlc_msat = 9 [json_name = "min_htlc_msat"];

    /// The delay we require on the remote's commitment transaction. If this is not set, it will be scaled automatically with the channel size.
    uint32 remote_csv_delay = 10 [json_name = "remote_csv_delay"];

    /// The minimum number of confirmations each one of your outputs used for the funding transaction must satisfy.
    int32 min_confs = 11 [json_name = "min_confs"];

    /// Whether unconfirmed outputs should be used as inputs for the funding transaction.
    bool spend_unconfirmed = 12 [json_name = "spend_unconfirmed"];
}
message OpenStatusUpdate {
    oneof update {
        PendingUpdate chan_pending = 1 [json_name = "chan_pending"];
        ChannelOpenUpdate chan_open = 3 [json_name = "chan_open"];
    }
}

message PendingHTLC {

    /// The direction within the channel that the htlc was sent
    bool incoming = 1 [ json_name = "incoming" ];

    /// The total value of the htlc
    int64 amount = 2 [ json_name = "amount" ];

    /// The final output to be swept back to the user's wallet
    string outpoint = 3 [ json_name = "outpoint" ];

    /// The next block height at which we can spend the current stage
    uint32 maturity_height = 4 [ json_name = "maturity_height" ];

    /**
       The number of blocks remaining until the current stage can be swept.
       Negative values indicate how many blocks have passed since becoming
       mature.
    */
    int32 blocks_til_maturity = 5 [ json_name = "blocks_til_maturity" ];

    /// Indicates whether the htlc is in its first or second stage of recovery
    uint32 stage = 6 [ json_name = "stage" ];
}

message PendingChannelsRequest {}
message PendingChannelsResponse {
    message PendingChannel {
        string remote_node_pub = 1 [ json_name = "remote_node_pub" ];
        string channel_point = 2 [ json_name = "channel_point" ];

        int64 capacity = 3 [ json_name = "capacity" ];

        int64 local_balance = 4 [ json_name = "local_balance" ];
        int64 remote_balance = 5 [ json_name = "remote_balance" ];
       
        /// The minimum satoshis this node is required to reserve in its balance.
        int64 local_chan_reserve_sat = 6 [json_name = "local_chan_reserve_sat"];

        /**
        The minimum satoshis the other node is required to reserve in its
        balance.
        */
        int64 remote_chan_reserve_sat = 7 [json_name = "remote_chan_reserve_sat"];
    }

    message PendingOpenChannel {
        /// The pending channel
        PendingChannel channel = 1 [ json_name = "channel" ];

        /// The height at which this channel will be confirmed
        uint32 confirmation_height = 2 [ json_name = "confirmation_height" ];

        /**
        The amount calculated to be paid in fees for the current set of
        commitment transactions. The fee amount is persisted with the channel
        in order to allow the fee amount to be removed and recalculated with
        each channel state update, including updates that happen after a system
        restart.
        */
        int64 commit_fee = 4 [json_name = "commit_fee" ];

        /// The weight of the commitment transaction
        int64 commit_weight = 5 [ json_name = "commit_weight" ];

        /**
        The required number of satoshis per kilo-weight that the requester will
        pay at all times, for both the funding transaction and commitment
        transaction. This value can later be updated once the channel is open.
        */
        int64 fee_per_kw = 6 [ json_name = "fee_per_kw" ];
    }

    message WaitingCloseChannel {
        /// The pending channel waiting for closing tx to confirm
        PendingChannel channel = 1;

        /// The balance in satoshis encumbered in this channel
        int64 limbo_balance = 2 [ json_name = "limbo_balance" ];
    }

    message ClosedChannel {
        /// The pending channel to be closed
        PendingChannel channel = 1;

        /// The transaction id of the closing transaction
        string closing_txid = 2 [ json_name = "closing_txid" ];
    }

    message ForceClosedChannel {
        /// The pending channel to be force closed
        PendingChannel channel = 1 [ json_name = "channel" ];

        /// The transaction id of the closing transaction
        string closing_txid = 2 [ json_name = "closing_txid" ];

        /// The balance in satoshis encumbered in this pending channel
        int64 limbo_balance = 3 [ json_name = "limbo_balance" ];

        /// The height at which funds can be swept into the wallet
        uint32 maturity_height = 4 [ json_name = "maturity_height" ];

        /*
          Remaining # of blocks until the commitment output can be swept.
          Negative values indicate how many blocks have passed since becoming
          mature.
        */
        int32 blocks_til_maturity = 5 [ json_name = "blocks_til_maturity" ];

        /// The total value of funds successfully recovered from this channel
        int64 recovered_balance = 6 [ json_name = "recovered_balance" ];

        repeated PendingHTLC pending_htlcs = 8 [ json_name = "pending_htlcs" ];
    }

    /// The balance in satoshis encumbered in pending channels
    int64 total_limbo_balance = 1 [ json_name = "total_limbo_balance" ];

    /// Channels pending opening
    repeated PendingOpenChannel pending_open_channels = 2 [ json_name = "pending_open_channels" ];

    /// Channels pending closing
    repeated ClosedChannel pending_closing_channels = 3 [ json_name = "pending_closing_channels" ];

    /// Channels pending force closing
    repeated ForceClosedChannel pending_force_closing_channels =  4 [ json_name = "pending_force_closing_channels" ];

    /// Channels waiting for closing tx to confirm
    repeated WaitingCloseChannel waiting_close_channels = 5 [ json_name = "waiting_close_channels" ];
}

message ChannelEventSubscription {
}

message ChannelEventUpdate {
    oneof channel {
        Channel open_channel = 1 [ json_name = "open_channel" ];
        ChannelCloseSummary closed_channel = 2 [ json_name = "closed_channel" ];
        ChannelPoint active_channel = 3 [ json_name = "active_channel" ];
        ChannelPoint inactive_channel = 4 [ json_name = "inactive_channel" ];
    }

    enum UpdateType {
         OPEN_CHANNEL = 0;
         CLOSED_CHANNEL = 1;
         ACTIVE_CHANNEL = 2;
         INACTIVE_CHANNEL = 3;
    }

    UpdateType type = 5 [ json_name = "type" ];
}

message WalletBalanceRequest {
}
message WalletBalanceResponse {
    /// The balance of the wallet
    int64 total_balance = 1 [json_name = "total_balance"];

    /// The confirmed balance of a wallet(with >= 1 confirmations)
    int64 confirmed_balance = 2 [json_name = "confirmed_balance"];

    /// The unconfirmed balance of a wallet(with 0 confirmations)
    int64 unconfirmed_balance = 3 [json_name = "unconfirmed_balance"];
}

message ChannelBalanceRequest {
}
message ChannelBalanceResponse {
    /// Sum of channels balances denominated in satoshis
    int64 balance = 1 [json_name = "balance"];

    /// Sum of channels pending balances denominated in satoshis
    int64 pending_open_balance = 2 [json_name = "pending_open_balance"];
}

message QueryRoutesRequest {
    /// The 33-byte hex-encoded public key for the payment destination
    string pub_key = 1;

    /// The amount to send expressed in satoshis
    int64 amt = 2;

    reserved 3;

    /// An optional CLTV delta from the current height that should be used for the timelock of the final hop
    int32 final_cltv_delta = 4;

    /**
    The maximum number of satoshis that will be paid as a fee of the payment.
    This value can be represented either as a percentage of the amount being
    sent, or as a fixed amount of the maximum fee the user is willing the pay to
    send the payment.
    */
    FeeLimit fee_limit = 5;

    /**
    A list of nodes to ignore during path finding.
    */
    repeated bytes ignored_nodes = 6;

    /**
    Deprecated. A list of edges to ignore during path finding.
    */
    repeated EdgeLocator ignored_edges = 7 [deprecated = true];

    /**
    The source node where the request route should originated from. If empty,
    self is assumed.
    */
    string source_pub_key = 8;

    /**
    If set to true, edge probabilities from mission control will be used to get
    the optimal route.
    */
    bool use_mission_control = 9;

    /**
    A list of directed node pairs that will be ignored during path finding.
    */
    repeated NodePair ignored_pairs = 10;

    /** 
    An optional field that can be used to pass an arbitrary set of TLV records
    to a peer which understands the new records. This can be used to pass
    application specific data during the payment attempt. If the destination
    does not support the specified recrods, and error will be returned.
    */
    map<uint64, bytes> dest_tlv = 11;
}

message NodePair {
    /// The sending node of the pair.
    bytes from = 1;

    /// The receiving node of the pair.
    bytes to = 2;
}

message EdgeLocator {
    /// The short channel id of this edge.
    uint64 channel_id = 1;

    /**
    The direction of this edge. If direction_reverse is false, the direction
    of this edge is from the channel endpoint with the lexicographically smaller
    pub key to the endpoint with the larger pub key. If direction_reverse is
    is true, the edge goes the other way.
    */
    bool direction_reverse = 2;
}

message QueryRoutesResponse {
    /**
    The route that results from the path finding operation. This is still a
    repeated field to retain backwards compatibility.
    */
    repeated Route routes = 1 [json_name = "routes"];

    /**
    The success probability of the returned route based on the current mission
    control state. [EXPERIMENTAL]
    */
    double success_prob = 2 [json_name = "success_prob"];
}

message Hop {
    /**
    The unique channel ID for the channel. The first 3 bytes are the block
    height, the next 3 the index within the block, and the last 2 bytes are the
    output index for the channel.
    */
    uint64 chan_id = 1 [json_name = "chan_id"];
    int64 chan_capacity = 2 [json_name = "chan_capacity"];
    int64 amt_to_forward = 3 [json_name = "amt_to_forward", deprecated = true];
    int64 fee = 4 [json_name = "fee", deprecated = true];
    uint32 expiry = 5 [json_name = "expiry"];
    int64 amt_to_forward_msat = 6 [json_name = "amt_to_forward_msat"];
    int64 fee_msat = 7 [json_name = "fee_msat"];

    /**
    An optional public key of the hop. If the public key is given, the payment
    can be executed without relying on a copy of the channel graph.
    */
    string pub_key = 8 [json_name = "pub_key"];

    /** 
    If set to true, then this hop will be encoded using the new variable length
    TLV format. Note that if any custom tlv_records below are specified, then
    this field MUST be set to true for them to be encoded properly.
    */
    bool tlv_payload = 9 [json_name = "tlv_payload"];

    /**
    An optional set of key-value TLV records. This is useful within the context
    of the SendToRoute call as it allows callers to specify arbitrary K-V pairs
    to drop off at each hop within the onion.
    */
    map<uint64, bytes> tlv_records = 10 [json_name = "tlv_records"];
}

/**
A path through the channel graph which runs over one or more channels in
succession. This struct carries all the information required to craft the
Sphinx onion packet, and send the payment along the first hop in the path. A
route is only selected as valid if all the channels have sufficient capacity to
carry the initial payment amount after fees are accounted for.
*/
message Route {

    /**
    The cumulative (final) time lock across the entire route.  This is the CLTV
    value that should be extended to the first hop in the route. All other hops
    will decrement the time-lock as advertised, leaving enough time for all
    hops to wait for or present the payment preimage to complete the payment.
    */
    uint32 total_time_lock = 1 [json_name = "total_time_lock"];

    /**
    The sum of the fees paid at each hop within the final route.  In the case
    of a one-hop payment, this value will be zero as we don't need to pay a fee
    to ourselves.
    */
    int64 total_fees = 2 [json_name = "total_fees", deprecated = true];

    /**
    The total amount of funds required to complete a payment over this route.
    This value includes the cumulative fees at each hop. As a result, the HTLC
    extended to the first-hop in the route will need to have at least this many
    satoshis, otherwise the route will fail at an intermediate node due to an
    insufficient amount of fees.
    */
    int64 total_amt = 3 [json_name = "total_amt", deprecated = true];

    /**
    Contains details concerning the specific forwarding details at each hop.
    */
    repeated Hop hops = 4 [json_name = "hops"];
    
    /**
    The total fees in millisatoshis.
    */
    int64 total_fees_msat = 5 [json_name = "total_fees_msat"];
    
    /**
    The total amount in millisatoshis.
    */
    int64 total_amt_msat = 6 [json_name = "total_amt_msat"];
}

message NodeInfoRequest {
    /// The 33-byte hex-encoded compressed public of the target node 
    string pub_key = 1;

    /// If true, will include all known channels associated with the node.
    bool include_channels = 2;
}

message NodeInfo {

    /**
    An individual vertex/node within the channel graph. A node is
    connected to other nodes by one or more channel edges emanating from it. As
    the graph is directed, a node will also have an incoming edge attached to
    it for each outgoing edge.
    */
    LightningNode node = 1 [json_name = "node"];

    /// The total number of channels for the node.
    uint32 num_channels = 2 [json_name = "num_channels"];

    /// The sum of all channels capacity for the node, denominated in satoshis.
    int64 total_capacity = 3 [json_name = "total_capacity"];

    /// A list of all public channels for the node.
    repeated ChannelEdge channels = 4 [json_name = "channels"];
}

/**
An individual vertex/node within the channel graph. A node is
connected to other nodes by one or more channel edges emanating from it. As the
graph is directed, a node will also have an incoming edge attached to it for
each outgoing edge.
*/
message LightningNode {
    uint32 last_update = 1 [ json_name = "last_update" ];
    string pub_key = 2 [ json_name = "pub_key" ];
    string alias = 3 [ json_name = "alias" ];
    repeated NodeAddress addresses = 4 [ json_name = "addresses" ];
    string color = 5 [ json_name = "color" ];
}

message NodeAddress {
    string network = 1 [ json_name = "network" ];
    string addr = 2 [ json_name = "addr" ];
}

message RoutingPolicy {
    uint32 time_lock_delta = 1 [json_name = "time_lock_delta"];
    int64 min_htlc = 2 [json_name = "min_htlc"];
    int64 fee_base_msat = 3 [json_name = "fee_base_msat"];
    int64 fee_rate_milli_msat = 4 [json_name = "fee_rate_milli_msat"];
    bool disabled = 5 [json_name = "disabled"];
    uint64 max_htlc_msat = 6 [json_name = "max_htlc_msat"];
    uint32 last_update = 7 [json_name = "last_update"];
}

/**
A fully authenticated channel along with all its unique attributes.
Once an authenticated channel announcement has been processed on the network,
then an instance of ChannelEdgeInfo encapsulating the channels attributes is
stored. The other portions relevant to routing policy of a channel are stored
within a ChannelEdgePolicy for each direction of the channel.
*/
message ChannelEdge {

    /**
    The unique channel ID for the channel. The first 3 bytes are the block
    height, the next 3 the index within the block, and the last 2 bytes are the
    output index for the channel.
    */
    uint64 channel_id = 1 [json_name = "channel_id"];
    string chan_point = 2 [json_name = "chan_point"];

    uint32 last_update = 3 [json_name = "last_update", deprecated = true];

    string node1_pub = 4 [json_name = "node1_pub"];
    string node2_pub = 5 [json_name = "node2_pub"];

    int64 capacity = 6 [json_name = "capacity"];

    RoutingPolicy node1_policy = 7 [json_name = "node1_policy"];
    RoutingPolicy node2_policy = 8 [json_name = "node2_policy"];
}

message ChannelGraphRequest {
     /**
     Whether unannounced channels are included in the response or not. If set,
     unannounced channels are included. Unannounced channels are both private
     channels, and public channels that are not yet announced to the network.
     */
     bool include_unannounced = 1 [json_name = "include_unannounced"];
}

/// Returns a new instance of the directed channel graph.
message ChannelGraph {
    /// The list of `LightningNode`s in this channel graph
    repeated LightningNode nodes = 1 [json_name = "nodes"];

    /// The list of `ChannelEdge`s in this channel graph
    repeated ChannelEdge edges = 2 [json_name = "edges"];
}

message ChanInfoRequest {
    /**
    The unique channel ID for the channel. The first 3 bytes are the block
    height, the next 3 the index within the block, and the last 2 bytes are the
    output index for the channel.
    */
    uint64 chan_id = 1;
}

message NetworkInfoRequest {
}
message NetworkInfo {
    uint32 graph_diameter = 1 [json_name = "graph_diameter"];
    double avg_out_degree = 2 [json_name = "avg_out_degree"];
    uint32 max_out_degree = 3 [json_name = "max_out_degree"];

    uint32 num_nodes = 4 [json_name = "num_nodes"];
    uint32 num_channels = 5 [json_name = "num_channels"];

    int64 total_network_capacity = 6 [json_name = "total_network_capacity"];

    double avg_channel_size = 7 [json_name = "avg_channel_size"];
    int64 min_channel_size = 8 [json_name = "min_channel_size"];
    int64 max_channel_size = 9 [json_name = "max_channel_size"];
    int64 median_channel_size_sat = 10 [json_name = "median_channel_size_sat"];

    // The number of edges marked as zombies.
    uint64 num_zombie_chans = 11 [json_name = "num_zombie_chans"];

    // TODO(roasbeef): fee rate info, expiry
    //  * also additional RPC for tracking fee info once in
}

message StopRequest{}
message StopResponse{}

message GraphTopologySubscription {}
message GraphTopologyUpdate {
    repeated NodeUpdate node_updates = 1;
    repeated ChannelEdgeUpdate channel_updates = 2;
    repeated ClosedChannelUpdate closed_chans = 3;
}
message NodeUpdate {
    repeated string addresses = 1;
    string identity_key = 2;
    bytes global_features = 3;
    string alias = 4;
    string color = 5;
}
message ChannelEdgeUpdate {
    /**
    The unique channel ID for the channel. The first 3 bytes are the block
    height, the next 3 the index within the block, and the last 2 bytes are the
    output index for the channel.
    */
    uint64 chan_id = 1;

    ChannelPoint chan_point = 2;

    int64 capacity = 3;

    RoutingPolicy routing_policy  = 4;

    string advertising_node  = 5;
    string connecting_node = 6;
}
message ClosedChannelUpdate {
    /**
    The unique channel ID for the channel. The first 3 bytes are the block
    height, the next 3 the index within the block, and the last 2 bytes are the
    output index for the channel.
    */
    uint64 chan_id = 1;
    int64 capacity = 2;
    uint32 closed_height = 3;
    ChannelPoint chan_point = 4;
}

message HopHint {
    /// The public key of the node at the start of the channel.
    string node_id = 1 [json_name = "node_id"];

    /// The unique identifier of the channel.
    uint64 chan_id = 2 [json_name = "chan_id"];

    /// The base fee of the channel denominated in millisatoshis.
    uint32 fee_base_msat = 3 [json_name = "fee_base_msat"];

    /**
    The fee rate of the channel for sending one satoshi across it denominated in
    millionths of a satoshi.
    */
    uint32 fee_proportional_millionths = 4 [json_name = "fee_proportional_millionths"];

    /// The time-lock delta of the channel.
    uint32 cltv_expiry_delta = 5 [json_name = "cltv_expiry_delta"];
}

message RouteHint {
    /**
    A list of hop hints that when chained together can assist in reaching a
    specific destination.
    */
    repeated HopHint hop_hints = 1 [json_name = "hop_hints"];
}

message Invoice {
    /**
    An optional memo to attach along with the invoice. Used for record keeping
    purposes for the invoice's creator, and will also be set in the description
    field of the encoded payment request if the description_hash field is not
    being used.
    */
    string memo = 1 [json_name = "memo"];

    /** Deprecated. An optional cryptographic receipt of payment which is not
    implemented.
    */
    bytes receipt = 2 [json_name = "receipt", deprecated = true];

    /**
    The hex-encoded preimage (32 byte) which will allow settling an incoming
    HTLC payable to this preimage
    */
    bytes r_preimage = 3 [json_name = "r_preimage"];

    /// The hash of the preimage
    bytes r_hash = 4 [json_name = "r_hash"];

    /// The value of this invoice in satoshis
    int64 value = 5 [json_name = "value"];

    /// Whether this invoice has been fulfilled
    bool settled = 6 [json_name = "settled", deprecated = true];

    /// When this invoice was created
    int64 creation_date = 7 [json_name = "creation_date"];

    /// When this invoice was settled
    int64 settle_date = 8 [json_name = "settle_date"];

    /**
    A bare-bones invoice for a payment within the Lightning Network.  With the
    details of the invoice, the sender has all the data necessary to send a
    payment to the recipient.
    */
    string payment_request = 9 [json_name = "payment_request"];

    /**
    Hash (SHA-256) of a description of the payment. Used if the description of
    payment (memo) is too long to naturally fit within the description field
    of an encoded payment request.
    */
    bytes description_hash = 10 [json_name = "description_hash"];

    /// Payment request expiry time in seconds. Default is 3600 (1 hour).
    int64 expiry = 11 [json_name = "expiry"];

    /// Fallback on-chain address.
    string fallback_addr = 12 [json_name = "fallback_addr"];

    /// Delta to use for the time-lock of the CLTV extended to the final hop.
    uint64 cltv_expiry = 13 [json_name = "cltv_expiry"];

    /**
    Route hints that can each be individually used to assist in reaching the
    invoice's destination.
    */
    repeated RouteHint route_hints = 14 [json_name = "route_hints"];

    /// Whether this invoice should include routing hints for private channels.
    bool private = 15 [json_name = "private"];

    /**
    The "add" index of this invoice. Each newly created invoice will increment
    this index making it monotonically increasing. Callers to the
    SubscribeInvoices call can use this to instantly get notified of all added
    invoices with an add_index greater than this one.
    */
    uint64 add_index = 16 [json_name = "add_index"];

    /**
    The "settle" index of this invoice. Each newly settled invoice will
    increment this index making it monotonically increasing. Callers to the
    SubscribeInvoices call can use this to instantly get notified of all
    settled invoices with an settle_index greater than this one.
    */
    uint64 settle_index = 17 [json_name = "settle_index"];

    /// Deprecated, use amt_paid_sat or amt_paid_msat.
    int64 amt_paid = 18 [json_name = "amt_paid", deprecated = true];

    /**
    The amount that was accepted for this invoice, in satoshis. This will ONLY
    be set if this invoice has been settled. We provide this field as if the
    invoice was created with a zero value, then we need to record what amount
    was ultimately accepted. Additionally, it's possible that the sender paid
    MORE that was specified in the original invoice. So we'll record that here
    as well.
    */
    int64 amt_paid_sat = 19 [json_name = "amt_paid_sat"];

    /**
    The amount that was accepted for this invoice, in millisatoshis. This will
    ONLY be set if this invoice has been settled. We provide this field as if
    the invoice was created with a zero value, then we need to record what
    amount was ultimately accepted. Additionally, it's possible that the sender
    paid MORE that was specified in the original invoice. So we'll record that
    here as well.
    */
    int64 amt_paid_msat = 20 [json_name = "amt_paid_msat"];

    enum InvoiceState {
        OPEN = 0;
        SETTLED = 1;
        CANCELED = 2;
        ACCEPTED = 3;
    }

    /**
    The state the invoice is in.
    */
    InvoiceState state = 21 [json_name = "state"];

    /// List of HTLCs paying to this invoice [EXPERIMENTAL].
    repeated InvoiceHTLC htlcs = 22 [json_name = "htlcs"];
}

enum InvoiceHTLCState {
    ACCEPTED = 0;
    SETTLED = 1;
    CANCELLED = 2;
}

/// Details of an HTLC that paid to an invoice
message InvoiceHTLC {
    /// Short channel id over which the htlc was received.
    uint64 chan_id = 1 [json_name = "chan_id"];

    /// Index identifying the htlc on the channel.
    uint64 htlc_index = 2 [json_name = "htlc_index"];

    /// The amount of the htlc in msat.
    uint64 amt_msat = 3 [json_name = "amt_msat"];

    /// Block height at which this htlc was accepted.
    int32 accept_height = 4 [json_name = "accept_height"];

    /// Time at which this htlc was accepted.
    int64 accept_time = 5 [json_name = "accept_time"];

    /// Time at which this htlc was settled or cancelled.
    int64 resolve_time = 6 [json_name = "resolve_time"];
    
    /// Block height at which this htlc expires.
    int32 expiry_height = 7 [json_name = "expiry_height"];

    /// Current state the htlc is in.
    InvoiceHTLCState state = 8 [json_name = "state"];
}

message AddInvoiceResponse {
    bytes r_hash = 1 [json_name = "r_hash"];

    /**
    A bare-bones invoice for a payment within the Lightning Network.  With the
    details of the invoice, the sender has all the data necessary to send a
    payment to the recipient.
    */
    string payment_request = 2 [json_name = "payment_request"];

    /**
    The "add" index of this invoice. Each newly created invoice will increment
    this index making it monotonically increasing. Callers to the
    SubscribeInvoices call can use this to instantly get notified of all added
    invoices with an add_index greater than this one.
    */
    uint64 add_index = 16 [json_name = "add_index"];
}
message PaymentHash {
    /**
    The hex-encoded payment hash of the invoice to be looked up. The passed
    payment hash must be exactly 32 bytes, otherwise an error is returned.
    */
    string r_hash_str = 1 [json_name = "r_hash_str"];

    /// The payment hash of the invoice to be looked up.
    bytes r_hash = 2 [json_name = "r_hash"];
}

message ListInvoiceRequest {
    /// If set, only unsettled invoices will be returned in the response.
    bool pending_only = 1 [json_name = "pending_only"];

    /**
    The index of an invoice that will be used as either the start or end of a
    query to determine which invoices should be returned in the response.
    */
    uint64 index_offset = 4 [json_name = "index_offset"];

    /// The max number of invoices to return in the response to this query.
    uint64 num_max_invoices = 5 [json_name = "num_max_invoices"];

    /**
    If set, the invoices returned will result from seeking backwards from the
    specified index offset. This can be used to paginate backwards.
    */
    bool reversed = 6 [json_name = "reversed"];
}
message ListInvoiceResponse {
    /**
    A list of invoices from the time slice of the time series specified in the
    request.
    */
    repeated Invoice invoices = 1 [json_name = "invoices"];

    /**
    The index of the last item in the set of returned invoices. This can be used
    to seek further, pagination style.
    */
    uint64 last_index_offset = 2 [json_name = "last_index_offset"];

    /**
    The index of the last item in the set of returned invoices. This can be used
    to seek backwards, pagination style.
    */
    uint64 first_index_offset = 3 [json_name = "first_index_offset"];
}

message InvoiceSubscription {
    /**
    If specified (non-zero), then we'll first start by sending out
    notifications for all added indexes with an add_index greater than this
    value. This allows callers to catch up on any events they missed while they
    weren't connected to the streaming RPC.
    */
    uint64 add_index = 1 [json_name = "add_index"];

    /**
    If specified (non-zero), then we'll first start by sending out
    notifications for all settled indexes with an settle_index greater than
    this value. This allows callers to catch up on any events they missed while
    they weren't connected to the streaming RPC.
    */
    uint64 settle_index = 2 [json_name = "settle_index"];
}


message Payment {
    /// The payment hash
    string payment_hash = 1 [json_name = "payment_hash"];

    /// Deprecated, use value_sat or value_msat.
    int64 value = 2 [json_name = "value", deprecated = true];

    /// The date of this payment
    int64 creation_date = 3 [json_name = "creation_date"];

    /// The path this payment took
    repeated string path = 4 [ json_name = "path" ];

    /// Deprecated, use fee_sat or fee_msat.
    int64 fee = 5 [json_name = "fee", deprecated = true];

    /// The payment preimage
    string payment_preimage = 6 [json_name = "payment_preimage"];

    /// The value of the payment in satoshis
    int64 value_sat = 7 [json_name = "value_sat"];

    /// The value of the payment in milli-satoshis
    int64 value_msat = 8 [json_name = "value_msat"];

    /// The optional payment request being fulfilled.
    string payment_request = 9 [json_name = "payment_request"];

    enum PaymentStatus {
        UNKNOWN = 0;
        IN_FLIGHT = 1;
        SUCCEEDED = 2;
        FAILED = 3;
    }

    // The status of the payment.
    PaymentStatus status = 10 [json_name = "status"];

    ///  The fee paid for this payment in satoshis
    int64 fee_sat = 11 [json_name = "fee_sat"];

    ///  The fee paid for this payment in milli-satoshis
    int64 fee_msat = 12 [json_name = "fee_msat"];
}

message ListPaymentsRequest {
    /**
    If true, then return payments that have not yet fully completed. This means
    that pending payments, as well as failed payments will show up if this
    field is set to True.
    */
    bool include_incomplete = 1;
}

message ListPaymentsResponse {
    /// The list of payments
    repeated Payment payments = 1 [json_name = "payments"];
}

message DeleteAllPaymentsRequest {
}

message DeleteAllPaymentsResponse {
}

message AbandonChannelRequest {
    ChannelPoint channel_point = 1;
}

message AbandonChannelResponse {
}


message DebugLevelRequest {
    bool show = 1;
    string level_spec = 2;
}
message DebugLevelResponse {
    string sub_systems = 1 [json_name = "sub_systems"];
}

message PayReqString {
    /// The payment request string to be decoded
    string pay_req = 1;
}
message PayReq {
    string destination = 1 [json_name = "destination"];
    string payment_hash = 2 [json_name = "payment_hash"];
    int64 num_satoshis = 3 [json_name = "num_satoshis"];
    int64 timestamp = 4 [json_name = "timestamp"];
    int64 expiry = 5 [json_name = "expiry"];
    string description = 6 [json_name = "description"];
    string description_hash = 7 [json_name = "description_hash"];
    string fallback_addr = 8 [json_name = "fallback_addr"];
    int64 cltv_expiry = 9 [json_name = "cltv_expiry"];
    repeated RouteHint route_hints = 10 [json_name = "route_hints"];
}

message FeeReportRequest {}
message ChannelFeeReport {
    /// The channel that this fee report belongs to.
    string chan_point = 1 [json_name = "channel_point"];

    /// The base fee charged regardless of the number of milli-satoshis sent.
    int64 base_fee_msat = 2 [json_name = "base_fee_msat"];

    /// The amount charged per milli-satoshis transferred expressed in millionths of a satoshi.
    int64 fee_per_mil = 3 [json_name = "fee_per_mil"];

    /// The effective fee rate in milli-satoshis. Computed by dividing the fee_per_mil value by 1 million.
    double fee_rate = 4 [json_name = "fee_rate"];
}
message FeeReportResponse {
    /// An array of channel fee reports which describes the current fee schedule for each channel.
    repeated ChannelFeeReport channel_fees = 1 [json_name = "channel_fees"];

    /// The total amount of fee revenue (in satoshis) the switch has collected over the past 24 hrs.
    uint64 day_fee_sum = 2 [json_name = "day_fee_sum"];

    /// The total amount of fee revenue (in satoshis) the switch has collected over the past 1 week.
    uint64 week_fee_sum = 3 [json_name = "week_fee_sum"];

    /// The total amount of fee revenue (in satoshis) the switch has collected over the past 1 month.
    uint64 month_fee_sum = 4 [json_name = "month_fee_sum"];
}

message PolicyUpdateRequest {
    oneof scope {
        /// If set, then this update applies to all currently active channels.
        bool global = 1 [json_name = "global"] ;

        /// If set, this update will target a specific channel.
        ChannelPoint chan_point = 2 [json_name = "chan_point"];
    }

    /// The base fee charged regardless of the number of milli-satoshis sent.
    int64 base_fee_msat = 3 [json_name = "base_fee_msat"];

    /// The effective fee rate in milli-satoshis. The precision of this value goes up to 6 decimal places, so 1e-6.
    double fee_rate = 4 [json_name = "fee_rate"];

    /// The required timelock delta for HTLCs forwarded over the channel.
    uint32 time_lock_delta = 5 [json_name = "time_lock_delta"];
}
message PolicyUpdateResponse {
}

message ForwardingHistoryRequest {
    /// Start time is the starting point of the forwarding history request. All records beyond this point will be included, respecting the end time, and the index offset.
    uint64 start_time = 1 [json_name = "start_time"];

    /// End time is the end point of the forwarding history request. The response will carry at most 50k records between the start time and the end time. The index offset can be used to implement pagination.
    uint64 end_time = 2 [json_name = "end_time"];

    /// Index offset is the offset in the time series to start at. As each response can only contain 50k records, callers can use this to skip around within a packed time series.
    uint32 index_offset = 3 [json_name = "index_offset"];

    /// The max number of events to return in the response to this query.
    uint32 num_max_events = 4 [json_name = "num_max_events"];
}
message ForwardingEvent {
    /// Timestamp is the time (unix epoch offset) that this circuit was completed.
    uint64 timestamp = 1 [json_name = "timestamp"];

    /// The incoming channel ID that carried the HTLC that created the circuit.
    uint64 chan_id_in = 2 [json_name = "chan_id_in"];

    /// The outgoing channel ID that carried the preimage that completed the circuit.
    uint64 chan_id_out = 4 [json_name = "chan_id_out"];

    /// The total amount (in satoshis) of the incoming HTLC that created half the circuit.
    uint64 amt_in = 5 [json_name = "amt_in"];

    /// The total amount (in satoshis) of the outgoing HTLC that created the second half of the circuit.
    uint64 amt_out = 6 [json_name = "amt_out"];

    /// The total fee (in satoshis) that this payment circuit carried.
    uint64 fee = 7 [json_name = "fee"];

    /// The total fee (in milli-satoshis) that this payment circuit carried.
    uint64 fee_msat = 8 [json_name = "fee_msat"];

    // TODO(roasbeef): add settlement latency?
    //  * use FPE on the chan id?
    //  * also list failures?
}
message ForwardingHistoryResponse {
   /// A list of forwarding events from the time slice of the time series specified in the request.
   repeated ForwardingEvent forwarding_events = 1 [json_name = "forwarding_events"];

   /// The index of the last time in the set of returned forwarding events. Can be used to seek further, pagination style.
   uint32 last_offset_index = 2 [json_name = "last_offset_index"];
}

message ExportChannelBackupRequest {
    /// The target channel point to obtain a back up for.
    ChannelPoint chan_point = 1;
}

message ChannelBackup {
    /**
    Identifies the channel that this backup belongs to.
    */
    ChannelPoint chan_point = 1 [ json_name = "chan_point" ];

    /**
    Is an encrypted single-chan backup. this can be passed to
    RestoreChannelBackups, or the WalletUnlocker Init and Unlock methods in
    order to trigger the recovery protocol.
    */
    bytes chan_backup = 2 [ json_name = "chan_backup" ];
}

message MultiChanBackup {
    /**
    Is the set of all channels that are included in this multi-channel backup.
    */
    repeated ChannelPoint chan_points = 1 [ json_name = "chan_points" ];

    /**
    A single encrypted blob containing all the static channel backups of the
    channel listed above. This can be stored as a single file or blob, and
    safely be replaced with any prior/future versions.
    */
    bytes multi_chan_backup = 2 [ json_name = "multi_chan_backup" ];
}

message ChanBackupExportRequest {}
message ChanBackupSnapshot  {
    /**
    The set of new channels that have been added since the last channel backup
    snapshot was requested.
    */
    ChannelBackups single_chan_backups = 1 [ json_name = "single_chan_backups" ];

    /**
    A multi-channel backup that covers all open channels currently known to
    lnd.
    */
    MultiChanBackup multi_chan_backup  = 2 [ json_name = "multi_chan_backup" ];
}

message ChannelBackups {
    /**
    A set of single-chan static channel backups.
    */
    repeated ChannelBackup chan_backups = 1 [ json_name = "chan_backups" ];
}

message RestoreChanBackupRequest {
    oneof backup {
        ChannelBackups chan_backups = 1 [ json_name = "chan_backups" ];

        bytes multi_chan_backup = 2 [ json_name = "multi_chan_backup" ];
    }
}
message RestoreBackupResponse {}

message ChannelBackupSubscription {}

message VerifyChanBackupResponse {
}

src:./wtclientrpc/wtclient.proto


syntax = "proto3";

package wtclientrpc;

option go_package = "github.com/lightningnetwork/lnd/lnrpc/wtclientrpc";

message AddTowerRequest {
    // The identifying public key of the watchtower to add.
    bytes pubkey = 1 [json_name = "pubkey"];

    // A network address the watchtower is reachable over.
    string address = 2 [json_name = "address"];
}

message AddTowerResponse {
}

message RemoveTowerRequest {
    // The identifying public key of the watchtower to remove.
    bytes pubkey = 1 [json_name = "pubkey"];

    /*
    If set, then the record for this address will be removed, indicating that is
    is stale. Otherwise, the watchtower will no longer be used for future
    session negotiations and backups.
    */
    string address = 2 [json_name = "address"];
}

message RemoveTowerResponse {
}

message GetTowerInfoRequest {
    // The identifying public key of the watchtower to retrieve information for.
    bytes pubkey = 1 [json_name = "pubkey"];

    // Whether we should include sessions with the watchtower in the response.
    bool include_sessions = 2 [json_name = "include_sessions"];
}

message TowerSession {
    /*
    The total number of successful backups that have been made to the
    watchtower session.
    */
    uint32 num_backups = 1 [json_name = "num_backups"];

    /*
    The total number of backups in the session that are currently pending to be
    acknowledged by the watchtower.
    */
    uint32 num_pending_backups = 2 [json_name = "num_pending_backups"];

    // The maximum number of backups allowed by the watchtower session.
    uint32 max_backups = 3 [json_name = "max_backups"];

    /*
    The fee rate, in satoshis per vbyte, that will be used by the watchtower for
    the justice transaction in the event of a channel breach.
    */
    uint32 sweep_sat_per_byte = 4 [json_name = "sweep_sat_per_byte"];
}

message Tower {
    // The identifying public key of the watchtower.
    bytes pubkey = 1 [json_name = "pubkey"];

    // The list of addresses the watchtower is reachable over.
    repeated string addresses = 2 [json_name = "addresses"];

    // Whether the watchtower is currently a candidate for new sessions.
    bool active_session_candidate = 3 [json_name = "active_session_candidate"];

    // The number of sessions that have been negotiated with the watchtower.
    uint32 num_sessions = 4 [json_name = "num_sessions"];

    // The list of sessions that have been negotiated with the watchtower.
    repeated TowerSession sessions = 5 [json_name = "sessions"];
}

message ListTowersRequest {
    // Whether we should include sessions with the watchtower in the response.
    bool include_sessions = 1 [json_name = "include_sessions"];
}

message ListTowersResponse {
    // The list of watchtowers available for new backups.
    repeated Tower towers = 1 [json_name = "towers"];
}

message StatsRequest {
}

message StatsResponse {
    /*
    The total number of backups made to all active and exhausted watchtower
    sessions.
    */
    uint32 num_backups = 1 [json_name = "num_backups"];

    /*
    The total number of backups that are pending to be acknowledged by all
    active and exhausted watchtower sessions.
    */
    uint32 num_pending_backups = 2 [json_name = "num_pending_backups"];

    /*
    The total number of backups that all active and exhausted watchtower
    sessions have failed to acknowledge.
    */
    uint32 num_failed_backups = 3 [json_name = "num_failed_backups"];

    // The total number of new sessions made to watchtowers.
    uint32 num_sessions_acquired = 4 [json_name = "num_sessions_acquired"];

    // The total number of watchtower sessions that have been exhausted.
    uint32 num_sessions_exhausted = 5 [json_name = "num_sessions_exhausted"];
}

message PolicyRequest {
}

message PolicyResponse {
    /*
    The maximum number of updates each session we negotiate with watchtowers
    should allow.
    */
    uint32 max_updates = 1 [json_name = "max_updates"];

    /*
    The fee rate, in satoshis per vbyte, that will be used by watchtowers for
    justice transactions in response to channel breaches.
    */
    uint32 sweep_sat_per_byte = 2 [json_name = "sweep_sat_per_byte"];
}

service WatchtowerClient {
    /*
    AddTower adds a new watchtower reachable at the given address and
    considers it for new sessions. If the watchtower already exists, then
    any new addresses included will be considered when dialing it for
    session negotiations and backups.
    */
    rpc AddTower(AddTowerRequest) returns (AddTowerResponse);

    /*
    RemoveTower removes a watchtower from being considered for future session
    negotiations and from being used for any subsequent backups until it's added
    again. If an address is provided, then this RPC only serves as a way of
    removing the address from the watchtower instead.
    */
    rpc RemoveTower(RemoveTowerRequest) returns (RemoveTowerResponse);

    // ListTowers returns the list of watchtowers registered with the client. 
    rpc ListTowers(ListTowersRequest) returns (ListTowersResponse);

    // GetTowerInfo retrieves information for a registered watchtower.
    rpc GetTowerInfo(GetTowerInfoRequest) returns (Tower);

    // Stats returns the in-memory statistics of the client since startup.
    rpc Stats(StatsRequest) returns (StatsResponse);

    // Policy returns the active watchtower client policy configuration.
    rpc Policy(PolicyRequest) returns (PolicyResponse);
}

src:./routerrpc/router.proto


syntax = "proto3";

import "rpc.proto";

package routerrpc;

option go_package = "github.com/lightningnetwork/lnd/lnrpc/routerrpc";

message SendPaymentRequest {
    /// The identity pubkey of the payment recipient
    bytes dest = 1;

    /// Number of satoshis to send.
    int64 amt = 2;

    /// The hash to use within the payment's HTLC
    bytes payment_hash = 3;
 
    /**
    The CLTV delta from the current height that should be used to set the
    timelock for the final hop.
    */
    int32 final_cltv_delta = 4;

    /**
    A bare-bones invoice for a payment within the Lightning Network.  With the
    details of the invoice, the sender has all the data necessary to send a
    payment to the recipient. The amount in the payment request may be zero. In
    that case it is required to set the amt field as well. If no payment request
    is specified, the following fields are required: dest, amt and payment_hash.
    */
    string payment_request = 5;

    /**
    An upper limit on the amount of time we should spend when attempting to
    fulfill the payment. This is expressed in seconds. If we cannot make a
    successful payment within this time frame, an error will be returned.
    This field must be non-zero.
    */
    int32 timeout_seconds = 6;

    /**
    The maximum number of satoshis that will be paid as a fee of the payment.
    If this field is left to the default value of 0, only zero-fee routes will
    be considered. This usually means single hop routes connecting directly to
    the destination. To send the payment without a fee limit, use max int here.
    */
    int64 fee_limit_sat = 7;

    /**
    The channel id of the channel that must be taken to the first hop. If zero,
    any channel may be used.
    */
    uint64 outgoing_chan_id = 8;

    /** 
    An optional maximum total time lock for the route. If zero, there is no
    maximum enforced.
    */
    int32 cltv_limit = 9;

    /**
    Optional route hints to reach the destination through private channels.
    */
    repeated lnrpc.RouteHint route_hints = 10 [json_name = "route_hints"];

    /** 
    An optional field that can be used to pass an arbitrary set of TLV records
    to a peer which understands the new records. This can be used to pass
    application specific data during the payment attempt.
    */
    map<uint64, bytes> dest_tlv = 11;
}

message TrackPaymentRequest {
    /// The hash of the payment to look up.
    bytes payment_hash = 1;
}

enum PaymentState {
    /**
    Payment is still in flight.
    */
    IN_FLIGHT = 0;

    /**
    Payment completed successfully.
    */
    SUCCEEDED = 1;

    /**
    There are more routes to try, but the payment timeout was exceeded.
    */
    FAILED_TIMEOUT = 2;
    
    /**
    All possible routes were tried and failed permanently. Or were no
    routes to the destination at all.
    */
    FAILED_NO_ROUTE = 3;

    /**
    A non-recoverable error has occured.
    */
    FAILED_ERROR = 4;

    /**
    Payment details incorrect (unknown hash, invalid amt or
    invalid final cltv delta)
    */
    FAILED_INCORRECT_PAYMENT_DETAILS = 5;
}


message PaymentStatus {
    /// Current state the payment is in.
    PaymentState state = 1;

    /**
    The pre-image of the payment when state is SUCCEEDED.
    */
    bytes preimage = 2;

    /**
    The taken route when state is SUCCEEDED.
    */
    lnrpc.Route route = 3;
}


message RouteFeeRequest {
    /**
    The destination once wishes to obtain a routing fee quote to.
    */
    bytes dest = 1;

    /**
    The amount one wishes to send to the target destination.
    */
    int64 amt_sat = 2;
}

message RouteFeeResponse {
    /**
    A lower bound of the estimated fee to the target destination within the
    network, expressed in milli-satoshis.
    */
    int64 routing_fee_msat = 1;

    /**
    An estimate of the worst case time delay that can occur. Note that callers
    will still need to factor in the final CLTV delta of the last hop into this
    value.
    */
    int64 time_lock_delay = 2;
}

message SendToRouteRequest {
    /// The payment hash to use for the HTLC.
    bytes payment_hash = 1;

    /// Route that should be used to attempt to complete the payment.
    lnrpc.Route route = 2;
}

message SendToRouteResponse {
    /// The preimage obtained by making the payment.
    bytes preimage = 1;

    /// The failure message in case the payment failed.
    Failure failure = 2;
}

message Failure {
    enum FailureCode {
        /**
        The numbers assigned in this enumeration match the failure codes as
        defined in BOLT #4. Because protobuf 3 requires enums to start with 0,
        a RESERVED value is added.
        */
        RESERVED = 0;

        INCORRECT_OR_UNKNOWN_PAYMENT_DETAILS = 1;
        INCORRECT_PAYMENT_AMOUNT = 2;
        FINAL_INCORRECT_CLTV_EXPIRY = 3;
        FINAL_INCORRECT_HTLC_AMOUNT = 4;
        FINAL_EXPIRY_TOO_SOON = 5;
        INVALID_REALM = 6;
        EXPIRY_TOO_SOON = 7;
        INVALID_ONION_VERSION = 8;
        INVALID_ONION_HMAC = 9;
        INVALID_ONION_KEY = 10;
        AMOUNT_BELOW_MINIMUM = 11;
        FEE_INSUFFICIENT = 12;
        INCORRECT_CLTV_EXPIRY = 13;
        CHANNEL_DISABLED = 14;
        TEMPORARY_CHANNEL_FAILURE = 15;
        REQUIRED_NODE_FEATURE_MISSING = 16;
        REQUIRED_CHANNEL_FEATURE_MISSING = 17;
        UNKNOWN_NEXT_PEER = 18;
        TEMPORARY_NODE_FAILURE = 19;
        PERMANENT_NODE_FAILURE = 20;
        PERMANENT_CHANNEL_FAILURE = 21;

        /**
        The error source is known, but the failure itself couldn't be decoded.
        */
        UNKNOWN_FAILURE = 998;

        /**
        An unreadable failure result is returned if the received failure message
        cannot be decrypted. In that case the error source is unknown.
        */
        UNREADABLE_FAILURE = 999;
    }

    /// Failure code as defined in the Lightning spec
    FailureCode code = 1;

    reserved 2;

    /// An optional channel update message.
    ChannelUpdate channel_update = 3;

    /// A failure type-dependent htlc value.
    uint64 htlc_msat = 4;

    /// The sha256 sum of the onion payload.
    bytes onion_sha_256 = 5;

    /// A failure type-dependent cltv expiry value.
    uint32 cltv_expiry = 6;

    /// A failure type-dependent flags value.
    uint32 flags = 7;

    /**
    The position in the path of the intermediate or final node that generated
    the failure message. Position zero is the sender node.
    **/
    uint32 failure_source_index = 8;
}


message ChannelUpdate {
    /**
    The signature that validates the announced data and proves the ownership
    of node id.
    */
    bytes signature = 1;

    /**
    The target chain that this channel was opened within. This value
    should be the genesis hash of the target chain. Along with the short
    channel ID, this uniquely identifies the channel globally in a
    blockchain.
    */
    bytes chain_hash = 2;

    /**
    The unique description of the funding transaction.
    */
    uint64 chan_id = 3;

    /**
    A timestamp that allows ordering in the case of multiple announcements.
    We should ignore the message if timestamp is not greater than the
    last-received.
    */
    uint32 timestamp = 4;

    /**
    The bitfield that describes whether optional fields are present in this
    update. Currently, the least-significant bit must be set to 1 if the
    optional field MaxHtlc is present.
    */
    uint32 message_flags = 10;

    /**
    The bitfield that describes additional meta-data concerning how the
    update is to be interpreted. Currently, the least-significant bit must be
    set to 0 if the creating node corresponds to the first node in the
    previously sent channel announcement and 1 otherwise. If the second bit
    is set, then the channel is set to be disabled.
    */
    uint32 channel_flags = 5;

    /**
    The minimum number of blocks this node requires to be added to the expiry
    of HTLCs. This is a security parameter determined by the node operator.
    This value represents the required gap between the time locks of the
    incoming and outgoing HTLC's set to this node.
    */
    uint32 time_lock_delta = 6;

    /**
    The minimum HTLC value which will be accepted.
    */
    uint64 htlc_minimum_msat = 7;

    /**
    The base fee that must be used for incoming HTLC's to this particular
    channel. This value will be tacked onto the required for a payment
    independent of the size of the payment.
    */
    uint32 base_fee = 8;

    /**
    The fee rate that will be charged per millionth of a satoshi.
    */
    uint32 fee_rate = 9;
    
    /**
    The maximum HTLC value which will be accepted.
    */
    uint64 htlc_maximum_msat = 11;
    
    /**
    The set of data that was appended to this message, some of which we may
    not actually know how to iterate or parse. By holding onto this data, we
    ensure that we're able to properly validate the set of signatures that
    cover these new fields, and ensure we're able to make upgrades to the
    network in a forwards compatible manner.
    */
    bytes extra_opaque_data = 12;
}
message ResetMissionControlRequest{}

message ResetMissionControlResponse{}

message QueryMissionControlRequest {}

/// QueryMissionControlResponse contains mission control state.
message QueryMissionControlResponse {
    /// Node-level mission control state.
    repeated NodeHistory nodes = 1 [json_name = "nodes"];

    /// Node pair-level mission control state.
    repeated PairHistory pairs = 2 [json_name = "pairs"];
}

/// NodeHistory contains the mission control state for a particular node.
message NodeHistory {
    /// Node pubkey
    bytes pubkey = 1 [json_name = "pubkey"];

    /// Time stamp of last failure. Set to zero if no failure happened yet.
    int64 last_fail_time = 2 [json_name = "last_fail_time"];

    /**
    Estimation of success probability of forwarding towards peers of this node
    for which no specific history is available.
    **/
    float other_success_prob = 3 [json_name = "other_success_prob"];

    reserved 4;
}

/// PairHistory contains the mission control state for a particular node pair.
message PairHistory {
    /// The source node pubkey of the pair.
    bytes node_from = 1 [json_name ="node_from"];
    
    /// The destination node pubkey of the pair.
    bytes node_to = 2 [json_name="node_to"];
    
    /// Time stamp of last result.
    int64 timestamp = 3 [json_name = "timestamp"];

    /// Minimum penalization amount (only applies to failed attempts).
    int64 min_penalize_amt_sat = 4 [json_name = "min_penalize_amt_sat"];

    /// Estimation of success probability for this pair.
    float success_prob = 5 [json_name = "success_prob"];

    /// Whether the last payment attempt through this pair was successful.
    bool last_attempt_successful = 6 [json_name = "last_attempt_successful"];
}

service Router {
    /**
    SendPayment attempts to route a payment described by the passed
    PaymentRequest to the final destination. The call returns a stream of
    payment status updates.
    */
    rpc SendPayment(SendPaymentRequest) returns (stream PaymentStatus);

    /**
    TrackPayment returns an update stream for the payment identified by the
    payment hash.
    */
    rpc TrackPayment(TrackPaymentRequest) returns (stream PaymentStatus);


    /**
    EstimateRouteFee allows callers to obtain a lower bound w.r.t how much it
    may cost to send an HTLC to the target end destination.
    */
    rpc EstimateRouteFee(RouteFeeRequest) returns (RouteFeeResponse);

    /**
    SendToRoute attempts to make a payment via the specified route. This method
    differs from SendPayment in that it allows users to specify a full route
    manually. This can be used for things like rebalancing, and atomic swaps.
    */
    rpc SendToRoute(SendToRouteRequest) returns (SendToRouteResponse);

    /**
    ResetMissionControl clears all mission control state and starts with a clean
    slate.
    */
    rpc ResetMissionControl(ResetMissionControlRequest) returns (ResetMissionControlResponse);
    
    /**
    QueryMissionControl exposes the internal mission control state to callers.
    It is a development feature.
    */
    rpc QueryMissionControl(QueryMissionControlRequest) returns (QueryMissionControlResponse);
}

src:./watchtowerrpc/watchtower.proto


syntax = "proto3";

package watchtowerrpc;

option go_package = "github.com/lightningnetwork/lnd/lnrpc/watchtowerrpc";

service Watchtower {
        /** lncli: tower info
        GetInfo returns general information concerning the companion watchtower
        including it's public key and URIs where the server is currently
        listening for clients.
        */
        rpc GetInfo(GetInfoRequest) returns (GetInfoResponse);
}

message GetInfoRequest{
}

message GetInfoResponse {
        /// The public key of the watchtower.
        bytes pubkey = 1 [json_name = "pubkey"];

        /// The listening addresses of the watchtower.
        repeated string listeners = 2 [json_name = "listeners"];

        /// The URIs of the watchtower.
        repeated string uris = 3 [json_name = "uris" ];
}

src:./signrpc/signer.proto


syntax = "proto3";

package signrpc;

option go_package = "github.com/lightningnetwork/lnd/lnrpc/signrpc";

message KeyLocator {
    /// The family of key being identified.
    int32 key_family = 1;

    /// The precise index of the key being identified.
    int32 key_index = 2;
}

message KeyDescriptor {
     /**
     The raw bytes of the key being identified. Either this or the KeyLocator
     must be specified.
     */
     bytes raw_key_bytes = 1;

     /** 
     The key locator that identifies which key to use for signing. Either this
     or the raw bytes of the target key must be specified.
     */
     KeyLocator key_loc = 2;
}

message TxOut {
    /// The value of the output being spent.
    int64 value = 1;

    /// The script of the output being spent.
    bytes pk_script = 2;
}

message SignDescriptor {
    /**
    A descriptor that precisely describes *which* key to use for signing. This
    may provide the raw public key directly, or require the Signer to re-derive
    the key according to the populated derivation path.
    */
    KeyDescriptor key_desc = 1;

    /**
    A scalar value that will be added to the private key corresponding to the
    above public key to obtain the private key to be used to sign this input.
    This value is typically derived via the following computation:

      * derivedKey = privkey + sha256(perCommitmentPoint || pubKey) mod N
    */
    bytes single_tweak = 2;

    /**
    A private key that will be used in combination with its corresponding
    private key to derive the private key that is to be used to sign the target
    input. Within the Lightning protocol, this value is typically the
    commitment secret from a previously revoked commitment transaction. This
    value is in combination with two hash values, and the original private key
    to derive the private key to be used when signing.
   
     * k = (privKey*sha256(pubKey || tweakPub) +
           tweakPriv*sha256(tweakPub || pubKey)) mod N
    */
    bytes double_tweak = 3;

    /**
    The full script required to properly redeem the output.  This field will
    only be populated if a p2wsh or a p2sh output is being signed.
    */
    bytes witness_script = 4;

    /**
    A description of the output being spent. The value and script MUST be provided.
    */
    TxOut output = 5;

    /**
    The target sighash type that should be used when generating the final
    sighash, and signature.
    */
    uint32 sighash = 7;

    /**
    The target input within the transaction that should be signed.
    */
    int32 input_index = 8;
}

message SignReq {
    /// The raw bytes of the transaction to be signed.
    bytes raw_tx_bytes = 1;

    /// A set of sign descriptors, for each input to be signed.
    repeated SignDescriptor sign_descs = 2;
}

message SignResp {
    /**
    A set of signatures realized in a fixed 64-byte format ordered in ascending
    input order.
    */
    repeated bytes raw_sigs = 1;
}

message InputScript {
    /// The serializes witness stack for the specified input.
    repeated bytes witness = 1;

    /***
    The optional sig script for the specified witness that will only be set if
    the input specified is a nested p2sh witness program.
    */
    bytes sig_script = 2;
}

message InputScriptResp {
    /// The set of fully valid input scripts requested.
    repeated InputScript input_scripts = 1;
}

service Signer {
    /**
    SignOutputRaw is a method that can be used to generated a signature for a
    set of inputs/outputs to a transaction. Each request specifies details
    concerning how the outputs should be signed, which keys they should be
    signed with, and also any optional tweaks. The return value is a fixed
    64-byte signature (the same format as we use on the wire in Lightning). 
    
    If we are  unable to sign using the specified keys, then an error will be
    returned.
    */
    rpc SignOutputRaw(SignReq) returns (SignResp);

    /**
    ComputeInputScript generates a complete InputIndex for the passed
    transaction with the signature as defined within the passed SignDescriptor.
    This method should be capable of generating the proper input script for
    both regular p2wkh output and p2wkh outputs nested within a regular p2sh
    output.

    Note that when using this method to sign inputs belonging to the wallet,
    the only items of the SignDescriptor that need to be populated are pkScript
    in the TxOut field, the value in that same field, and finally the input
    index.
    */
    rpc ComputeInputScript(SignReq) returns (InputScriptResp); 
}