1188fd2bf6
This commit adds the necessary plumbing within the server, peer, and rpcServer to handle opening and cooperatively closing a channel with a remote peer. Many new data structures have been added to the peer in order to allow it to efficiently manage opening+.losing new/existing lightning channels. Additional documentation has been added to several methods within the peer struct, with some minor renaming along with way. The peer has also gained a dedicated goroutine whose job it is to manage any requests pertaining to opening, or closing any channels with the remote peer. The messages have been added to lnrpc define the requests and responses to channel open+close messages. Additional channel logic has been added between the rpcServer, peer, and server in order to properly manage the necessary synchronization.
132 lines
2.5 KiB
Protocol Buffer
132 lines
2.5 KiB
Protocol Buffer
syntax = "proto3";
|
|
|
|
package lnrpc;
|
|
|
|
service Lightning {
|
|
rpc SendMany(SendManyRequest) returns (SendManyResponse);
|
|
|
|
rpc NewAddress(NewAddressRequest) returns (NewAddressResponse);
|
|
|
|
rpc ConnectPeer(ConnectPeerRequest) returns (ConnectPeerResponse);
|
|
rpc ListPeers(ListPeersRequest) returns (ListPeersResponse);
|
|
|
|
rpc OpenChannel(OpenChannelRequest) returns (OpenChannelResponse);
|
|
rpc CloseChannel(CloseChannelRequest) returns (CloseChannelResponse);
|
|
|
|
rpc WalletBalance(WalletBalanceRequest) returns (WalletBalanceResponse);
|
|
}
|
|
|
|
message ChannelPoint {
|
|
bytes funding_txid = 1;
|
|
uint32 output_index = 2;
|
|
}
|
|
|
|
message LightningAddress {
|
|
string pubKeyHash = 1;
|
|
string host = 2;
|
|
}
|
|
|
|
message SendManyRequest {
|
|
map<string, int64> AddrToAmount = 1;
|
|
}
|
|
message SendManyResponse {
|
|
string txid = 1;
|
|
}
|
|
|
|
message NewAddressRequest {
|
|
enum AddressType {
|
|
WITNESS_PUBKEY_HASH = 0;
|
|
NESTED_PUBKEY_HASH = 1;
|
|
PUBKEY_HASH = 2;
|
|
}
|
|
|
|
AddressType type = 1;
|
|
}
|
|
message NewAddressResponse {
|
|
string address = 1;
|
|
}
|
|
|
|
message ConnectPeerRequest {
|
|
LightningAddress addr = 1;
|
|
}
|
|
message ConnectPeerResponse {
|
|
int32 peer_id = 1;
|
|
}
|
|
|
|
message HTLC {
|
|
int64 id = 1;
|
|
|
|
int64 amount = 2;
|
|
|
|
bytes hash_lock = 3;
|
|
|
|
bool to_us = 4;
|
|
}
|
|
|
|
message ActiveChannel {
|
|
bytes funding_txid = 1;
|
|
|
|
int64 capacity = 2;
|
|
int64 local_balance = 3;
|
|
int64 remote_balance = 4;
|
|
|
|
int64 unsettled_belance = 5;
|
|
repeated HTLC pending_htlcs = 6;
|
|
|
|
int64 num_updates = 7;
|
|
// TODO(roasbeef): other stuffs
|
|
}
|
|
|
|
message Peer {
|
|
string lightning_id = 1;
|
|
int32 peer_id = 2;
|
|
string address = 3;
|
|
|
|
uint64 bytes_sent = 4;
|
|
uint64 bytes_recv = 5;
|
|
|
|
int64 sat_sent = 6;
|
|
int64 sat_recv = 7;
|
|
|
|
bool inbound = 8;
|
|
|
|
// TODO(roasbeef): add pending channels
|
|
repeated ActiveChannel channels = 9;
|
|
}
|
|
|
|
message ListPeersRequest {}
|
|
message ListPeersResponse {
|
|
repeated Peer peers = 1;
|
|
}
|
|
|
|
message OpenChannelRequest {
|
|
int32 target_peer_id = 1;
|
|
LightningAddress target_node = 2;
|
|
|
|
int64 local_funding_amount = 3;
|
|
int64 remote_funding_amount = 4;
|
|
|
|
int64 commission_size = 5;
|
|
|
|
uint32 num_confs = 6;
|
|
}
|
|
message OpenChannelResponse {
|
|
ChannelPoint channel_point = 1;
|
|
}
|
|
|
|
message CloseChannelRequest {
|
|
ChannelPoint channel_point = 1;
|
|
int64 time_limit = 2;
|
|
bool allow_force_close = 3;
|
|
}
|
|
message CloseChannelResponse {
|
|
bool success = 1;
|
|
}
|
|
|
|
message WalletBalanceRequest {
|
|
bool witness_only = 1;
|
|
}
|
|
message WalletBalanceResponse {
|
|
double balance = 1;
|
|
}
|