Commit Graph

269 Commits

Author SHA1 Message Date
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