Commit Graph

453 Commits

Author SHA1 Message Date
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
Christian Decker 025fbbc9ea pylightning: Always assign the `init` method in plugin
Also fixes a crash if the doc was empty.
2019-01-17 05:42:49 +00:00
Christian Decker a707ae091d pylightning: Add hooks as a new type of method
Instead of creating a new map I opted to re-use the Plugin.methods
map, since the semantics are really similar and we don't allow
duplicates. The only difference is in how they are announced to
lightningd, so we use an enum to differentiate rpcmethods from hooks,
since only the former will get added to the JSON-RPC dispatch table in
lightningd.

Signed-off-by: Christian Decker <decker.christian@gmail.com>
2019-01-17 05:42:49 +00:00
Rusty Russell 80753bfbd5 Feedback from @niftynei.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2019-01-15 12:01:38 +01:00
Rusty Russell dc2ee9639b listchannels: allow source arg to list channels by their source node.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2019-01-15 12:01:38 +01:00
Rusty Russell 3d016e7249 getroute: allow array of channels to exclude.
The pay plugin will use this, rather than the current "suppress for 90 second" hacks.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2019-01-15 12:01:38 +01:00
Rusty Russell 1567238dd9 invoice: option to expose/not-expose private channels.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2019-01-15 12:01:38 +01:00
Rene Pickhardt 6b5db38774 pylightning: Made rpc a public member of Plugin and sorted imports
After this code change people can use `plugin.rpc` from anywhere in
their plugin code this is much nicer than going this way:

```
@plugin.method("init")
def init(options, configuration, plugin):
    global rpc
    basedir = plugin.lightning_dir
    rpc_filename = plugin.rpc_filename
    path = os.path.join(basedir, rpc_filename)
    rpc = LightningRpc(path)
```

or similarly that way:
```
@plugin.method("init")
def init(options, configuration, plugin):
    global rpc
    basedir = configuration['lightning-dir']
    rpc_filename = configuration['rpc-file']
    path = os.path.join(basedir, rpc_filename)
    rpc = LightningRpc(path)
```

Also the imports have been sorted alphabetically

Co-authored-by: Rene Pickhardt <rene@rene-pickhardt.de>
Co-authored-by: Christian Decker <decker.christian@gmail.com>
2019-01-12 22:12:01 +01:00
Christian Decker e0621fa8f7 pylightning: Better inject arguments in plugin method calls
If the `request` or `plugin` parameter that are injected by the
framework where before or inbetween positional arguments we'd be
injecting them incorrectly, i.e., we'd be providing them both as
`args` (and mismapping another argument) as well as `kwargs`.

This is a better way to map arguments, which takes advantage of the
fact that JSON-RPC calls are either all positional or named arguments.

I also included a test for various scenarios, that hopefull cover the
most common cases.

Reported-by: Rene Pickhardt <@renepickhardt>
Signed-off-by: Christian Decker <decker.christian@gmail.com>
2019-01-08 17:37:00 +01:00
nicolas.dorier 6f027a24a0 Add dockerfile for cross compiling arm32v7 image 2019-01-04 22:48:20 +01:00
Rene Pickhardt 0321d79540 [plugin] Improved the example code to encourage usage of optional arguments (#2212)
The example code had the `plugin` argument as the last argument. this disallows arguments that have a standard value. As far as I understand the dispatching code the order of arguments does not matter since it is the name `plugin` that is relevant. Therefor I changed the order so that newbe's don't have to read the entire code and can easily add optional arguments
2019-01-02 23:16:56 +01:00
Christian Decker 4f16044404 fixup! pylightning: Added a tiny library for python plugins 2018-12-30 14:36:02 +01:00
Christian Decker 25ca49c444 pytest: Add a test for the event subscription and notification
Signed-off-by: Christian Decker <decker.christian@gmail.com>
2018-12-30 14:36:02 +01:00
Christian Decker 5338d3115f pylightning: Add notification subscription handlers
Just like we added the RPC methods, the notification handlers can also
be registered using a function decorator, and we auto-subscribe when
asked for a manifest.

Signed-off-by: Christian Decker <decker.christian@gmail.com>
2018-12-30 14:36:02 +01:00
Christian Decker 7314c71695 pylightning: Increase buffer size for big JSON-RPC responses
This was causing `listchannels` to be incredibly slow. The response is
several megabyte in size, and we were only buffering 1Kb on each
iteration.

Signed-off-by: Christian Decker <decker.christian@gmail.com>
2018-12-29 12:19:56 +01:00
Christian Decker 42d8e07d70 pylightning: Merge option_values into options
Suggested-by: Rusty Russell <@rustyrussell>
Signed-off-by: Christian Decker <decker.christian@gmail.com>
2018-12-15 15:04:32 +01:00
Christian Decker 1eb23d6b29 pylightning: Split log messages on newlines
This is just cosmetic, and makes things like tracebacks much easier to
read.

Signed-off-by: Christian Decker <decker.christian@gmail.com>
2018-12-15 15:04:32 +01:00
Christian Decker 643480cfd8 pylightning: Migrate the test plugin to use the new wrapper
Should be a lot easier to see what happens :-)

Signed-off-by: Christian Decker <decker.christian@gmail.com>
2018-12-15 15:04:32 +01:00
Christian Decker d88228280e pylightning: Add option handling to the plugin library
Signed-off-by: Christian Decker <decker.christian@gmail.com>
2018-12-15 15:04:32 +01:00
Christian Decker ada69e7943 pylightning: Added a tiny library for python plugins
It's flask inspired with the Plugin instance and decorators to add
methods to the plugin description.

Signed-off-by: Christian Decker <decker.christian@gmail.com>
2018-12-15 15:04:32 +01:00
Christian Decker a304db9be2 plugin: Handle log notifications from plugins
Logs are parsed and injected into the main daemon's logs.

Signed-off-by: Christian Decker <decker.christian@gmail.com>
2018-12-13 02:36:43 +00:00
Rusty Russell 19ecf8c6fb disconnect: add force option to disconnect even with a live channel.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2018-12-10 22:25:32 +00:00
William Casarin db9e250df8 python: fix check-python errors in plugins
Fixes some lint errors with unused variables:

contrib/plugins/fail/failtimeout.py:48:5:
  F841 local variable 'e' is assigned to but never used

contrib/plugins/helloworld.py:86:5:
  F841 local variable 'e' is assigned to but never used

Signed-off-by: William Casarin <jb55@jb55.com>
2018-12-10 20:03:05 +01:00
Conor Scott 6470630db9 [doc] Add lightning-pay script as example for using pylightning library 2018-12-10 17:07:34 +01:00
lisa neigut a39c97c960 channeld: support private channel creation, fixes #2125
Adds a new 'announce' field for `fundchannel`, which if false
won't broadcast a `channel_announcement`.
2018-12-08 15:15:55 -08:00
Christian Decker be7674ed6c plugin: Added .params.configuration to init call
This tells the plugin both the `lightning-dir` as well as the
`rpc-filename` to use to talk to `lightningd`. Prior to this they'd
had to guess.

Signed-off-by: Christian Decker <decker.christian@gmail.com>
2018-12-07 17:17:53 +01:00
Christian Decker 5b6bb7c571 pylightning: Bump version number to 0.0.6 to make Pypi work again
Fixes #2135

Signed-off-by: Christian Decker <decker.christian@gmail.com>
2018-12-07 10:29:21 +01:00
Christian Decker bd6e3bfe6a pylightning: Add a compatibility mode for pre-\n\n versions
We inadvertently broke the compatibility between the python library
and the binary when switching to \n\n-delimiters. This reintroduces
the old inefficient parsing, and dynamically upgrades to the faster
version if it detects the \n\n-delimiter.

Signed-off-by: Christian Decker <decker.christian@gmail.com>
2018-12-07 10:29:21 +01:00
Christian Decker a50529bcb0 pylightning: Allow both kwargs as well as positional args
We don't allow a mix (just like JSON-RPC), but we can use either or
now.

Signed-off-by: Christian Decker <decker.christian@gmail.com>
2018-12-07 10:29:21 +01:00
Christian Decker f5a3f1f0a2 plugin: Add a test for timeout and broken manifest
Both of these plugins will fail in interesting ways, and we should
still handle them correctly.

Signed-off-by: Christian Decker <decker.christian@gmail.com>
2018-12-05 23:15:59 +00:00
Christian Decker 0f72e0bce8 plugin: The example plugin can now return errors
Signed-off-by: Christian Decker <decker.christian@gmail.com>
2018-12-02 22:55:47 +00:00
Christian Decker 1e139e412b plugin: Allow both array as well as object params in example plugin
Signed-off-by: Christian Decker <decker.christian@gmail.com>
2018-12-02 22:55:47 +00:00
Christian Decker 879f9b7986 plugin: Make a common directory of plugins in contrib
No need to create a directory each.

Signed-off-by: Christian Decker <@cdecker>
2018-11-26 22:53:37 +00:00
Christian Decker e27b2ea69b pytest: Add a test for the plugin option passthrough
Signed-off-by: Christian Decker <@cdecker>
2018-11-26 22:53:37 +00:00
Christian Decker 0040673e90 docker: Update pytest dependencies in the builder image
Adds timeout and progress to the output.

Signed-off-by: Christian Decker <decker.christian@gmail.com>
2018-11-26 22:53:37 +00:00
Rusty Russell b9b7411d88 lightning.py: use double-\n as marker for RPC parsing.
This doesn't make a performance difference, but even better, it
simplifies the code.

We hacked test_multirpc to send 200x as many commands, and timed the
pytest over 20 runs:

Before:
=================== 1 passed, 136 deselected in 8.550000-9.400000(9.0045+/-0.2) seconds ===================

After:
=================== 1 passed, 136 deselected in 8.540000-9.370000(8.97286+/-0.16) seconds ===================

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2018-11-19 21:36:40 +01:00
Rusty Russell 0c3f85d931 lightning.py: parse multiple JSON RPC commands accurately.
We need to keep the remaining buffer, and we need to try to parse it
before we read the next.  I first tried keeping it in the object, but
its lifetime is that of the *socket*, which we actually reopen for
every command.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2018-11-19 21:36:40 +01:00
Conor Scott 9a0f3a764c [pylightning] Fix lightning-pay script 2018-11-19 21:24:03 +01:00
Christian Decker 6c649ce775 docs: Mention that msatoshi on pay is not optional, but ignored
Reported-by: Tim Horie <@thorie7912>
Signed-off-by: Christian Decker <@cdecker>
2018-11-13 06:17:50 +01:00
Christian Decker 2b3059be0c plugin: Have the helloworld plugin accept a configure message
Just customizes the greeting, the actual sending is in the next commit.

Signed-off-by: Christian Decker <@cdecker>
2018-11-13 00:44:50 +01:00
Christian Decker 55d6d6b0e7 plugin: Register plugin cli options
We also make `--help` a non-early arg so it allows for the plugins to
register their options before printing the help message. The options
themselves are stored in a separate struct inbetween them being
registered and them being forwarded to the plugin. Currently only
supports string options.

Signed-off-by: Christian Decker <@cdecker>
2018-11-13 00:44:50 +01:00
Christian Decker d0de6e59c6 plugin: Start each plugin and setup the connection to it
Mostly copied from bitcoind.c
2018-11-13 00:44:50 +01:00
Christian Decker f7116c3a43 plugins: Add simple helloworld plugin to test against
It does double duty to show how a simple plugin might work.
2018-11-13 00:44:50 +01:00
Rusty Russell f3329d6013 pylightning: add msatoshi optional sendpay param.
And there's a difference between no description and "" as a description:
for no description, listpayments doesn't show the field at all.  So fix
that.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2018-10-23 16:47:32 +02:00
Christian Decker 6b7546b94d json-rpc: Rename `getroutestats` and move stats to getinfo
Signed-off-by: Christian Decker <@cdecker>
2018-10-19 21:58:27 +00:00
Christian Decker facd7d16aa json-rpc: Add `listforwardings` command 2018-10-19 21:58:27 +00:00
Christian Decker e904fcc00c docker: Update docker images and docs to non-CVE-2018-17144 bitcoind
While not strictly necessary it's certainly a good idea to test
against the latest one and not encourage users to use old versions.

Reported-by: Jonas Nick <@jonasnick>
Signed-off-by: Christian Decker <@cdecker>
2018-10-15 23:05:25 +00:00
Christian Decker 0a5c45e8b1 docker: Prepare builder to include flask and cherrypy
This is in preparation for the next commit.
2018-09-16 00:05:34 +02:00
Christian Decker b861e44f36 docker: Add missing dependencies to builder for `a2x` 2018-09-14 21:19:50 +02:00
Rusty Russell e0952ceff2 feerate: use suffix, not separate argument.
And, reluctantly, default to bitcoind style.
"It's wrong to be right too soon."

Suggested-by: @cdecker
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2018-08-30 16:33:35 +02:00
Rusty Russell 14dc1c37ab fundchannel / withdraw: allow explicit feerate setting.
These are the two cases where we'll refuse without a fee estimate.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2018-08-30 16:33:35 +02:00
Rene Pickhardt 5848a5c718 channel_id unknown at funding time. Needs to be node_id
No semantical change but when using the python lib for the rpc-api it is confusing that my developing environment suggests that I should fund a channel and pass a channel_id when in fact I want to pass a node_id
2018-08-28 00:53:57 +00:00
Rusty Russell c7c5affa3f feerates: new command to inject/query fee estimates.
This is useful mainly in the case where bitcoind is not giving estimates,
but can also be used to bias results if you want.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2018-08-25 00:33:12 +00:00
Rusty Russell d93be58bd0 pytest: remove use dev-override-feerates.
Manipulate fees via fake-bitcoin-cli.  It's not quite the same, as
these are pre-smoothing, so we need a restart to override that where
we really need an exact change.  Or we can wait until it reaches a
certain value in cases we don't care about exact amounts.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2018-08-24 02:17:51 +00:00
Rusty Russell 2314a4aa5d contrib/short_channel_id-to-txid.sh: simple mapping util.
I use this to look up on smartbit.com.au to see if a channel is spent,
for example.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2018-08-21 22:53:45 +02:00
Douglas Schilling Landgraf 0a5dc713f0 contrib: add init file for systemd
Similar to init/bitcoind.service, this patch
includes an initial lightningd.service.

[ Squashed "trivial, fix comment" -- RR ]
2018-08-13 23:55:12 +00:00
Rusty Russell 71575b2115 ping: no longer a dev_ command.
Fixes: #1407
Suggested-by: conanoc@gmail.com
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2018-08-10 12:46:45 +02:00
Rusty Russell 60b95d4764 pylightning: add method and payload as proper fields.
They're much more useful being programatically-accessible, AFAICT.

The string stays the same so they're backwards compatible.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2018-08-08 16:05:58 +02:00
Douglas Schilling Landgraf ea6c0d4506 contrib: Dockerfile.builder.fedora bump fedora release
Fedora 28 released
2018-08-05 13:09:58 +02:00
Christian Decker 1738107598 json-rpc: Add description argument to `sendpay` 2018-07-30 03:04:45 +00:00
Christian Decker 356dcbba97 pylightning: Don't attempt to deserialize after every read
We make use of the structure of the final read to decide when to deserialize.
2018-07-16 00:24:04 +00:00
Bertrand Marlier 760b053d7b pylightning: fix incorrect description for disconnect() method 2018-07-15 18:40:48 +02:00
gallizoltan 1220a4eb1d pylightning: add missing arguments to getroute 2018-07-13 13:12:49 +02:00
Christian Decker 13796f0d0f travis: Add xmllint to the builder image
Seems that it is required for the manpage conversion.
2018-07-05 00:24:33 +00:00
Christian Decker 582ea1a33b jsonrpc: Remove `dev-blockheight` in favor of `getinfo`
`getinfo` has been providing the blockheight for a good while and doesn't
require the `DEVELOPER=1` flag during compilation, so it should be the preferred
method to retrieve the blockchain height.
2018-07-04 00:08:14 +00:00
arowser fecef618bc remove duplicate line 2018-07-01 04:14:10 +00:00
Christian Decker 6c82d1b8b0 pylightning: Subclass ValueError to access to the returned error 2018-07-01 04:13:04 +00:00
Christian Decker e35da01d11 travis: Add asciidoc, excluding latex, to the builder images
Fixes #1641
2018-07-01 04:12:45 +00:00
Christian Decker 1899e000d6 docker: Add two more dependencies to the fedora builder
Strictly speaking not needed for the build and test, but if we want to use the
image also for packaging this is required.

Signed-off-by: Christian Decker <decker.christian@gmail.com>
2018-06-21 23:04:10 +00:00
Rusty Russell f52245d442 gossipd: support and use zlib encoding in short_channel_id encoding.
We still use uncompressed if zlib turns out to be larger.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2018-06-06 03:25:56 +00:00
Rusty Russell c633cbe2ee tests: add dev-query-scids
And write the test for it.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2018-06-06 03:25:56 +00:00
Christian Decker 957b32affe contrib: Add the flaky dependency to the builder image
Signed-off-by: Christian Decker <decker.christian@gmail.com>
2018-05-07 02:40:50 +00:00
Christian Decker 71857bad8e builder: Add the ephemeral-port-reserve dependency to the builder
Signed-off-by: Christian Decker <decker.christian@gmail.com>
2018-05-07 02:40:50 +00:00
Christian Decker e308423954 travis: Fix the locale in the builder images
These were spamming the logs and making the log view almost unusable.

Signed-off-by: Christian Decker <decker.christian@gmail.com>
2018-05-06 15:45:52 +02:00
Christian Decker 700a505727 doc: Remove libsodium-dev dependency, it's in-tree
Signed-off-by: Christian Decker <decker.christian@gmail.com>
Reported-by: Perlover <@Perlover>
2018-05-06 14:07:13 +02:00
ZmnSCPxj eb42804fcc invoice: Support providing preimage when making invoice. 2018-04-24 11:54:02 +02:00
ZmnSCPxj 2cee1ab20f peer_control: Make close wait for complete closure, with timeout.
Also report tx and txid, and whether we closed unilaterally or
bilaterally, if we could close the channel.

Also make a manpage.

Fixes: #1207
Fixes: #714
Fixes: #622
2018-04-23 05:24:46 +00:00
Christian Decker 36c335fb09 contrib: Updated the builder images to include shellcheck
As requested in #1319

Signed-off-by: Christian Decker <decker.christian@gmail.com>
2018-04-09 00:21:20 +00:00
Rusty Russell 09c4203767 bolt11: allow multiple fallback addresses.
We can have more than one; eg we might offer both bech32 and a p2sh
address, and in future we might offer v1 segwit, etc.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2018-04-06 14:26:53 +02:00
practicalswift bc4a099bff Add shell script linting: Check for shellcheck warnings in shell scripts 2018-04-04 15:06:30 +02:00
Christian Decker f2e81fde44 travis: Updated docker builder images to include cppcheck
It's a check dependency from PR #1262.

Signed-off-by: Christian Decker <decker.christian@gmail.com>
2018-03-27 23:17:48 +00:00
Zhen Zhang d1010673b5 contrib: Rewrite contrib/lightning-pay in Python, support bolt11
fixes #718
2018-03-25 23:19:35 +02:00
ZmnSCPxj a4a5d6002c pylightning: Add new waitsendpay command 2018-03-14 05:33:09 +00:00
John Barboza 9a2950628d test: disconnect command 2018-03-07 16:14:01 +01:00
Douglas Schilling Landgraf d8e764efa0 contrib: Dockerfile.builder.fedora - remove git clone lightning
The original Dockerfile.builder don't build lightning
2018-03-07 16:01:03 +01:00
Douglas Schilling Landgraf 887b5048f1 contrib: Add Dockerfile.builder.fedora
The Fedora distro version of Dockerfile.builder
2018-03-07 16:01:03 +01:00
ZmnSCPxj 8e8d7c2aba pay/sendpay: Use spec names for rhash and r. 2018-03-05 20:21:37 +00:00
Douglas Schilling Landgraf ef34efa93f pylightning: label is required for waitinvoice()
This patch make sure label don't have default value.
2018-03-03 18:12:26 +01:00
Christian Decker 136a5f2b74 contrib: Updated builder image to include v0.16.0 of bitcoind
Now that 0.16.0 is stable we should make use of it

Signed-off-by: Christian Decker <decker.christian@gmail.com>
2018-03-01 03:52:21 +00:00
John Barboza b028a0a439 invoice: add fallback address to invoice command
* Modifies invoice command to have the following format
  invoice <msatoshi> <label> <desc> <?expiry> <?fallbackaddr>
* Adds support for Segwit bcrt1 addresses for withdraw
* Add test case for fallback address in invoice creation
* Create a common json_tok_address_scriptpubkey to be used
  by invoice and withdraw commands.
2018-02-26 03:09:15 +00:00
Christian Decker 68a9951fb9 contrib: Add pytest-reruns into the builder image
Should allow us to reduce the number of manual reruns, but may hide
some flaky tests.

Signed-off-by: Christian Decker <decker.christian@gmail.com>
2018-02-24 10:40:03 +01:00
Christian Decker ac21ac3653 contrib: Add flake8 to builder container images
Signed-off-by: Christian Decker <decker.christian@gmail.com>
2018-02-24 10:40:03 +01:00
Anton Astafiev 8787766d44 Pylightning (#1003)
* Fix dev_setfees to set slow and normal fees correctly.

Due to a bug def_setfees(100, slow=100) would instead set immediate and
normal fees to 100. This behavior has been updated to set fees to
correct values, make the values truly optional as per documentation and
unit test this behavior.

* Fix pay() to set msatoshi, description and risk factor properly

Due to a bug pay(invoice, description='1000') resulted in payment of
1000 msatoshi instead. This was fixed and covered with tests.

* Fix named args in listpayments, listpeers and connect

* Do not pass None to methods where it is default value

* Make description on invoice and pay match.

Suggested-by: @ZmnSCPxj

* Fix dev_setfees to set slow and normal fees correctly.

Due to a bug def_setfees(100, slow=100) would instead set immediate and
normal fees to 100. This behavior has been updated to set fees to
correct values, make the values truly optional as per documentation and
unit test this behavior.

* Fix pay() to set msatoshi, description and risk factor properly

Due to a bug pay(invoice, description='1000') resulted in payment of
1000 msatoshi instead. This was fixed and covered with tests.

* Fix named args in listpayments, listpeers and connect

* Do not pass None to methods where it is default value

* Make description on invoice and pay match.

Suggested-by: @ZmnSCPxj
2018-02-16 22:40:55 +01:00
Douglas Schilling Landgraf cb1a4a5180 pylightning: make flake8 happy
Trivial changes to make the code pythonic

Signed-off-by: Douglas Schilling Landgraf <dougsland@gmail.com>
2018-02-16 12:55:04 +01:00
Christian Decker e48a97ffd4 pylightning: Filter out None arguments in JSON-RPC calls
Passing them in doesn't hurt, but better to avoid ambivalences.

Suggested-by: @graphite
Signed-off-by: Christian Decker <decker.christian@gmail.com>
2018-02-15 23:56:38 +00:00
Christian Decker 0e40b9b08c pylightning: Switch to dict-based params instead of positional
Signed-off-by: Christian Decker <decker.christian@gmail.com>
Co-authored-by: Guido Dassori @gdassori
2018-02-15 23:56:38 +00:00
Christian Decker ed2fee8977 pylightning: Added explicit logger to log to
Signed-off-by: Christian Decker <decker.christian@gmail.com>
Co-authored-by: Guido Dassori @gdassori
2018-02-15 23:56:38 +00:00
Christian Decker b2cec18a81 contrib: Add the addrtype argument to newaddr
Signed-off-by: Christian Decker <decker.christian@gmail.com>
2018-02-06 01:37:58 +00:00
Rusty Russell 7fd5808803 contrib/lightning-cli.bash-completion: fix for new simpler help format.
Plus, we don't need awk *and* sed for this!

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2018-02-02 00:05:00 +01:00
gdassori 7101db060b add mutually exclusive bolt11 & payment_hash to listpayments method 2018-01-31 12:38:18 +01:00
gdassori b9b0b7ebe0 fix LightningRpc signatures according to tests 2018-01-31 12:38:18 +01:00
gdassori bdcf38442b add port argument in connect, add getpeer method for test convenience 2018-01-31 12:38:18 +01:00
gdassori 67dbe71dfa update pylightning readme installation informations 2018-01-31 12:38:18 +01:00
gdassori 825ccb33a6 version bump 2018-01-31 12:38:18 +01:00
gdassori 51a491ef74 same methods of lightning-cli in pylightning 2018-01-31 12:38:18 +01:00
Christian Decker 0223d836ac contrib: Updated bitcoind in CI builder image to 0.15.1
Signed-off-by: Christian Decker <decker.christian@gmail.com>
2018-01-29 20:35:59 +00:00
alaniz 5421e9f6f2 pylightning: Add and move example to README 2018-01-24 17:30:32 +01:00
Tomas Stary e2d66136d3 adding the bash completition script for the client 2018-01-19 22:28:14 +00:00
Rusty Russell cf54f23947 JSONRPC: add id argument to listpeers.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2018-01-19 22:23:45 +00:00
Rusty Russell 5698a133c2 JSONRPC: rename getpeers to listpeers.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2018-01-19 22:23:45 +00:00
Rusty Russell 66885163c9 JSON: Rename rhash to payment_hash in delinvoice, invoice, listinvoice, waitinvoice, waitanyinvoice.
'rhash' is the old terminology, but 'payment_preimage' and
'payment_hash' were decided on for the BOLTs, so we should fix that here.

We still use rhash internally, but that's much easier to fix.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2018-01-14 23:10:10 +00:00
Christian Decker 00e75d3d81 pylightning: Bumped version to 0.0.2 2018-01-10 03:52:46 +00:00
practicalswift f9b8a007d5 Remove unused imports 2017-12-28 16:05:15 +01:00
Christian Decker 0574d68c97 docker: Added pytest-groups plugin to builder image 2017-12-21 22:43:24 +00:00
Christian Decker 34444a99f9 docker: Added clang to build dependencies 2017-12-12 02:31:03 +00:00
practicalswift 0353ec0983 Remove trailing whitespace 2017-12-11 03:35:59 +00:00
Christian Decker bab0693fc4 contrib: Add py.test to builder Dockerfiles
With the previous commit this enables py.test on travis, which should
give us some better way of hunting down bugs on travis.

Signed-off-by: Christian Decker <decker.christian@gmail.com>
2017-11-10 02:20:00 +00:00
Konstantin Nick 62ca15d6aa Fix python-api example 2017-11-06 10:24:09 +01:00
Christian Decker 847df2eb1d contrib: Updated dockerfile to use bitcoind v0.15.1
This was causing intermittent `rawtransactiondecode` errors see
ElementsProject/lightning#332

Reported-by: @achow101
Signed-off-by: Christian Decker <decker.christian@gmail.com>
2017-10-31 19:30:54 +00:00
Rusty Russell c9828d146a contrib/lightning-open-channel: remove
It doesn't work on new lightningd anyway.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-10-20 18:31:32 +02:00
Christian Decker e56ca11624 docker: Added 32bit travis builder dockerfile 2017-09-06 18:06:58 -07:00
Rusty Russell 8375857116 common: absorb remaining files from daemon/
Also, we split the more sophisticated json_add helpers to avoid pulling in
everything into lightning-cli, and unify the routines to print struct
short_channel_id (it's ':',  not '/' too).

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-08-29 17:54:14 +02:00
Rusty Russell 88bb38f63b daemon/lightningd: remove building, and main files
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-08-29 17:54:14 +02:00
Rusty Russell be3b5f11e8 contrib/pylightning: allow getpeer with log level.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-04-29 10:30:10 +02:00
Christian Decker 67315be673 travis: Simplified build script
The Dockerfile is now stored in contrib and built using the Docker
Hub. This allows us to simply pull in the finished image from the hub
instead of having to build it ourself. Should shave off about 2
minutes from the build time.

I also switched to running the individual build and check steps in
their own containers, but on the same volume, so travis can group the
commands and run them independently.
2017-04-29 10:29:44 +09:30
Christian Decker 4e0be7a48f pytest: Added dynamic RPC call dispatch
Instead of having to define every single method we can now just call
any method, it'll fail upstream if it does not exist.
2017-04-24 05:18:11 +00:00
Christian Decker 225f29abf4 pylightning: RPC returns a failure if the connection is lost 2017-03-20 11:18:00 +10:30
Christian Decker 9c7c2a3f2f pytest: Added simple pytest for the new JSON-RPC 2017-03-20 11:18:00 +10:30
Christian Decker 5f61b3a272 pytest: Separating new lightningd and legacy lightningd RPC client
We intend to ultimately no longer use the legacy `daemon/lightningd`
and instead use `lightningd/lightningd`, so I grouped the new RPC and
the legacy RPC and implemented stubs for the new daemon.
2017-01-23 10:37:34 +01:00