Commit Graph

481 Commits

Author SHA1 Message Date
rbndg 83b78fd327 Unpacking variable for cleaner code for testing 2020-05-04 19:18:05 +02:00
rbndg 241fa00e97 plugin:added invoice creation event
New invoice_creation event triggered when an new invoice is created

Changelog-Added: plugin: New invoice_creation plugin event
2020-05-04 19:18:05 +02:00
Christian Decker 64b0487228 pyln-testing: Just warn if we get an unexpected fee request
This was breaking a couple of tests if the pyln version was not synced up with
`lightningd`, so now we just warn (these are then collected when running in
pytest and highlighted).
2020-05-01 18:20:33 -05:00
Christian Decker 264b2d1975 pyln-testing: Add more meaningful error for mock_estimatefees
We only support a very limited number of argument combinations, and apparently
sometimes we trigger a case we aren't handling. This adds a more useful error
message, including the params we didn't match.
2020-04-20 07:48:32 +09:30
lisa neigut 9b42d9d8ba build: add mkrd to docker install? 2020-04-19 08:07:47 +09:30
Christian Decker f3315ca110 pyln-proto: Add Tu32Field and Tu64Field helpers
These are necessary for the interim keysend plugin
2020-04-16 18:03:35 +09:30
darosior 11acd902ff pyln-testing: specify fallbackfee for newer versions of bitcoind
Changelog-None
2020-04-13 19:50:05 +09:30
darosior af76bce0fa pyln-client: send proper JSONRPC2 errors on failed call
Changelog-Added: pyln now sends proper error on bad calls to plugin methods

Co-Authored-By: Sergi Delgado Segura <sergi.delgado.s@gmail.com>
2020-04-11 12:17:51 +09:30
Christian Decker 3b09662768 pyln: Allow non-empty directory when creating node in node_factory
So far we've always cleared the node directory when provisioning the node, but
while testing some plugins we noticed that pre-generating some files in that
directory is useful. This just adds yet another flag to `get_node` that
disables deleting any existing node directory.
2020-04-11 08:43:06 +09:30
Vasil Dimov 158d2212c2 closingd: configurable closing fee negotiation step
When negotiating the transaction fee for closing a channel [1], we used
to always pick the middle of the range between our proposal and the
peer's proposal.

Introduce a new option `fee_negotiation_step` to the close command, so
the peer who initiates the close can choose his back off step.

Partially resolves https://github.com/ElementsProject/lightning/issues/3270

[1] https://github.com/lightningnetwork/lightning-rfc/blob/master/02-peer-protocol.md#closing-negotiation-closing_signed

Changelog-Added: New optional parameter to the `close` command to control the closing transaction fee negotiation back off step
2020-04-07 13:52:48 +09:30
darosior 242ddb5660 pyln-testing: allow to customize --allow-deprecated-apis 2020-04-05 11:06:27 +09:30
darosior 7c0af81c21 bcli: use a more urgent feerate for HTLCs and penalty transactions
A CONSERVATIVE/3 target for them.

Some noisy changes to the tests as we had to update the estimatesmartfee
mock.

Changelog-Changed: We now use a higher feerate for resolving onchain HTLCs and for penalty transactions
2020-04-01 23:02:47 -05:00
darosior dce2e87928 chaintopology: better feerate targets differentiation
We kept track of an URGENT, a NORMAL, and a SLOW feerate. They were used
for opening (NORMAL), mutual (NORMAL), UNILATERAL (URGENT) transactions
as well as minimum and maximum estimations, and onchain resolution.

We now keep track of more fine-grained feerates:
- `opening` used for funding and also misc transactions
- `mutual_close` used for the mutual close transaction
- `unilateral_close` used for unilateral close (commitment transactions)
- `delayed_to_us` used for resolving our output from our unilateral close
- `htlc_resolution` used for resolving onchain HTLCs
- `penalty` used for resolving revoked transactions

We don't modify our requests to our Bitcoin backend, as the next commit
will batch them !

Changelog-deprecated: The "urgent", "slow", and "normal" field of the `feerates` command are now deprecated.
Changelog-added: The fields "opening", "mutual_close", "unilateral_close", "delayed_to_us", "htlc_resolution" and "penalty" have been added to the `feerates` command.
2020-03-30 20:17:18 +10:30
Michael Schmoock e71e44ac8b pyln-testing: cleanup of pay() helper function 2020-03-27 12:33:23 +01:00
Michael Schmoock 80ff9c5b63 test: refactor lockup_drain add helpers drain and force_feerates 2020-03-27 12:33:23 +01:00
Christian Decker 7201cb7315 pytest: Configure logging in a fixture to match stdout capturing
pytest captures the output by monkey patching out `sys.stdout`. This may
conflict with our use of `sys.stdout` when configuring logging, resulting in
the "Write to closed file" issue that is spamming the logs. By making the
logging configuration a fixture hopefully we always use the correct
stdout (after pytest has monkey-patched it).
2020-03-24 09:52:33 +10:30
Christian Decker cf8c972883 pyln-testing: Print a list of files if we can't remove the test dir
For some reason we fail to remove the test directory in some cases. My
hypothesis is that it is a daemon that is not completely shut down yet, and
still writes to the directory. This commit intercepts the error, prints any
files in the directory and re-raises the error. This should allow us to debug
the reappears.
2020-03-24 09:52:33 +10:30
Christian Decker 3e3b05e1b2 pyln: Migrate remaining uses of the deprecated pylightning module
`pylightning` is not much more than an alias for `pyln-client`, so this
removes the need to install that as well just to run the tests.
2020-03-24 09:52:33 +10:30
Christian Decker 24aaf73982 pytest: Actually make sure that the direcory exists
Some tests may not spawn a node at all, so make sure that our assumption that
the directory exists in the fixture cleanup is correct by creating the
directory.
2020-03-24 09:52:33 +10:30
lisa neigut 42cce55b45 plugins: add 'flag' type for plugin options
Updates the plugin docs to include more detailed info about how options
work.

Changelog-Added: Plugins: 'flag'-type option now available.
2020-03-21 16:29:52 +10:30
lisa neigut d19cddf00f pyln: enforce types of options
we loosely enforce that the specified type must be one of the listed
options. you can still cause an error because we're not checking the
default value you're passing in ...

not sure if this is totally necessary, should we jsut let clightning
enforce the input?
2020-03-10 13:25:36 +10:30
lisa neigut 34cef2cac3 pyln-testing: add flag 'expect_fail' to node factory get_node
if the node fails to start (and we're expecting it to) return to us the
node object anyway

we also signal to collect all of its stderr logs by setting stderr
on the tailableproc that backs the node
2020-03-10 13:25:36 +10:30
lisa neigut 0cf3e19e0b pyln-testing: save stderr logs for checking
just for convenience's sake
2020-03-10 13:25:36 +10:30
ZmnSCPxj jxPCSnmZ d9b2482415 lightningd/hsm_control.c: Implement `getsharedsecret`.
ChangeLog-Added: New `getsharedsecret` command, which lets you compute a shared secret with this node knowing only a public point. This implements the BOLT standard of hashing the ECDH point, and is incompatible with ECIES.
2020-02-28 14:45:50 +10:30
Christian Decker 7f6f324590 python2: Remove python2 dependency from docs and dockerfiles 2020-02-27 09:18:24 +10:30
Christian Decker 87e924e270 docker: Remove Dockerfile for i386 builder
We aren't using it and it's broken with the specified upstream image, so
remove it outright.
2020-02-27 09:18:24 +10:30
Michael Schmoock dd334df80d fix: makes testutils ln.pay assert status complete
`waitsendpay` in `lightningd/pay.c` can also return 'pending' and 'failed',
we should check that.
2020-02-18 10:10:17 +10:30
Michael Schmoock 3e2607bf2d chore: updates coincurve requirement to v13
Update to v13 as v12 started to raise undefined symbol exceptions agains latest
libsecp256k1.

Note: any version of `pip install coincurve` fails if no libsecp256k1 headers
are installed, should we point this out somewhere/somehow?

Changelog-None
2020-02-18 10:10:17 +10:30
Christian Decker 966ac95098 pytest: Add a test for plugin featurebits 2020-02-11 13:53:31 +10:30
Christian Decker a13591400a pyln-client: Add facility to register featurebits from plugins
we have 4 venues in which we can add features, 3 of which are unilaterally
controlled (`init`, `node_announcement`, and `invoices`) the
`channel_announcement` is co-signed by both parties, so we can't add
featurebits without additional coordination overhead.

Each location is encoded as a key-value pair in a dict called `featurebits` in
the manifest (omitted if no custom featurebits are set).
2020-02-11 13:53:31 +10:30
Michael Schmoock 5f7cf307e7 pyln-testing: adds helper wait_for_htlcs
Changelog-Added: pyln-testing adds wait_for_htlcs helper to settle HTLCs
2020-02-10 12:14:19 +10:30
Christian Decker 6c19818314 pyln-proto: Add invoice utilities
We are about to disect a couple of invoices for features, so let's add a class
that can encode and decode invoices from bolt11 strings. This is pretty much
the lnaddr.py file created by @rustyrussell with some minor changes. I'm
planning to clean this up further which is why I'm only exporting the
`Invoice` class for now.
2020-02-01 16:50:58 +01:00
Christian Decker 24219b38f9 pyln: Add unit tests from pyln-* to `make check-python` 2020-02-01 16:50:58 +01:00
Christian Decker 28080b2e69 elementsd: Do not use `generate` for elementsd >= 0.17.0
The `generate` has been deprecated since 0.16 and has been removed in 0.18.0
so we better use `generatetoaddress` instead, which is already what we do with
`bitcoind`. So we remove the override here.
2020-01-28 20:03:55 +01:00
ZmnSCPxj jxPCSnmZ 67590fc6be lightningd/invoice.c: Add `timeout` parameter to `waitanyinvoice`.
Fixes: #3192

Changelog-Added: `waitanyinvoice` now supports a `timeout` parameter, which when set will cause the command to fail when the timeout is reached; can set this to 0 to fail immediately if no new invoice has been paid yet.
2020-01-28 14:07:52 +01:00
Christian Decker d3f6ebf911 pyln-proto: Added a couple of utilities to manage onions and zbase32 2020-01-28 13:43:44 +10:30
lisa neigut 1763960c4a txprepare: don't crash on empty args
add test for empty args check
2020-01-27 22:59:41 +01:00
darosior b7699cff9f pyln: actually specify jsonrpc in requests
As per the spec (https://www.jsonrpc.org/specification#request_object)

```
A rpc call is represented by sending a Request object to a Server. The Request object has the following members:

jsonrpc
    A String specifying the version of the JSON-RPC protocol. MUST be exactly "2.0".
```

Changelog-fixed: pyln now includes the "jsonrpc" field to jsonrpc2 requests
2020-01-27 12:38:40 +01:00
ZmnSCPxj 54cc735201 lightningd/peer_control.c: Implement waitblockheight.
This is needed to fully implement handling of blockheight disagreements
between us and payee.
If payee believes the blockheight is higher than ours, then `pay`
should wait for our node to achieve that blockheight.

Changelog-Add: Implement `waitblockheight` to wait for a specific blockheight.
2020-01-21 22:23:21 +01:00
Zoe Faltibà 205f9d814d pyln-client/LightningRpc: fixed logger in super()
* Changelog-None
2020-01-15 09:26:09 +08:00
Vasil Dimov 43cc2ba708 contrib: fix wrong number in comment
Changelog-None
2020-01-06 12:57:59 +01:00
Christian Decker 8cad3ffeac pyln: Work around the socket path length on Linux OSs
Some Linux OSs impose a length limit on the path a Unix socket may have. This
is not an issue in `lightningd` since we `chdir()` into that directory before
opening the socket, however in pyln this became a problem for some tests,
since we use absolute paths in the testing framework. It's also a rather
strange quirk to expose to users.

This patch introduces a `UnixSocket` abstraction that attempts to work around
these limitations by aliasing the directory containing the socket into
`/proc/self/fd` and then connecting using that alias.

It was inspired by Open vSwitch code here https://github.com/openvswitch/ovs/blob/master/python/ovs/socket_util.py

Signed-off-by: Christian Decker <@cdecker>
2020-01-02 16:05:52 +01:00
Christian Decker de619b1754 pyln: Check to see if we have annotations on funcs before accessing
We were indiscriminately accessing the `__annotations__` which could cause
issues if the function had been wrapped by some functions such as
`functools.partial`. This just checks that the access is safe before doing it.

Suggested-by: jarret <@jarret>
Signed-off-by: Christian Decker <@cdecker>
2020-01-02 16:05:52 +01:00
Christian Decker 8c387932c0 pyln: Bump versions of pyln-client and pyln-testing 2019-12-31 16:43:04 +01:00
lisa neigut 689dd28ddd funding: enable push_msat
it's that time of year (merry xmas!)

enables the ability to push_msat on fundchannel

Changelog-Added: RPC: `fundchannel` and `fundchannel_start` can now accept an optional parameter, `push_msat`, which will gift that amount of satoshis to the peer at channel open.
2019-12-24 12:04:01 -06:00
darosior 051b5bd1bf Update bitcoin-core version
Bitcoin-core v0.18.X is now the more widely used.
2019-12-22 12:42:56 +01:00
Michael Schmoock c77a085ca4 fix: update pip dependencies version in dockerfile 2019-12-19 15:17:25 +01:00
Michael Schmoock dc5a1ad664 fix: normalize pip requirements
This will change some `requirements.txt` of pyln-testing in a way that
it does not require different package version i.e. to `tests/requirements.txt`.

The reason for this is that users are not forced to hassle with pyenv
or virtualenv and could just use `--user`.

```bash
pip install --user -r tests/requirements.txt -r contrib/pyln-testing/requirements.txt
```

Changelog-None
2019-12-19 15:17:25 +01:00
Michael Schmoock 43b5abeb22 fix: pip dependency version for psycopg2-binary
Trying to `pip install psycopg2-binary==2.8.3` raised an error for a
long time. Since version `2.8.4` is recent and also seem to work I
suggest updating the requirements so other users dont run into the
following error, where pip tries to use `pg_config` for the BINARY
package:

Collecting psycopg2-binary==2.8.3 (from -r contrib/pyln-testing/requirements.txt (line 6))
  Using cached 91911be018dd876c1e0f12e1b5fb90/psycopg2-binary-2.8.3.tar.gz
    ERROR: Command errored out with exit status 1:
     command: /usr/bin/python -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-zapr0fhs/psycopg2-binary/setup.py'"'"'; __file__='"'"'/tmp/pip-install-zapr0fhs/psycopg2-binary/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base pip-egg-info
         cwd: /tmp/pip-install-zapr0fhs/psycopg2-binary/
    Complete output (23 lines):
    running egg_info
    creating pip-egg-info/psycopg2_binary.egg-info
    writing pip-egg-info/psycopg2_binary.egg-info/PKG-INFO
    writing dependency_links to pip-egg-info/psycopg2_binary.egg-info/dependency_links.txt
    writing top-level names to pip-egg-info/psycopg2_binary.egg-info/top_level.txt
    writing manifest file 'pip-egg-info/psycopg2_binary.egg-info/SOURCES.txt'

    Error: pg_config executable not found.

    pg_config is required to build psycopg2 from source.  Please add the directory
    containing pg_config to the $PATH or specify the full executable path with the
    option:

        python setup.py build_ext --pg-config /path/to/pg_config build ...

    or with the pg_config option in 'setup.cfg'.

    If you prefer to avoid building psycopg2 from source, please install the PyPI
    'psycopg2-binary' package instead.

    For further information please check the 'doc/src/install.rst' file (also at
    <http://initd.org/psycopg/docs/install.html>).

    ----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.

Changelog-None
2019-12-19 13:26:13 +01:00
Rusty Russell 839909d2cf Protocol: make var_onion, payment_secret and basic_mpp non-EXPERIMENTAL.
Thanks to @t-bast, who made this possible by interop testing with Eclair!

Changelog-Added: Protocol: can now send and receive TLV-style onion messages.
Changelog-Added: Protocol: can now send and receive BOLT11 payment_secrets.
Changelog-Added: Protocol: can now receive basic multi-part payments.
Changelog-Added: RPC: low-level commands sendpay and waitsendpay can now be used to manually send multi-part payments.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2019-12-12 22:16:03 +01:00
Christian Decker d449423983 pyln: Bump the version of pyln-client 2019-12-12 00:15:23 +01:00
Christian Decker 43dfb4dae7 pytest: Stabilize and parameterize closing_specified_destination
This test was doing a few contortions, so I disentangled it a bit and
parametrized it
2019-12-11 16:18:34 +01:00
Christian Decker fc93787db9 pytest: Parametrize test_gossip_query_channel_range for elements
We were hardcoding the chainparams->chain_hash which caused the query to
return an empty result. By parametrizing the test we can make it work on
elements.
2019-12-11 16:18:34 +01:00
Christian Decker 15f04d5fff pytest: Give details about which node exited with a return code != 0 2019-12-11 16:18:34 +01:00
Christian Decker 518c43a9c2 pytest: Remember a node's return code so we can check it later 2019-12-11 16:18:34 +01:00
Michael Schmoock bd369edd10 chore: reduce rpc load in is_channel_active helper 2019-12-07 21:27:28 +01:00
Michael Schmoock 44c23ede04 chore: adds announce_channel parameter to pyln fund_channel 2019-12-07 21:27:28 +01:00
Jarret Dyrbye d712f732d8 pylightning - allow unicode symbols in the description to be passed as-is to the daemon
addresses issue #2753.

Formatting the JSON with the default parameters will escape the unicode
symbols in a way that c-lightning won't allow, leading to an exception.

Changelog-Fixed: `pylightning` now handles unicode characters in JSON-RPC requests and responses correctly.
2019-11-29 21:38:17 +01:00
Christian Decker 9e59740268 pyln-testing: Do not require a conftest.py to annotate tests
In the c-lightning tests we have `tests/conftest.py` which annotates test
function with the outcome. If we use pyln-testing outside of the c-lightning
tree we cannot rely on that annotation being there, so we assume it passed.
2019-11-29 15:06:39 +01:00
Christian Decker 3c5ed15b2c pyln: Add psycopg2-binary as a dependency
Using the psycopg2-binary package means that the apropriate compiled binary
for the user platform will be shipped alongside the python binaries. Otherwise
the python bindings and the C shims would be shipped which would then require
the postgres development packages as well.

This just makes things easier, since we don't require the build dependencies.
2019-11-29 15:06:39 +01:00
Rusty Russell aab83e729b lightningd: change config-dir from plugin / wallet / hsm POV into <network> subdir
Changelog-changed: .lightningd plugins and files moved into <network>/ subdir
Changelog-changed: WARNING: If you don't have a config file, you now may need to specify the network to lightning-cli
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2019-11-23 22:42:34 +00:00
Christian Decker 1e89937a0a pytest: Skip mem-leak test when not running in developer mode
We were skipping it when running under valgrind, but not if not in developer,
which is required to have access to `dev-*` methods.
2019-11-22 03:48:54 +00:00
Rusty Russell 3437f7e25d devtools/gossipwith: change timeout to seconds.
I always get this wrong, then wonder why it's dying!

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2019-11-18 11:01:20 +01:00
Rusty Russell 709c98f539 logging: remove spaces from subsystem names.
Spaces just make life a little harder for everyone.

(Plus, fix documentation: it's 'jsonrpc' not 'json' subsystem).

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2019-11-18 04:50:22 +00:00
Rusty Russell 4fc498f901 lightningd: enable io logging on subdaemons iff we're going to print it.
This simplifies our tests, too, since we don't need a magic option to
enable io logging in subdaemons.

Note that test_bad_onion still takes too long, due to a separate minor
bug, so that's marked and left dev-only for now.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2019-11-18 04:50:22 +00:00
Rusty Russell ef7a820ab1 log: make formatting more consistent.
1. Printed form is always "[<nodeid>-]<prefix>: <string>"
2. "jcon fd %i" becomes "jsonrpc #%i".
3. "jsonrpc" log is only used once, and is removed.
4. "database" log prefix is use for db accesses.
5. "lightningd(%i)" becomes simply "lightningd" without the pid.
6. The "lightningd_" prefix is stripped from subd log prefixes, and pid removed.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Changelog-changed: Logging: formatting made uniform: [NODEID-]SUBSYSTEM: MESSAGE
Changelog-removed: `lightning_` prefixes removed from subdaemon names, including in listpeers `owner` field.
2019-11-18 04:50:22 +00:00
Rusty Russell eed654f684 connectd, gossipd: use per-peer logging.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2019-11-18 04:50:22 +00:00
Rusty Russell e433d4ddc1 lightningd: have logging include an optional node_id for each entry.
A log can have a default node_id, which can be overridden on a per-entry
basis.  This changes the format of logging, so some tests need rework.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2019-11-18 04:50:22 +00:00
arowser 39fa486cb2 remove unnecessary software package from arm Dockerfile 2019-11-14 10:20:28 +01:00
lisa neigut 6f215a70e5 contrib: fixup documentation of l1/2-log 2019-11-13 03:31:20 +00:00
Christian Decker 9378be72a9 pyln: Allow users to override the LightningNode class
Quite a few of the things in the LightningNode class are tailored to their use
in the c-lightning tests, so I decided to split those customizations out into
a sub-class, and adding one more fixture that just serves the class. This
allows us to override the LightningNode implementation in our own tests, while
still having sane defaults for other users.
2019-11-12 21:23:55 +01:00
Christian Decker bc9b1c405e pyln: Move RPC and daemon instantiation into the LightningNode
We were relying heavily on NodeFactory to do some magic before instantiating
the Node with rpc and daemon initialized, that meant that we'd have to replace
all 3 classes when customizing the node to our needs. Moving that
initialization into the node itself means that the LightningNode class now can
be swapped out and customized, without having to wire everything else through.
2019-11-12 21:23:55 +01:00
Christian Decker 53a2789547 pyln: Default to DEVELOPER=0 when running outside of tree
`DEVELOPER=1` assumes that the binary has been compiled with developer set to
true, which might not be the case for plugin developers. Setting this to 0 by
default has no effect in c-lightning since we always at least set it in
`config.vars` but may prevent some issues outside.
2019-11-12 21:23:55 +01:00
Christian Decker b7e7e535c8 pytest: Migrate `env` to pyln-testing 2019-11-12 21:23:55 +01:00
Christian Decker a2a3d33802 pyln-testing: Copy basic support infrastructure into pyln.testing
We'll rewrite the tests to use this infrastructure in the next commit.

Changelog-Added: The new `pyln-testing` package now contains the testing infrastructure so it can be reused to test against c-lighting in external projects
2019-11-12 21:23:55 +01:00
Christian Decker 81f7978cc8 pyln: Migrate implementation from pylightning to pyln-client
This should not affect any consumer of the API since we just shift the actual
implementation from one side to the other, and keep aliases in place so
scripts don't break.

We also bump the version number from 0.0.7.3 to 0.7.4 which allows us to be in
sync with c-lightning itself, and remove the superfluous `0` in front.
2019-11-12 21:23:55 +01:00
darosior f3d304901b pay: add a dev-only parameter to deactivate shadow routing
Had to make a special pylightning function to avoid rewriting all calls
to 'pay()' with 'rpc.call()' in the next commit..
2019-11-08 03:27:58 +00:00
darosior f690c35883 cleanup lightning-pay
No json.dumps, make bolt11 a required argument (better usage output instead of assertion error)
2019-10-29 12:15:29 -05:00
darosior 8a9650c887 pylightning: reorder imports 2019-10-29 12:15:29 -05:00
lisa neigut f5e4a30c8d add gettext to build release script
new dependency for this build means we need it
2019-10-20 22:33:23 +02:00
lisa neigut 422b4502d3 funding: add RPC arg to specify a 'close_to' address
Takes advantage of upfront-shutdown-script to permit users to
specify the close-to address for a channel at open, by adding
a `close_to` field to `fundchannel_start`.

Note that this only is in effect if `fundchannel_start` returns
with `close_to` set -- otherwise, peer doesn't
support `option_upfront_shutdown_script`.
2019-10-15 19:10:05 +02:00
Rusty Russell 3702f0f17b pylightning: bump version number.
We should add this to the release checklist!  It was last changed
for version 0.7.1.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2019-10-15 17:15:23 +02:00
Rusty Russell ab48ecf07c pylightning: wrap signmessage/checkmessage.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2019-10-15 17:15:23 +02:00
lisa neigut 9e29a47cf8 contrib: add aliases for logs
Add aliases 'l1-log' and 'l2-log' to startup_regtest script
2019-10-10 05:57:45 +00:00
trueptolemy 63af8632b7 pytest: Test `close` to the specified destination 2019-10-09 21:04:16 -05:00
trueptolemy 019c052123 JSON-API: Allow `close` channel to specified address
Command format: close id [unilateraltimeout] [destination]

Close the channel with peer {id}, forcing a unilateral
close after {unilateraltimeout} seconds if non-zero, and
the to-local output will be sent to {destination}. If
{destination} isn't specified, the default is the address
of lightningd.

Also change the pylightning:
update the `close` API to support `destination` parameter
2019-10-09 21:04:16 -05:00
trueptolemy d149ba2f3a JSON-API: `fundchannel_start` uses `amount` fieldname to replace `satoshi` 2019-10-09 16:51:42 -05:00
trueptolemy aafa16786d JSON-API: `fundchannel` uses `amount` fieldname to replace `satoshi` 2019-10-09 16:51:42 -05:00
trueptolemy 24575c9fa4 pylightning: Fix the compat of `txprepare` 2019-10-09 16:51:42 -05:00
Luca Ambrosini 11124fa3bf Add compability to current formalism to short_channel_id-to-txid.sh
* Add compatibility with the new shortchannelid syntax with x as separator

* Add an error message in case the parse failed, instead of receveing an unrelated error from the bitcoin-cli
2019-10-04 00:38:52 +00:00
Christian Decker 3418e59d76 pyln: Split pylightning into multiple pyln modules
This is the first step to transition to a better organized python module
structure. Sadly we can't reuse the `pylightning` module as a namespace module
since having importable things in the top level of the namespace is not
allowed in any of the namespace variants [1], hence we just switch over to the
`pyln` namespace. The code the was under `lightning` will now be reachable
under `pyln.client` and we add the `pyln.proto` module for all the things that
are independent of talking to lightningd and can be used for protocol testing.

[1] https://packaging.python.org/guides/packaging-namespace-packages/

Signed-off-by: Christian Decker <decker.christian@gmail.com>
2019-09-30 13:27:37 +02:00
Christian Decker 4e0c3f098c pylightning: Implement the lightning handshake and wire protocol
Simple transcript of the specification in python :-)

Signed-off-by: Christian Decker <decker.christian@gmail.com>
2019-09-30 13:27:37 +02:00
Rusty Russell aab9e9f010 gossipd: remove internal dev helpers for queries.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2019-09-30 07:08:07 +00:00
darosior 05a747c5ba contrib: Make cowsay answer 'init'
__________________________________
< I was not plugin specs compliant >
 ----------------------------------
        \   ^__^
         \  (oo)\_______
            (__)\       )\/\
                ||----w |
                ||     ||
2019-09-30 00:20:16 +00:00
Jorge Timón 152f9b66b9 pylightning: Responses may not be iterable 2019-09-26 11:37:53 +02:00
trueptolemy 2d184d464f pylightning: Fix the parameter `label` of `sendpay`
`description` is renamed as `label` in 0.7.0
2019-09-25 12:29:53 +02:00
trueptolemy 5361a5d059 JSON-API: `getroute` now also support `exclude` nodes 2019-09-16 12:22:06 +08:00
lisa neigut 5c70890efa rpc: add 'utxos' parameter to txprepare + withdraw
Allow a user to select the utxo set that will be added to a
transaction, via the `utxos` parameter. Optional.

Format for utxos should be of the form ["txid:vout","..."]
2019-09-11 23:56:27 +00:00
darosior e52af0d1ea doc: Document the new dependency 2019-09-10 02:17:27 +00:00
trueptolemy cdcafdaf74 API: `txprepare` now support mutiple outputs 2019-09-05 16:05:36 -05:00
Michael Schmoock bc5add399b pylightning: adds a millisatoshi test class 2019-09-03 19:02:04 +02:00
Michael Schmoock c0069d8944 pylightning: adds Millisatoshi __radd__ method for sum() 2019-09-03 19:02:04 +02:00
darosior 8f8e955421 Update installation instructions and Dockerfile
Get rid of the 'asciidoc' dependency, make developers also install 'doc/requirements.txt'
2019-08-30 00:34:11 +00:00
Rusty Russell c2f58aec9d contrib/plugins: cowsay
___________________________________________________________________________
/ The most important plugin. Ever. Much thanks to @practicalswift and @jb55 \
\ for their improvements!                                                   /
 ---------------------------------------------------------------------------
        \   ^__^
         \  (oo)\_______
            (__)\       )\/\
                ||----w |
                ||     ||

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2019-08-26 23:10:36 +00:00
Simon Vrouwe 2f5f364e17 pylightning/plugin: add `lightning_version` member to plugin 2019-08-26 15:39:03 -07:00
Rusty Russell 997af6f3f4 contrib: make stricter shellcheck from Ubuntu 18.04 happy
In contrib/bootstrap-node.sh line 7:
if type lightning-cli >/dev/null 2>&1; then
   ^-- SC2039: In POSIX sh, 'type' is undefined.

In contrib/startup_regtest.sh line 41:
	type lightning-cli || return
        ^-- SC2039: In POSIX sh, 'type' is undefined.

In contrib/startup_regtest.sh line 42:
	type lightningd || return
        ^-- SC2039: In POSIX sh, 'type' is undefined.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2019-08-23 08:22:28 -07:00
Sjors Provoost 55776c1605 systemd: After=network-online.target 2019-08-20 20:14:36 +02:00
Nicolas Dorier a358b9ab57 [Docker] Fixing the environment variable for arm32 2019-08-19 07:09:47 +00:00
Rusty Russell 403c054c4e contrib: add mako requirement to docker files.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2019-08-16 00:26:09 +00:00
nicolas.dorier 6cf42fe6c1 Add python-mako to the arm32 build 2019-08-12 05:44:11 +00:00
nicolas.dorier 19cf199f0e Add docker ARM64 support 2019-08-11 18:19:22 +02:00
Rusty Russell 7a592a2b5c contrib/startup_regtest.sh: avoid getting stuck in initialblockdownload.
And give a hint as to what cmds are available, since I forget!

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2019-08-10 19:07:13 +02:00
Rusty Russell 2a09124574 contrib/startup_regtest.sh: set sane defaults for lightning & bitcoin dirs.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2019-08-10 19:07:13 +02:00
Rusty Russell 83e654a106 close: change to a unilateraltimeout argument.
`close` takes two optional arguments: `force` and `timeout`.
`timeout` doesn't timeout the close (there's no way to do that), just
the JSON call.  `force` (default `false`) if set, means we unilaterally
close at the timeout, instead of just failing.

Timing out JSON calls is generally deprecated: that's the job of the
client.  And the semantics of this are confusing, even to me!  A
better API is a timeout which, if non-zero, is the time at which we
give up and unilaterally close.

The transition code is awkward, but we'll manage for the three
releases until we can remove it.

The new defaults are to unilaterally close after 48 hours.

Fixes: #2791
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2019-08-09 05:47:16 +00:00
lisa neigut 0bd95fc068 contrib: add txindex to bitcoind for regtest 2019-08-09 05:07:18 +00:00
Rusty Russell 2f30cdc731 contrib: simple script to bootstrap node.
The helpme plugin is more comprensive, but this at least connects to a
few random nodes, and doesn't require python libraries in path or anything.

I selected the nodes from helpme.py, eliminating ones I couldn't reach.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2019-08-07 21:13:17 +08:00
darosior ed63496152 Pylightning: update to use the 'dev' multiplex command
Update 'dev_crash()' and 'dev_rhash()' methods which used outdated RPC commands, add the missing 'dev_slowcmd()' method.
2019-08-07 01:50:42 +00:00
Christian Decker 9d4148ce68 pylightning: Warn users of plugins that may break due to extra args
We recently noticed that the way we unpack the call arguments for hooks and
notifications in pylightning breaks pretty quickly once you start changing the
hook and notification params. If you add params they will not get mapped
correctly causing the plugin to error out.

This can be fixed by adding a `VAR_KEYWORD` argument to the calbacks, i.e., by
adding a single `**kwargs` argument at the end of the signature. This commit
adds a check that such a catch-all argument exists, and emits a warning if it
doesn't.

It also fixes up the plugins that we ship ourselves.

Signed-off-by: Christian Decker <decker.christian@gmail.com>
2019-08-05 00:19:48 +00:00
darosior 12e28c2554 lightningd/plugin: Add a 'dynamic' field to getmanifest and a 'startup' field to init
This lets a plugin specify whether it can be restarted, and to know if it is started at lightningd startup
2019-07-28 07:24:04 +00:00
darosior 9ddc2e0334 Add the 'plugin' subcommands to pylightning and add a test for them 2019-07-28 07:24:04 +00:00
darosior 34533ead68 Plugins: Add a test for the 'invoice_payment' notfication 2019-07-25 11:19:47 +08:00
lisa neigut a6516f477b bash-completion: include underscores
`fundchannel_start` etc are not included in the bash-completion as
they include underscores in their names. this fixes this by including
underscores.
2019-07-09 13:23:14 +02:00
darosior 7ea5c5c00f Pylightning: allow to set description and long description manually
This just adds the possibility to set a command's descriptionS by hand, so that the method docstring can be used for something else
2019-07-02 19:30:50 +02:00
Jorge Timón 83f2ccd9fd pylightning: Add new listtransactions command
[ FIXUP: Uninitialized var response used as context, changed to cmd --RR ]
2019-06-22 04:24:02 +00:00
lisa neigut c00e0d2936 funding: rename fundchannel_continue -> _complete
Renaming. "complete" more accurately describes what we're doing here.
2019-06-12 02:22:43 +00:00
lisa neigut 5aad642c59 opening: add fundchannel_cancel command
Provide the option to cancel a funding-opening with a peer.
Must either call `fundchannel_cancel` or `fundchannel_continue`
2019-06-12 02:22:43 +00:00
lisa neigut 7ea21c36b1 fundchannel: add txout field to RPC/API
We'll need the outpoint for the funding output.
2019-06-12 02:22:43 +00:00
lisa neigut dd11d3bd81 lightningd: add start for fundchannel_continue
Add an RPC method (not working at the moment) called
`fundchannel_continue` that takes as its parameters a
node_id and a txid for a transaction (that ostensibly has an output
for a channel)
2019-06-12 02:22:43 +00:00
lisa neigut 23e7846053 pylightning: add fundchannel_start
Add method to rpc handler
2019-06-12 02:22:43 +00:00
Rusty Russell adc4bf1817 pylightning: remove 0.6.2 JSON compat wedge.
The next commit breaks it: `if b' }\n' not in buff:` is always true since
we're about to clean up our JSON so there won't be a space.  I could have
hacked the space in our JSON, but 6 months is long enough anyway.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2019-06-12 02:00:15 +00:00
darosior 1b29b063b2 fundchannel: Update the manpage and Pylightning's method
Add the new 'utxo' parameter to both
2019-06-11 23:24:07 +00:00
Rusty Russell 403b861fc7 pylightning: interfaces for txprepare/txsend/txdiscard.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2019-06-06 04:47:44 +00:00
Christian Decker 2b81e02a2e plugin: Parse response for htlc_accepted hook
Signed-off-by: Christian Decker <decker.christian@gmail.com>
2019-06-04 00:27:15 +00:00
Christian Decker bf53821f1a plugin: Populate the request for the htlc_accepted hook
Signed-off-by: Christian Decker <decker.christian@gmail.com>
2019-06-04 00:27:15 +00:00
Christian Decker b54577041a pytest: Add a simple test for the hooks
This uses the `htlc_accepted` hook to delay payment acceptance.

Signed-off-by: Christian Decker <decker.christian@gmail.com>
2019-06-04 00:27:15 +00:00
darosior 3775a32659 Pylightning: allow to specify the option type at its creation 2019-06-03 00:06:12 +00:00
darosior 78326a8d90 Pylightning: Allow a plugin to set the category of the RPC commands it creates 2019-06-03 00:02:25 +00:00
lisa neigut be502a095d devscript: always clean up pid files for lightning daemons 2019-05-24 16:06:35 +02:00
Michael Schmoock 0efd72d882 test: pylightning to_approx_str 2019-05-22 22:13:06 +02:00
Michael Schmoock d8599e5f67 pylightning: adds msat.to_approx_str() method
Tries to return the approxmost posible string of a Millisatoshi amount using
various unit representations. The function will round to an effective
number of digits. Default: 3.

```
>>> Millisatoshi("100000sat").to_approx_str()
'0.001btc'
>>> Millisatoshi("100msat").to_approx_str()
'0.1sat'
>>> Millisatoshi("10000000sat").to_approx_str()
'0.1btc'
```
2019-05-22 22:13:06 +02:00
Rusty Russell ee303e4a94 contrib: fix up bash completion script.
$ lightning-cli <TAB><TAB>
autocleaninvoice               dev-slowcmd                    listinvoices
check                          dev-suppress-gossip            listnodes
close                          disconnect                     listpayments
connect                        feerates                       listpays
decodepay                      fundchannel                    listpeers
delexpiredinvoice              getinfo                        listsendpays
delinvoice                     getlog                         newaddr
dev-compact-gossip-store       getroute                       -o
dev-crash                      -h                             --order
dev-fail                       -H                             pay
dev-forget-channel             --help                         paystatus
dev-ignore-htlcs               help                           ping
dev-listaddrs                  --human-readable               --rpc-file
dev-memdump                    invoice                        sendpay
dev-memleak                    -J                             setchannelfee
dev-query-channel-range        --json                         stop
dev-query-scids                -k                             -V
dev-reenable-commit            --keywords                     --version
dev-rescan-outputs             --lightning-dir                waitanyinvoice
dev-rhash                      listchannels                   waitinvoice
dev-send-timestamp-filter      listconfigs                    waitsendpay
dev-set-max-scids-encode-size  listforwards                   withdraw
dev-sign-last-tx               listfunds

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2019-05-22 00:46:54 +00:00
darosior 862ae87389 Fix bash completion 2019-05-22 00:46:54 +00:00
darosior 67d20ae842 Add 'paystatus' method 2019-05-18 22:18:39 +02:00
darosior a7ef7b47c8 Pylightning: add 'listconfigs' and 'listsendpays' RPC methods, correct 'invoice' docstring 2019-05-18 22:18:39 +02:00
Sjors Provoost b95e10c354 systemd: wait until network is up
Prevents error when launching with bind-addr.
2019-05-16 19:30:38 +02:00
darosior 12f703eb82 pylightning: Add missing RPC command as LightningRpc methods
Added 'autocleaninvoice', 'check', 'setchannelfee'
2019-05-13 21:11:53 +02:00
darosior efecd64bf3 pylightning: Reorder LightningRpc methods alphabetically 2019-05-13 21:11:53 +02:00
darosior b7279e9130 Add 'delexpiredinvoice' to pylightning 2019-05-11 17:11:01 +02:00
Christian Decker ff5dfb1cc4 pylightning: Clean up the argument binding
We had a bit of a hand-woven mess in there, trying to inject the extra
arguments in the correct places. We now instead treat positional and keyword
calls separately and can go back to using the builtin argument binding again.

Signed-off-by: Christian Decker <decker.christian@gmail.com>
2019-05-10 23:07:49 +00:00
Michael Schmoock 1e0aa9329d fix: pylightning to_btc_str precision
The old codes if % 1000 statement logic was simply inverted
and produced the opposite output of the intention behin it.

Before Fix:
 - Millisatoshi('42sat').to_btc_str() => 0.00000042000btc
 - Millisatoshi('42001msat').to_btc_str() => 0.00000042btc

After  Fix:
 - Millisatoshi('42sat').to_btc_str() => 0.00000042btc
 - Millisatoshi('42001msat').to_btc_str() => 0.00000042001btc
2019-05-08 18:18:19 -05:00
Christian Decker eeecfc983c plugin: Remove autopatch argument from helloworld plugin
Suggested-by: Rusty Russell <@rustyrussell>
2019-04-30 17:56:09 -05:00
Michael Schmoock f99c461fed fix: pylightning msat round multiply and division
Currently, when a multiplication operator is invoked that
does not result in an even integer result but a floating result,
the pylightning code will raise an exception:

Millisatoshi must be string with msat/sat/btc suffix or int

This is because the internal float result will be used as
contructor argument like this:  return Millisatoshi(10000.5)

This happens especially on fee calculations where small uneven amounts
are calculated.
2019-04-29 19:10:56 +02:00
Hampus Sjöberg 3028964687 pylightning: Fixing incompatibility issue with Python 2.7
Global open doesn't have argument `encoding` in Python 2.7.
open from the io package is needed.
2019-04-23 23:39:57 +02:00
Gálli Zoltán 7f8e4de522 pylightning: millisatoshis type is int
Millisatoshi's inner representation expected to be an int, otherwise unwanted exceptions could occur
The following example raises: TypeError: __int__ returned non-int (type decimal.Decimal)

from lightning import Millisatoshi
one_sat = Millisatoshi("1sat")
two_sats = one_sat * 2
2019-04-17 07:12:43 +00:00
lisa neigut 9d20e95155 contrib-script: encapsulate more things
make a start + stop function, so that you can load this script
into other places and start/stop the services in the background.
2019-04-12 15:26:08 -07:00
lisa neigut eb8336331f contrib-script: make it so that you can source everywhere
the aliases are nice to have in other windows; if you want to
source it other places, we should make that possible.
2019-04-12 15:26:08 -07:00
lisa neigut 1d5475197e contrib script: add instructions for use 2019-04-12 15:26:08 -07:00
lisa neigut 99f20d8dd1 contrib: short script to startup two nodes to test locally
make it easier to fire up a local test environment to try out
c-lightning.

requires bitcoind to be installed. to use, you have to run it
via `source contrib/startup_regtest.sh`, so that the aliases
are set correctly.
2019-04-12 15:26:08 -07:00
Douglas Schilling Landgraf 3852704c5c contrib: Dockerfile.builder.fedora bump fedora release
Updated Dockerfile to Fedora 29
2019-03-22 17:13:16 +01:00
nicolas.dorier 3e215287cd Use tini as docker entrypoint 2019-03-19 14:26:03 +01:00
Billy Garrison 99adea5988 pylightning: update getroute() docstring 2019-03-19 14:24:11 +01:00
Billy Garrison 132028bd7f pylightning: update getroute() parameters
Removes `seed` and adds `maxhops`
2019-03-19 14:24:11 +01:00
wailo e843e138fe Fix installing plugins in dockerfile (#2451)
* Improved plugin install in docker

- All files generated by 'make install' are copied
- Fixes issues with incomplete installation.
- Example: New executables created by build but are missing in docker.
2019-03-11 09:51:47 +01:00
Rusty Russell 1facf626d5 pylightning: allow version querying from within modules.
With the preceeding UTF-8 fix, I'd like to detect UTF-8 support.  But
AFAICT Python doesn't have a standard way of doing version exposure.

So I added __version__, but now we need to make sure it matches.  I
used the hackiest possible method.

[ Christian Decker fixed version to be sane, so previous comment no longer
  applies! --RR ]
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2019-03-05 11:43:22 +01:00
Rusty Russell cc342fda83 pylightning: make sure UTF-8 gets passed intact.
1. We need to read in as a byte string, then decode into utf8 once we
   have a marker.  Otherwise we seem to mangle it horribly, and we
   might have a bad utf8 string anyway.

2. We need to suppress the JSON \u escapes on output.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2019-03-05 11:43:22 +01:00
Christian Decker 61f95be0e9 pylightning: Bump version so pypi includes plugin infra 2019-03-04 00:41:40 +00:00
nicolas.dorier 063149079e Installing the Pay plugin in Dockerfile for arm32v7 2019-03-02 15:21:57 +01:00
Rusty Russell 6e63d79159 pylightning: translate msat input to class Millisatoshi
Rather than using LightningJSONDecoder's implicit "field name and
value ends in msat, try converting to Millisatoshi", we do it to
parameters using type annotations.

If you had a parameter which was an array or dict itself, we don't
delve into that, but that's probably OK.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2019-02-25 21:45:21 +00:00
Rusty Russell 690064f7e0 pylightning: don't compare v with inspect._empty.
I originally converted input JSON naively into Millisatoshi, and the
result was a strange failure in Millisatoshi.__eq__.

It seems this is because inspect._empty.__eq__(Millisatoshi) raises
NotImplemented, and so it tries Millisatoshi.__eq__(inspect._empty)
which doesn't like it.

'is' is the correct test here, AFAICT, and doesn't suffer from these
problems.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2019-02-25 21:45:21 +00:00
Rusty Russell 6ace13ba22 pylightning: make plugins use Millisatoshi-converting encoder.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2019-02-25 21:45:21 +00:00
Rusty Russell 5a7d038e6e pylightning: provide a class for Lightning JSONDecoder.
Some JSON functions want a *class*, not just a hook, so provide one.
To make it clear that we want an encoding *class* and a decoding *object*,
rename the UnixDomainSocketRpc encode parameter to encode_cls.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2019-02-25 21:45:21 +00:00
Rusty Russell 464858883b pylightning: reduce scope for deadlock in plugins.
If we can't marshall an object into JSON, the exception causes a deadlock
and we don't get any results.

Instead of deadlocking, our failure now is:

	lightning.lightning.RpcError: RPC call failed: method: echo, payload: {'msat': 17msat}, error: Error while processing echo: TypeError("Object of type 'Millisatoshi' is not JSON serializable",)

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2019-02-25 21:45:21 +00:00
Rusty Russell 1982c73ebc pylightning: support functions with type annotations.
I tried annotating the plugin-millisatoshis.py plugin, and it failed like so:

	plugin-millisatoshis.py Killing plugin: "getmanifest" result is not an object: {"jsonrpc": "2.0", "id": 1, "error": "Error while processing getmanifest: ValueError(\'Function has keyword-only parameters or annotations, use getfullargspec() API which can support them\',)"}'

So, let's do that!

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2019-02-25 21:45:21 +00:00
Rusty Russell 1ec959752b plugin/pay: rename 'description' to 'label', deprecate 'description'.
This is the same deprecation, but one level up.  For the moment, we
still support invoices with a `h` field (where description will be
necessary) but that will be removed once this option is removed.

Note that I just changed pylightning without backwards compatibility,
since the field was unlikely to be used, but we could do something
more complex here?

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2019-02-23 05:45:25 +00:00
Christian Decker e79fbb6812 pylightning: Fix missing encode if first pass fails
Without this the RPC will fail to continue buffering if the response does not
fit in the first read, and if we don't switch over to the non-compat
mode. This was introduced by our mitigation of the UTF-8 misalignment, but I
missed this path.

Signed-off-by: Christian Decker <decker.christian@gmail.com>
2019-02-22 11:05:24 -08:00
Christian Decker 04ffa5a413 pylightning: Add some more documentation for the python lib
It was looking a bit minimal on pypi :-)

Signed-off-by: Christian Decker <decker.christian@gmail.com>
2019-02-22 17:55:36 +01:00
Christian Decker 683b601dc7 pylightning: Expose minconf in fundchannel and withdraw
Signed-off-by: Christian Decker <decker.christian@gmail.com>
2019-02-22 10:40:59 +00:00
Christian Decker f622ffb087 pylightning: Add plugin dispatch tests to check-python and fix them
These weren't checked by CI yet, and they are really short so I just added
them to the check-python target.

Signed-off-by: Christian Decker <decker.christian@gmail.com>
2019-02-22 02:59:36 +00:00
Christian Decker 7f11b4854e pylightning: Split @method and @async_method decorators
Suggested-by: Rusty Russell <@rustyrussell>
Suggested-by: Conor Scott <@conscott>
Signed-off-by: Christian Decker <decker.christian@gmail.com>
2019-02-22 02:59:36 +00:00
Christian Decker d9c3f5ec4b pylightning: Rename peer_id to node_id in getroute
Technically this is a node, not a direct peer, so this is correct.

Signed-off-by: Christian Decker <decker.christian@gmail.com>
2019-02-22 02:59:36 +00:00
Christian Decker cc4fbfca43 pylightning: Add the `background` keyword to hooks and methods
This indicates that the method or hook will accepts a request
parameter, and will use that to return the result or raise an
exception instead of returning the return value. This allows the hook
or method to stash the incomplete request or pass it around, without
blocking the JSON-RPC interface.

Signed-off-by: Christian Decker <decker.christian@gmail.com>
2019-02-22 02:59:36 +00:00
Christian Decker 9670b4382f pylightning: Don't always use request ID 0
This isn't a problem for now since we don't support multithreading,
and only allow synchronous calls, but eventually this'll become
important.

Signed-off-by: Christian Decker <decker.christian@gmail.com>
2019-02-22 02:59:36 +00:00
Christian Decker f452d00b77 pylightning: Add support for *args and **kwargs in plugin dispatch
These are a bit special and are handled separately.

Signed-off-by: Christian Decker <decker.christian@gmail.com>
2019-02-22 02:59:36 +00:00
Christian Decker 8de1a85ac0 pylightning: Exception if we have unfulfilled positional arguments
This caused me to backtrack quite a bit, so this should help debugging
in the future.

Signed-off-by: Christian Decker <decker.christian@gmail.com>
2019-02-22 02:59:36 +00:00
Christian Decker 81fa247d07 pylightning: Wrap request in an object
We well need this in the next commit to be able to return from an
asynchronous call. We also guard stdout access with a reentrant lock
since we are no longer guaranteed that all communication happens on
the same thread.

Signed-off-by: Christian Decker <decker.christian@gmail.com>
2019-02-22 02:59:36 +00:00
Christian Decker 71795d4d6a pylightning: Wrap the plugin methods in a class
Sending around unnamed tuples is bound to cause some issues sooner or
later, so we just create a quick class that holds all the information
about a plugin method.

Signed-off-by: Christian Decker <decker.christian@gmail.com>
2019-02-22 02:59:36 +00:00
Conor Scott d96564ce3e pylightning: raise Error when missing rpc parameter 2019-02-21 14:23:01 +01:00
Rusty Russell cc95a56544 pylightning: handle msat fields in JSON more appropriately.
Little point having users handle the postfixes manually, this
translates them, and also allows Millisatoshi to be used wherever an
'int' would be previously.

There are also helpers to create the formatting in a way c-lightning's
JSONRPC will accept.

All standard arithmetic operations with integers work.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2019-02-21 03:44:44 +00:00
Rusty Russell 1c542bcd08 pylightning: prepare plugin for parameters to getmanifest.
We might still add these in future, so I think we should allow for it.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2019-02-21 00:44:57 +00:00
Christian Decker ac6d9b34cc pylightning: Correctly return the remainder of a message back
We read a JSON message from the buffer, after converting it from raw bytes to
UTF-8, and returning the remainder of the byte array back to the
caller. However the return value of `raw_decode` refers to symbols in the
UTF-8 decoded string, not the raw bytes underlying byte-array, which means
that if we have multi-byte encoded UTF-8 symbols in the byte-array we end up
with a misaligned offset and will return part of the message as
remainder. This would then end up being interpreted as the result of the next
call.

This could not be exploited currently since we use a socket only for a single
JSON-RPC call and will close the connection afterwards, but since we want to
eventually recycle connections for multiple calls, this could have been very
dangerous.

Signed-off-by: Christian Decker <decker.christian@gmail.com>
Reported-by: Corné Plooy <@bitonic-cjp>
2019-02-18 02:10:43 +00:00
Conor Scott 960664337f pylightning: handle method introspection more generally.
[ I just cut & paste from @conscott's comment on GitHub -- RR ]
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2019-02-07 20:33:50 +00:00
Conor Scott 6e4eae372d [pylightning] add args list to getmanifest
[ Shamelessly stolen by Rusty, tweaked parameter name ]
2019-02-07 20:33:50 +00:00
Rusty Russell 0c89fc5d70 pylightning: use different decoration for init msg.
The next patch wants to decorate the methods with a compulsory
'usage' option, which doesn't make sense for init.  So I wanted
to change the init to its own decoration.

Made-to-work-by: @cdecker
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2019-02-07 20:33:50 +00:00
Rusty Russell a1ebfc9e5e pylightning: help() accepts an argument.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2019-02-07 20:33:50 +00:00
Christian Decker 35e4227015 docker: Do not use the copy of a clone
This was failing the docker hub builds, since the git-config retains
an absolute path to the worktree location when cloning. Copying it
over from the host system means that this path now points to a
non-existent location, which then interfered with the submodule
initialization.

This fixes it by not using the copy directly, but rather it creates a
clean clone from the copied location, including a submodule init.

Signed-off-by: Christian Decker <@cdecker>
2019-02-07 03:07:18 +00:00
Christian Decker 1c8b980985 pylightning: Handle empty log lines correctly
Logging an empty line (without newline character) would raise an
Exception due to out of bounds check.

Signed-off-by: Christian Decker <decker.christian@gmail.com>
2019-01-29 00:50:09 +00:00
arowser c029f2fb0f remove unused local var 2019-01-25 23:01:56 +01:00
Christian Decker c78d7e0f95 plugin: Increase manifest timeout to 60 seconds
Valgrind seems to be slowing the pay-plugin down enough for the 10
seconds timeout to get triggered on a semi-regular basis.

Reported-by: Rusty Russell <@rustyrussell>
Signed-off-by: Christian Decker <decker.christian@gmail.com>
2019-01-20 03:06:03 +00:00
Rusty Russell 0a8b4f8935 pay: remove inbuilt command in favor of plugin.
This doesn't actually remove some of the now-unnecessary infrastructure
though.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2019-01-17 13:02:24 +01:00
Rusty Russell 40637d0017 contrib/pylightning: temporarily convert to use plugin/pay for tests.
That this simply pay plugin passes the tests is a poor reflection on our
test cases, really.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2019-01-17 13:02:24 +01:00