LND API手册

gRPC API
GenSeed - 生成加密种子 InitWallet - 初始化钱包 UnlockWallet - 解锁钱包 ChangePassword - 修改钱包密码 WalletBalance - 查询钱包余额 ChannelBalance - 查询通道余额 GetTransactions - 查询钱包交易 EstimateFee - 估算交易手续费 SendCoins - 单址转账 ListUnspent - 查询钱包UTXO SubscribeTransactions - 订阅交易事件 SendMany - 多址转账 NewAddress - 生成新地址 SignMessage - 生成消息签名 VerifyMessage - 验证消息签名 ConnectPeer - 连接对端节点 DisconnectPeer - 断开对端节点的连接 ListPeers - 查询对端节点 GetInfo - 查询节点信息 PendingChannels - 查询待确认通道 ListChannels - 查询已开启通道 SubscribeChannelEvents - 订阅通道事件 ClosedChannels - 查询已关闭通道 OpenChannelSync - 同步开启通道 OpenChannel - 开启通道 CloseChannel - 关闭通道 AbandonChannel - 启用通道 SendPayment - 发送支付 SendPaymentSync - 同步支付 SendToRoute - 指定路由支付 SendToRouteSync - 指定路由同步支付 AddInvoice - 添加发票 ListInvoices - 返回发票清单 LookupInvoice - 查询发票 SubscribeInvoices - 订阅发票 DecodePayReq - 解码支付请求 ListPayments - 返回支付清单 DeleteAllPayments - 删除所有支付 DescribeGraph - 返回图描述 GetChanInfo - 获取通道信息 GetNodeInfo - 获取节点信息 QueryRoutes - 查询路径 GetNetworkInfo - 获取支付网络信息 StopDaemon - 停止后台服务 SubscribeChannelGraph - 订阅通道图事件 DebugLevel - 设置调试等级 FeeReport - 获取手续费报告 UpdateChannelPolicy - 更新通道政策 ForwardingHistory - 查询转发历史 ExportChannelBackup - 导出通道备份 ExportAllChannelBackups - 导出所有通道的备份 VerifyChanBackup - 验证通道备份完整性 RestoreChannelBackups - 恢复通道备份 SubscribeChannelBackups - 订阅通道备份
Messages
OpenStatusUpdate ChannelEventSubscription ChannelPoint GraphTopologySubscription UnlockWalletResponse ChannelOpenUpdate ChannelGraph ListInvoiceResponse VerifyChanBackupResponse EdgeLocator ForwardingHistoryRequest ClosedChannelUpdate HopHint Route ListPaymentsResponse HTLC FeeLimit StopResponse Peer ChangePasswordResponse ListINvoiceRequest SendCoinsRequest ForwardingEvent NetworkInfoRequest ForwardingHistoryResponse WalletBalanceResponse ListChannelsResponse ChangePasswordRequest Channel DeleteAllPaymentsResponse SendCoinsResponse MultiChanBackup GetInfoResponse ChannelBackup DeleteAllPaymentsRequest Transaction QueryRoutesRequest VerifyMessageResponse ChannelGraphRequest SendRequest FeeReportResponse ForceClosedChannel OutPoint LightningAddress Hop PolicyUpdateResponse SignMessageResponse EstimateFeeResponse AddInvoiceResponse Invoice InitWalletResponse ListUnspentResponse DisconnectPeerResponse ChannelCloseSummary SignMessageRequest NodeInfo NodeUpdate ListPeersRequest ClosedChannelsResponse StopRequest PayReqString SendManyResponse ChannelBackupSubscription Payment GenSeedRequest ConfirmationUpdate CloseStatusUpdate GetTransactionsRequest SendToRouteRequest Chain QueryRoutesResponse PaymentHash SendResponse DebugLevelResponse AbandonChannelResponse ChanBackupExportRequest ChannelCloseUpdate PendingChannel Utxo DebugLevelRequest PendingHTLC UnlockWalletRequest SendManyRequest PayReq PendingChannelsRequest RestoreChanBackupRequest ExportChannelBackupRequest ChannelBackups ChannelEdgeUpdate ClosedChannel CLoseChannelRequest OpenChannelRequest ChannelEventUpdate ChanInfoRequest ConnectPeerResponse NewAddressRequest ListPeersResponse ListChannelsRequest EstimateFeeRequest LightningNode WaitingCloseChannel PendingOpenChannel NewAddressResponse ChannelBalanceResponse ChanBackupSnapshot TransactionDetails PendingChannelsResponse ChannelEdge ConnectPeerRequest PendingUpdate RestoreBackupResponse DisconnectPeerRequest ClosedChannelsRequest InvoiceSubscription RouteHint NodeInfoRequest AddrToAmountEntry FeeReportRequest NetworkInfo ListPaymentsRequest AbandonChannelRequest GetInfoRequest GraphTopologyUpdate InitWalletRequest VerifyMessageRequest ChannelFeeReport PolicyUpdateRequest GenSeedResponse ChannelBalanceRequest NodeAddress WalletBalanceRequest RoutingPolicy ListUnspentRequest
Enums
ClosureType SyncType InvoiceState PyamentStatus UpdateType AddressType
在线工具推荐: Three.js AI纹理开发包 - YOLO合成数据生成器 - GLTF/GLB在线编辑 - 3D模型格式在线转换 - 可编程3D场景编辑器

ClosedChannels - 查询已关闭通道

OpenChannelSync 是OpenChannel调用的同步版本。该调用主要用于客户端通过REST代理的调用。和其他所有 的同步调用一样,所有的字节片段都使用16进制编码字符串。

gRPC请求 - OpenChannelRequest

字段如下:

  • node_pubkey bytes:节点用于开启通道的公钥
  • node_pubkey_string:节点用于开启通道的公钥的16进制编码表示
  • local_funding_amount:钱包需要提交给通道的satoshi数量, int64
  • push_sat:需要推送给远端作为初始提交状态的一部分的satoshi数量,int64
  • target_conf:存款交易的目标确认数, int32
  • sat_per_byte:手工设置的手续费费率,int64 ,单位sat/byte
  • private: 通道是否为私有,bool
  • min_htlc_msat:通道接收的HTLC最小值 ,int64 ,单位:millisatoshi
  • remote_csv_delay:远端交易提交的延时要求, uint32 ,如果未设置的话,则自动匹配通道尺寸
  • min_confs:用作交易输入的utxo的最小确认数, int32
  • spend_unconfirmed:是否允许使用未确认的utxo作为交易输入, bool

gRPC响应 - ChannelPoint

字段如下:

  • funding_txid_bytes: 存款交易的ID, bytes
  • funding_txid_str:存款交易ID的16进制字符串表示
  • output_index: 存款交易的输出索引, uint32

示例代码

Python示例代码

>>> import codecs, grpc, os
>>> import rpc_pb2 as ln, rpc_pb2_grpc as lnrpc
>>> macaroon = codecs.encode(open('LND_DIR/data/chain/bitcoin/simnet/admin.macaroon', 'rb').read(), 'hex')
>>> os.environ['GRPC_SSL_CIPHER_SUITES'] = 'HIGH+ECDSA'
>>> cert = open('LND_DIR/tls.cert', 'rb').read()
>>> ssl_creds = grpc.ssl_channel_credentials(cert)
>>> channel = grpc.secure_channel('localhost:10009', ssl_creds)
>>> stub = lnrpc.LightningStub(channel)
>>> request = ln.OpenChannelRequest(
        node_pubkey=<bytes>,
        node_pubkey_string=<string>,
        local_funding_amount=<int64>,
        push_sat=<int64>,
        target_conf=<int32>,
        sat_per_byte=<int64>,
        private=<bool>,
        min_htlc_msat=<int64>,
        remote_csv_delay=<uint32>,
        min_confs=<int32>,
        spend_unconfirmed=<bool>,
    )
>>> response = stub.OpenChannelSync(request)
>>> print(response)
{ 
    "funding_txid_bytes": <bytes>,
    "funding_txid_str": <string>,
    "output_index": <uint32>,
}

JavaScript示例代码

> var fs = require('fs');
> var grpc = require('grpc');
> var lnrpc = grpc.load('rpc.proto').lnrpc;
> process.env.GRPC_SSL_CIPHER_SUITES = 'HIGH+ECDSA'
> var lndCert = fs.readFileSync('LND_DIR/tls.cert');
> var sslCreds = grpc.credentials.createSsl(lndCert);
> var macaroonCreds = grpc.credentials.createFromMetadataGenerator(function(args, callback) {
    var macaroon = fs.readFileSync("LND_DIR/data/chain/bitcoin/simnet/admin.macaroon").toString('hex');
    var metadata = new grpc.Metadata()
    metadata.add('macaroon', macaroon);
    callback(null, metadata);
  });
> var creds = grpc.credentials.combineChannelCredentials(sslCreds, macaroonCreds);
> var lightning = new lnrpc.Lightning('localhost:10009', creds);
> var request = { 
    node_pubkey: <bytes>, 
    node_pubkey_string: <string>, 
    local_funding_amount: <int64>, 
    push_sat: <int64>, 
    target_conf: <int32>, 
    sat_per_byte: <int64>, 
    private: <bool>, 
    min_htlc_msat: <int64>, 
    remote_csv_delay: <uint32>, 
    min_confs: <int32>, 
    spend_unconfirmed: <bool>, 
  } 
> lightning.openChannelSync(request, function(err, response) {
    console.log(response);
  })
{ 
    "funding_txid_bytes": <bytes>,
    "funding_txid_str": <string>,
    "output_index": <uint32>,
}