mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-20 23:54:22 +01:00
pylightning: Reorder LightningRpc methods alphabetically
This commit is contained in:
committed by
Christian Decker
parent
b4e7b198e6
commit
efecd64bf3
@@ -284,273 +284,6 @@ class LightningRpc(UnixDomainSocketRpc):
|
|||||||
def __init__(self, socket_path, executor=None, logger=logging):
|
def __init__(self, socket_path, executor=None, logger=logging):
|
||||||
super().__init__(socket_path, executor, logging, self.LightningJSONEncoder, self.LightningJSONDecoder())
|
super().__init__(socket_path, executor, logging, self.LightningJSONEncoder, self.LightningJSONDecoder())
|
||||||
|
|
||||||
def getpeer(self, peer_id, level=None):
|
|
||||||
"""
|
|
||||||
Show peer with {peer_id}, if {level} is set, include {log}s
|
|
||||||
"""
|
|
||||||
payload = {
|
|
||||||
"id": peer_id,
|
|
||||||
"level": level
|
|
||||||
}
|
|
||||||
res = self.call("listpeers", payload)
|
|
||||||
return res.get("peers") and res["peers"][0] or None
|
|
||||||
|
|
||||||
def listnodes(self, node_id=None):
|
|
||||||
"""
|
|
||||||
Show all nodes in our local network view, filter on node {id}
|
|
||||||
if provided
|
|
||||||
"""
|
|
||||||
payload = {
|
|
||||||
"id": node_id
|
|
||||||
}
|
|
||||||
return self.call("listnodes", payload)
|
|
||||||
|
|
||||||
def getroute(self, node_id, msatoshi, riskfactor, cltv=9, fromid=None, fuzzpercent=None, exclude=[], maxhops=20):
|
|
||||||
"""
|
|
||||||
Show route to {id} for {msatoshi}, using {riskfactor} and optional
|
|
||||||
{cltv} (default 9). If specified search from {fromid} otherwise use
|
|
||||||
this node as source. Randomize the route with up to {fuzzpercent}
|
|
||||||
(0.0 -> 100.0, default 5.0). {exclude} is an optional array of
|
|
||||||
scid/direction to exclude. Limit the number of hops in the route to
|
|
||||||
{maxhops}.
|
|
||||||
"""
|
|
||||||
payload = {
|
|
||||||
"id": node_id,
|
|
||||||
"msatoshi": msatoshi,
|
|
||||||
"riskfactor": riskfactor,
|
|
||||||
"cltv": cltv,
|
|
||||||
"fromid": fromid,
|
|
||||||
"fuzzpercent": fuzzpercent,
|
|
||||||
"exclude": exclude,
|
|
||||||
"maxhops": maxhops
|
|
||||||
}
|
|
||||||
return self.call("getroute", payload)
|
|
||||||
|
|
||||||
def listchannels(self, short_channel_id=None, source=None):
|
|
||||||
"""
|
|
||||||
Show all known channels, accept optional {short_channel_id} or {source}
|
|
||||||
"""
|
|
||||||
payload = {
|
|
||||||
"short_channel_id": short_channel_id,
|
|
||||||
"source": source
|
|
||||||
}
|
|
||||||
return self.call("listchannels", payload)
|
|
||||||
|
|
||||||
def invoice(self, msatoshi, label, description, expiry=None, fallbacks=None, preimage=None, exposeprivatechannels=None):
|
|
||||||
"""
|
|
||||||
Create an invoice for {msatoshi} with {label} and {description} with
|
|
||||||
optional {expiry} seconds (default 1 hour)
|
|
||||||
"""
|
|
||||||
payload = {
|
|
||||||
"msatoshi": msatoshi,
|
|
||||||
"label": label,
|
|
||||||
"description": description,
|
|
||||||
"expiry": expiry,
|
|
||||||
"fallbacks": fallbacks,
|
|
||||||
"preimage": preimage,
|
|
||||||
"exposeprivatechannels": exposeprivatechannels
|
|
||||||
}
|
|
||||||
return self.call("invoice", payload)
|
|
||||||
|
|
||||||
def listinvoices(self, label=None):
|
|
||||||
"""
|
|
||||||
Show invoice {label} (or all, if no {label))
|
|
||||||
"""
|
|
||||||
payload = {
|
|
||||||
"label": label
|
|
||||||
}
|
|
||||||
return self.call("listinvoices", payload)
|
|
||||||
|
|
||||||
def delinvoice(self, label, status):
|
|
||||||
"""
|
|
||||||
Delete unpaid invoice {label} with {status}
|
|
||||||
"""
|
|
||||||
payload = {
|
|
||||||
"label": label,
|
|
||||||
"status": status
|
|
||||||
}
|
|
||||||
return self.call("delinvoice", payload)
|
|
||||||
|
|
||||||
def delexpiredinvoice(self, maxexpirytime=None):
|
|
||||||
"""
|
|
||||||
Delete all invoices that have expired on or before the given {maxexpirytime}
|
|
||||||
"""
|
|
||||||
payload = {
|
|
||||||
"maxexpirytime": maxexpirytime
|
|
||||||
}
|
|
||||||
return self.call("delexpiredinvoice", payload)
|
|
||||||
|
|
||||||
def waitanyinvoice(self, lastpay_index=None):
|
|
||||||
"""
|
|
||||||
Wait for the next invoice to be paid, after {lastpay_index}
|
|
||||||
(if supplied)
|
|
||||||
"""
|
|
||||||
payload = {
|
|
||||||
"lastpay_index": lastpay_index
|
|
||||||
}
|
|
||||||
return self.call("waitanyinvoice", payload)
|
|
||||||
|
|
||||||
def waitinvoice(self, label):
|
|
||||||
"""
|
|
||||||
Wait for an incoming payment matching the invoice with {label}
|
|
||||||
"""
|
|
||||||
payload = {
|
|
||||||
"label": label
|
|
||||||
}
|
|
||||||
return self.call("waitinvoice", payload)
|
|
||||||
|
|
||||||
def decodepay(self, bolt11, description=None):
|
|
||||||
"""
|
|
||||||
Decode {bolt11}, using {description} if necessary
|
|
||||||
"""
|
|
||||||
payload = {
|
|
||||||
"bolt11": bolt11,
|
|
||||||
"description": description
|
|
||||||
}
|
|
||||||
return self.call("decodepay", payload)
|
|
||||||
|
|
||||||
def help(self, command=None):
|
|
||||||
"""
|
|
||||||
Show available commands, or just {command} if supplied.
|
|
||||||
"""
|
|
||||||
payload = {
|
|
||||||
"command": command,
|
|
||||||
}
|
|
||||||
return self.call("help", payload)
|
|
||||||
|
|
||||||
def stop(self):
|
|
||||||
"""
|
|
||||||
Shut down the lightningd process
|
|
||||||
"""
|
|
||||||
return self.call("stop")
|
|
||||||
|
|
||||||
def getlog(self, level=None):
|
|
||||||
"""
|
|
||||||
Show logs, with optional log {level} (info|unusual|debug|io)
|
|
||||||
"""
|
|
||||||
payload = {
|
|
||||||
"level": level
|
|
||||||
}
|
|
||||||
return self.call("getlog", payload)
|
|
||||||
|
|
||||||
def dev_rhash(self, secret):
|
|
||||||
"""
|
|
||||||
Show SHA256 of {secret}
|
|
||||||
"""
|
|
||||||
payload = {
|
|
||||||
"secret": secret
|
|
||||||
}
|
|
||||||
return self.call("dev-rhash", payload)
|
|
||||||
|
|
||||||
def dev_crash(self):
|
|
||||||
"""
|
|
||||||
Crash lightningd by calling fatal()
|
|
||||||
"""
|
|
||||||
return self.call("dev-crash")
|
|
||||||
|
|
||||||
def dev_query_scids(self, id, scids):
|
|
||||||
"""
|
|
||||||
Ask peer for a particular set of scids
|
|
||||||
"""
|
|
||||||
payload = {
|
|
||||||
"id": id,
|
|
||||||
"scids": scids
|
|
||||||
}
|
|
||||||
return self.call("dev-query-scids", payload)
|
|
||||||
|
|
||||||
def getinfo(self):
|
|
||||||
"""
|
|
||||||
Show information about this node
|
|
||||||
"""
|
|
||||||
return self.call("getinfo")
|
|
||||||
|
|
||||||
def sendpay(self, route, payment_hash, description=None, msatoshi=None):
|
|
||||||
"""
|
|
||||||
Send along {route} in return for preimage of {payment_hash}
|
|
||||||
"""
|
|
||||||
payload = {
|
|
||||||
"route": route,
|
|
||||||
"payment_hash": payment_hash,
|
|
||||||
"description": description,
|
|
||||||
"msatoshi": msatoshi,
|
|
||||||
}
|
|
||||||
return self.call("sendpay", payload)
|
|
||||||
|
|
||||||
def waitsendpay(self, payment_hash, timeout=None):
|
|
||||||
"""
|
|
||||||
Wait for payment for preimage of {payment_hash} to complete
|
|
||||||
"""
|
|
||||||
payload = {
|
|
||||||
"payment_hash": payment_hash,
|
|
||||||
"timeout": timeout
|
|
||||||
}
|
|
||||||
return self.call("waitsendpay", payload)
|
|
||||||
|
|
||||||
def pay(self, bolt11, msatoshi=None, label=None, riskfactor=None, description=None):
|
|
||||||
"""
|
|
||||||
Send payment specified by {bolt11} with {msatoshi}
|
|
||||||
(ignored if {bolt11} has an amount), optional {label}
|
|
||||||
and {riskfactor} (default 1.0)
|
|
||||||
"""
|
|
||||||
payload = {
|
|
||||||
"bolt11": bolt11,
|
|
||||||
"msatoshi": msatoshi,
|
|
||||||
"label": label,
|
|
||||||
"riskfactor": riskfactor,
|
|
||||||
# Deprecated.
|
|
||||||
"description": description,
|
|
||||||
}
|
|
||||||
return self.call("pay", payload)
|
|
||||||
|
|
||||||
def listpayments(self, bolt11=None, payment_hash=None):
|
|
||||||
"""
|
|
||||||
Show outgoing payments, regarding {bolt11} or {payment_hash} if set
|
|
||||||
Can only specify one of {bolt11} or {payment_hash}
|
|
||||||
"""
|
|
||||||
assert not (bolt11 and payment_hash)
|
|
||||||
payload = {
|
|
||||||
"bolt11": bolt11,
|
|
||||||
"payment_hash": payment_hash
|
|
||||||
}
|
|
||||||
return self.call("listpayments", payload)
|
|
||||||
|
|
||||||
def connect(self, peer_id, host=None, port=None):
|
|
||||||
"""
|
|
||||||
Connect to {peer_id} at {host} and {port}
|
|
||||||
"""
|
|
||||||
payload = {
|
|
||||||
"id": peer_id,
|
|
||||||
"host": host,
|
|
||||||
"port": port
|
|
||||||
}
|
|
||||||
return self.call("connect", payload)
|
|
||||||
|
|
||||||
def listpeers(self, peerid=None, level=None):
|
|
||||||
"""
|
|
||||||
Show current peers, if {level} is set, include {log}s"
|
|
||||||
"""
|
|
||||||
payload = {
|
|
||||||
"id": peerid,
|
|
||||||
"level": level,
|
|
||||||
}
|
|
||||||
return self.call("listpeers", payload)
|
|
||||||
|
|
||||||
def fundchannel(self, node_id, satoshi, feerate=None, announce=True, minconf=None):
|
|
||||||
"""
|
|
||||||
Fund channel with {id} using {satoshi} satoshis
|
|
||||||
with feerate of {feerate} (uses default feerate if unset).
|
|
||||||
If {announce} is False, don't send channel announcements.
|
|
||||||
Only select outputs with {minconf} confirmations
|
|
||||||
"""
|
|
||||||
payload = {
|
|
||||||
"id": node_id,
|
|
||||||
"satoshi": satoshi,
|
|
||||||
"feerate": feerate,
|
|
||||||
"announce": announce,
|
|
||||||
"minconf": minconf,
|
|
||||||
}
|
|
||||||
return self.call("fundchannel", payload)
|
|
||||||
|
|
||||||
def close(self, peer_id, force=None, timeout=None):
|
def close(self, peer_id, force=None, timeout=None):
|
||||||
"""
|
"""
|
||||||
Close the channel with peer {id}, forcing a unilateral
|
Close the channel with peer {id}, forcing a unilateral
|
||||||
@@ -564,14 +297,51 @@ class LightningRpc(UnixDomainSocketRpc):
|
|||||||
}
|
}
|
||||||
return self.call("close", payload)
|
return self.call("close", payload)
|
||||||
|
|
||||||
def dev_sign_last_tx(self, peer_id):
|
def connect(self, peer_id, host=None, port=None):
|
||||||
"""
|
"""
|
||||||
Sign and show the last commitment transaction with peer {id}
|
Connect to {peer_id} at {host} and {port}
|
||||||
"""
|
"""
|
||||||
payload = {
|
payload = {
|
||||||
"id": peer_id
|
"id": peer_id,
|
||||||
|
"host": host,
|
||||||
|
"port": port
|
||||||
}
|
}
|
||||||
return self.call("dev-sign-last-tx", payload)
|
return self.call("connect", payload)
|
||||||
|
|
||||||
|
def decodepay(self, bolt11, description=None):
|
||||||
|
"""
|
||||||
|
Decode {bolt11}, using {description} if necessary
|
||||||
|
"""
|
||||||
|
payload = {
|
||||||
|
"bolt11": bolt11,
|
||||||
|
"description": description
|
||||||
|
}
|
||||||
|
return self.call("decodepay", payload)
|
||||||
|
|
||||||
|
def delexpiredinvoice(self, maxexpirytime=None):
|
||||||
|
"""
|
||||||
|
Delete all invoices that have expired on or before the given {maxexpirytime}
|
||||||
|
"""
|
||||||
|
payload = {
|
||||||
|
"maxexpirytime": maxexpirytime
|
||||||
|
}
|
||||||
|
return self.call("delexpiredinvoice", payload)
|
||||||
|
|
||||||
|
def delinvoice(self, label, status):
|
||||||
|
"""
|
||||||
|
Delete unpaid invoice {label} with {status}
|
||||||
|
"""
|
||||||
|
payload = {
|
||||||
|
"label": label,
|
||||||
|
"status": status
|
||||||
|
}
|
||||||
|
return self.call("delinvoice", payload)
|
||||||
|
|
||||||
|
def dev_crash(self):
|
||||||
|
"""
|
||||||
|
Crash lightningd by calling fatal()
|
||||||
|
"""
|
||||||
|
return self.call("dev-crash")
|
||||||
|
|
||||||
def dev_fail(self, peer_id):
|
def dev_fail(self, peer_id):
|
||||||
"""
|
"""
|
||||||
@@ -582,25 +352,13 @@ class LightningRpc(UnixDomainSocketRpc):
|
|||||||
}
|
}
|
||||||
return self.call("dev-fail", payload)
|
return self.call("dev-fail", payload)
|
||||||
|
|
||||||
def dev_reenable_commit(self, peer_id):
|
def dev_forget_channel(self, peerid, force=False):
|
||||||
|
""" Forget the channel with id=peerid
|
||||||
"""
|
"""
|
||||||
Re-enable the commit timer on peer {id}
|
return self.call(
|
||||||
"""
|
"dev-forget-channel",
|
||||||
payload = {
|
payload={"id": peerid, "force": force}
|
||||||
"id": peer_id
|
)
|
||||||
}
|
|
||||||
return self.call("dev-reenable-commit", payload)
|
|
||||||
|
|
||||||
def ping(self, peer_id, length=128, pongbytes=128):
|
|
||||||
"""
|
|
||||||
Send {peer_id} a ping of length {len} asking for {pongbytes}"
|
|
||||||
"""
|
|
||||||
payload = {
|
|
||||||
"id": peer_id,
|
|
||||||
"len": length,
|
|
||||||
"pongbytes": pongbytes
|
|
||||||
}
|
|
||||||
return self.call("ping", payload)
|
|
||||||
|
|
||||||
def dev_memdump(self):
|
def dev_memdump(self):
|
||||||
"""
|
"""
|
||||||
@@ -614,35 +372,24 @@ class LightningRpc(UnixDomainSocketRpc):
|
|||||||
"""
|
"""
|
||||||
return self.call("dev-memleak")
|
return self.call("dev-memleak")
|
||||||
|
|
||||||
def withdraw(self, destination, satoshi, feerate=None, minconf=None):
|
def dev_query_scids(self, id, scids):
|
||||||
"""
|
"""
|
||||||
Send to {destination} address {satoshi} (or "all")
|
Ask peer for a particular set of scids
|
||||||
amount via Bitcoin transaction. Only select outputs
|
|
||||||
with {minconf} confirmations
|
|
||||||
"""
|
"""
|
||||||
payload = {
|
payload = {
|
||||||
"destination": destination,
|
"id": id,
|
||||||
"satoshi": satoshi,
|
"scids": scids
|
||||||
"feerate": feerate,
|
|
||||||
"minconf": minconf,
|
|
||||||
}
|
}
|
||||||
return self.call("withdraw", payload)
|
return self.call("dev-query-scids", payload)
|
||||||
|
|
||||||
def newaddr(self, addresstype=None):
|
def dev_reenable_commit(self, peer_id):
|
||||||
"""Get a new address of type {addresstype} of the internal wallet.
|
|
||||||
"""
|
"""
|
||||||
return self.call("newaddr", {"addresstype": addresstype})
|
Re-enable the commit timer on peer {id}
|
||||||
|
|
||||||
def listfunds(self):
|
|
||||||
"""
|
"""
|
||||||
Show funds available for opening channels
|
payload = {
|
||||||
"""
|
"id": peer_id
|
||||||
return self.call("listfunds")
|
}
|
||||||
|
return self.call("dev-reenable-commit", payload)
|
||||||
def listforwards(self):
|
|
||||||
"""List all forwarded payments and their information
|
|
||||||
"""
|
|
||||||
return self.call("listforwards")
|
|
||||||
|
|
||||||
def dev_rescan_outputs(self):
|
def dev_rescan_outputs(self):
|
||||||
"""
|
"""
|
||||||
@@ -650,13 +397,23 @@ class LightningRpc(UnixDomainSocketRpc):
|
|||||||
"""
|
"""
|
||||||
return self.call("dev-rescan-outputs")
|
return self.call("dev-rescan-outputs")
|
||||||
|
|
||||||
def dev_forget_channel(self, peerid, force=False):
|
def dev_rhash(self, secret):
|
||||||
""" Forget the channel with id=peerid
|
|
||||||
"""
|
"""
|
||||||
return self.call(
|
Show SHA256 of {secret}
|
||||||
"dev-forget-channel",
|
"""
|
||||||
payload={"id": peerid, "force": force}
|
payload = {
|
||||||
)
|
"secret": secret
|
||||||
|
}
|
||||||
|
return self.call("dev-rhash", payload)
|
||||||
|
|
||||||
|
def dev_sign_last_tx(self, peer_id):
|
||||||
|
"""
|
||||||
|
Sign and show the last commitment transaction with peer {id}
|
||||||
|
"""
|
||||||
|
payload = {
|
||||||
|
"id": peer_id
|
||||||
|
}
|
||||||
|
return self.call("dev-sign-last-tx", payload)
|
||||||
|
|
||||||
def disconnect(self, peer_id, force=False):
|
def disconnect(self, peer_id, force=False):
|
||||||
"""
|
"""
|
||||||
@@ -679,3 +436,246 @@ class LightningRpc(UnixDomainSocketRpc):
|
|||||||
"slow": slow
|
"slow": slow
|
||||||
}
|
}
|
||||||
return self.call("feerates", payload)
|
return self.call("feerates", payload)
|
||||||
|
|
||||||
|
def fundchannel(self, node_id, satoshi, feerate=None, announce=True, minconf=None):
|
||||||
|
"""
|
||||||
|
Fund channel with {id} using {satoshi} satoshis
|
||||||
|
with feerate of {feerate} (uses default feerate if unset).
|
||||||
|
If {announce} is False, don't send channel announcements.
|
||||||
|
Only select outputs with {minconf} confirmations
|
||||||
|
"""
|
||||||
|
payload = {
|
||||||
|
"id": node_id,
|
||||||
|
"satoshi": satoshi,
|
||||||
|
"feerate": feerate,
|
||||||
|
"announce": announce,
|
||||||
|
"minconf": minconf,
|
||||||
|
}
|
||||||
|
return self.call("fundchannel", payload)
|
||||||
|
|
||||||
|
def getinfo(self):
|
||||||
|
"""
|
||||||
|
Show information about this node
|
||||||
|
"""
|
||||||
|
return self.call("getinfo")
|
||||||
|
|
||||||
|
def getlog(self, level=None):
|
||||||
|
"""
|
||||||
|
Show logs, with optional log {level} (info|unusual|debug|io)
|
||||||
|
"""
|
||||||
|
payload = {
|
||||||
|
"level": level
|
||||||
|
}
|
||||||
|
return self.call("getlog", payload)
|
||||||
|
|
||||||
|
def getpeer(self, peer_id, level=None):
|
||||||
|
"""
|
||||||
|
Show peer with {peer_id}, if {level} is set, include {log}s
|
||||||
|
"""
|
||||||
|
payload = {
|
||||||
|
"id": peer_id,
|
||||||
|
"level": level
|
||||||
|
}
|
||||||
|
res = self.call("listpeers", payload)
|
||||||
|
return res.get("peers") and res["peers"][0] or None
|
||||||
|
|
||||||
|
def getroute(self, node_id, msatoshi, riskfactor, cltv=9, fromid=None, fuzzpercent=None, exclude=[], maxhops=20):
|
||||||
|
"""
|
||||||
|
Show route to {id} for {msatoshi}, using {riskfactor} and optional
|
||||||
|
{cltv} (default 9). If specified search from {fromid} otherwise use
|
||||||
|
this node as source. Randomize the route with up to {fuzzpercent}
|
||||||
|
(0.0 -> 100.0, default 5.0). {exclude} is an optional array of
|
||||||
|
scid/direction to exclude. Limit the number of hops in the route to
|
||||||
|
{maxhops}.
|
||||||
|
"""
|
||||||
|
payload = {
|
||||||
|
"id": node_id,
|
||||||
|
"msatoshi": msatoshi,
|
||||||
|
"riskfactor": riskfactor,
|
||||||
|
"cltv": cltv,
|
||||||
|
"fromid": fromid,
|
||||||
|
"fuzzpercent": fuzzpercent,
|
||||||
|
"exclude": exclude,
|
||||||
|
"maxhops": maxhops
|
||||||
|
}
|
||||||
|
return self.call("getroute", payload)
|
||||||
|
|
||||||
|
def help(self, command=None):
|
||||||
|
"""
|
||||||
|
Show available commands, or just {command} if supplied.
|
||||||
|
"""
|
||||||
|
payload = {
|
||||||
|
"command": command,
|
||||||
|
}
|
||||||
|
return self.call("help", payload)
|
||||||
|
|
||||||
|
def invoice(self, msatoshi, label, description, expiry=None, fallbacks=None, preimage=None, exposeprivatechannels=None):
|
||||||
|
"""
|
||||||
|
Create an invoice for {msatoshi} with {label} and {description} with
|
||||||
|
optional {expiry} seconds (default 1 hour)
|
||||||
|
"""
|
||||||
|
payload = {
|
||||||
|
"msatoshi": msatoshi,
|
||||||
|
"label": label,
|
||||||
|
"description": description,
|
||||||
|
"expiry": expiry,
|
||||||
|
"fallbacks": fallbacks,
|
||||||
|
"preimage": preimage,
|
||||||
|
"exposeprivatechannels": exposeprivatechannels
|
||||||
|
}
|
||||||
|
return self.call("invoice", payload)
|
||||||
|
|
||||||
|
def listchannels(self, short_channel_id=None, source=None):
|
||||||
|
"""
|
||||||
|
Show all known channels, accept optional {short_channel_id} or {source}
|
||||||
|
"""
|
||||||
|
payload = {
|
||||||
|
"short_channel_id": short_channel_id,
|
||||||
|
"source": source
|
||||||
|
}
|
||||||
|
return self.call("listchannels", payload)
|
||||||
|
|
||||||
|
def listforwards(self):
|
||||||
|
"""List all forwarded payments and their information
|
||||||
|
"""
|
||||||
|
return self.call("listforwards")
|
||||||
|
|
||||||
|
def listfunds(self):
|
||||||
|
"""
|
||||||
|
Show funds available for opening channels
|
||||||
|
"""
|
||||||
|
return self.call("listfunds")
|
||||||
|
|
||||||
|
def listinvoices(self, label=None):
|
||||||
|
"""
|
||||||
|
Show invoice {label} (or all, if no {label))
|
||||||
|
"""
|
||||||
|
payload = {
|
||||||
|
"label": label
|
||||||
|
}
|
||||||
|
return self.call("listinvoices", payload)
|
||||||
|
|
||||||
|
def listnodes(self, node_id=None):
|
||||||
|
"""
|
||||||
|
Show all nodes in our local network view, filter on node {id}
|
||||||
|
if provided
|
||||||
|
"""
|
||||||
|
payload = {
|
||||||
|
"id": node_id
|
||||||
|
}
|
||||||
|
return self.call("listnodes", payload)
|
||||||
|
|
||||||
|
def listpayments(self, bolt11=None, payment_hash=None):
|
||||||
|
"""
|
||||||
|
Show outgoing payments, regarding {bolt11} or {payment_hash} if set
|
||||||
|
Can only specify one of {bolt11} or {payment_hash}
|
||||||
|
"""
|
||||||
|
assert not (bolt11 and payment_hash)
|
||||||
|
payload = {
|
||||||
|
"bolt11": bolt11,
|
||||||
|
"payment_hash": payment_hash
|
||||||
|
}
|
||||||
|
return self.call("listpayments", payload)
|
||||||
|
|
||||||
|
def listpeers(self, peerid=None, level=None):
|
||||||
|
"""
|
||||||
|
Show current peers, if {level} is set, include {log}s"
|
||||||
|
"""
|
||||||
|
payload = {
|
||||||
|
"id": peerid,
|
||||||
|
"level": level,
|
||||||
|
}
|
||||||
|
return self.call("listpeers", payload)
|
||||||
|
|
||||||
|
def newaddr(self, addresstype=None):
|
||||||
|
"""Get a new address of type {addresstype} of the internal wallet.
|
||||||
|
"""
|
||||||
|
return self.call("newaddr", {"addresstype": addresstype})
|
||||||
|
|
||||||
|
def pay(self, bolt11, msatoshi=None, label=None, riskfactor=None, description=None):
|
||||||
|
"""
|
||||||
|
Send payment specified by {bolt11} with {msatoshi}
|
||||||
|
(ignored if {bolt11} has an amount), optional {label}
|
||||||
|
and {riskfactor} (default 1.0)
|
||||||
|
"""
|
||||||
|
payload = {
|
||||||
|
"bolt11": bolt11,
|
||||||
|
"msatoshi": msatoshi,
|
||||||
|
"label": label,
|
||||||
|
"riskfactor": riskfactor,
|
||||||
|
# Deprecated.
|
||||||
|
"description": description,
|
||||||
|
}
|
||||||
|
return self.call("pay", payload)
|
||||||
|
|
||||||
|
def ping(self, peer_id, length=128, pongbytes=128):
|
||||||
|
"""
|
||||||
|
Send {peer_id} a ping of length {len} asking for {pongbytes}"
|
||||||
|
"""
|
||||||
|
payload = {
|
||||||
|
"id": peer_id,
|
||||||
|
"len": length,
|
||||||
|
"pongbytes": pongbytes
|
||||||
|
}
|
||||||
|
return self.call("ping", payload)
|
||||||
|
|
||||||
|
def sendpay(self, route, payment_hash, description=None, msatoshi=None):
|
||||||
|
"""
|
||||||
|
Send along {route} in return for preimage of {payment_hash}
|
||||||
|
"""
|
||||||
|
payload = {
|
||||||
|
"route": route,
|
||||||
|
"payment_hash": payment_hash,
|
||||||
|
"description": description,
|
||||||
|
"msatoshi": msatoshi,
|
||||||
|
}
|
||||||
|
return self.call("sendpay", payload)
|
||||||
|
|
||||||
|
def stop(self):
|
||||||
|
"""
|
||||||
|
Shut down the lightningd process
|
||||||
|
"""
|
||||||
|
return self.call("stop")
|
||||||
|
|
||||||
|
def waitanyinvoice(self, lastpay_index=None):
|
||||||
|
"""
|
||||||
|
Wait for the next invoice to be paid, after {lastpay_index}
|
||||||
|
(if supplied)
|
||||||
|
"""
|
||||||
|
payload = {
|
||||||
|
"lastpay_index": lastpay_index
|
||||||
|
}
|
||||||
|
return self.call("waitanyinvoice", payload)
|
||||||
|
|
||||||
|
def waitinvoice(self, label):
|
||||||
|
"""
|
||||||
|
Wait for an incoming payment matching the invoice with {label}
|
||||||
|
"""
|
||||||
|
payload = {
|
||||||
|
"label": label
|
||||||
|
}
|
||||||
|
return self.call("waitinvoice", payload)
|
||||||
|
|
||||||
|
def waitsendpay(self, payment_hash, timeout=None):
|
||||||
|
"""
|
||||||
|
Wait for payment for preimage of {payment_hash} to complete
|
||||||
|
"""
|
||||||
|
payload = {
|
||||||
|
"payment_hash": payment_hash,
|
||||||
|
"timeout": timeout
|
||||||
|
}
|
||||||
|
return self.call("waitsendpay", payload)
|
||||||
|
|
||||||
|
def withdraw(self, destination, satoshi, feerate=None, minconf=None):
|
||||||
|
"""
|
||||||
|
Send to {destination} address {satoshi} (or "all")
|
||||||
|
amount via Bitcoin transaction. Only select outputs
|
||||||
|
with {minconf} confirmations
|
||||||
|
"""
|
||||||
|
payload = {
|
||||||
|
"destination": destination,
|
||||||
|
"satoshi": satoshi,
|
||||||
|
"feerate": feerate,
|
||||||
|
"minconf": minconf,
|
||||||
|
}
|
||||||
|
return self.call("withdraw", payload)
|
||||||
|
|||||||
Reference in New Issue
Block a user