Ejemplo n.º 1
0
def addinvoice(memo, rpcserver, amt, expiry):
    """
    TODO (2019-??-??): check for [lncli] rpc error: code = Unknown desc = memo too large: 1192 bytes (maxsize=1024)
    """
    cmd = [LNCLI_BIN] + _auth_args(rpcserver) + [
        "addinvoice", "--memo", memo, "--amt",
        str(amt), "--expiry",
        str(expiry)
    ]

    # TODO: return_stderr_on_fail=True, and adjust all the call sites
    output = cli.run(cmd)
    print("Command finished, addinvoice json stdout: {}".format(output))
    return output
Ejemplo n.º 2
0
def verifymessage(msg, sig, rpcserver, mock=False):
    """
    NOTE: CLI retruns "pubkey" while API returns "idnetity_pubkey"
    """
    if mock:
        return {"valid": True, "pubkey": "FAKE2"}

    cmd = [LNCLI_BIN] + _auth_args(rpcserver) + [
        "verifymessage",
        "--msg",
        msg,
        "--sig",
        sig,
    ]

    # TODO: return_stderr_on_fail=True, and adjust all the call sites
    return cli.run(cmd, log_cmd=True)
Ejemplo n.º 3
0
def payinvoice(payreq, rpcserver, mock=False):
    if mock:
        return {"success": True, "stdouterr": ""}

    # TODO: add --json, note that this flag is not defined in older versions of lncli

    cmd = [LNCLI_BIN] + _auth_args(rpcserver) + [
        "payinvoice",
        "-f",  # force, no interactive prompt
        "--pay_req",
        payreq,
    ]

    return cli.run(cmd,
                   log_cmd=True,
                   return_stderr_on_fail=True,
                   try_num=3,
                   timeout=60)  # 12x the default timeout!
Ejemplo n.º 4
0
def listinvoices(index_offset, rpcserver, max_invoices=100, mock=False):
    if mock:
        return {
            "first_index_offset": "0",
            "invoices": [],
            "last_index_offset": "0"
        }

    cmd = [LNCLI_BIN] + _auth_args(rpcserver) + [
        "listinvoices",
        "--index_offset",
        str(index_offset),
        "--max_invoices",
        str(max_invoices),
        "--paginate-forwards",
    ]

    # TODO: return_stderr_on_fail=True, and adjust all the call sites
    return cli.run(cmd, log_cmd=False)
Ejemplo n.º 5
0
def decodepayreq(payreq, rpcserver, mock=False):
    if mock:
        return {
            "success":
            True,
            "stdouterr":
            json.dumps({
                "num_satoshis": 123,
                "num_msat": 123000,
                "pubkey": "FAKE2"
            })
        }

    cmd = [LNCLI_BIN] + _auth_args(rpcserver) + [
        "decodepayreq",
        "--pay_req",
        payreq,
    ]

    return cli.run(cmd, log_cmd=True, return_stderr_on_fail=True)