Commit Graph

108 Commits

Author SHA1 Message Date
Vasil Dimov 2ea91f834c Add the missing space between "if" and "("
Changelog-None
2020-01-06 12:57:59 +01:00
Vasil Dimov 76e5ed45a6 doc: fix wording in plugins/README.md
Changelog-None
2020-01-06 12:57:59 +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
Rusty Russell 207689c274 plugins: listpays will now consolidate multi-part payments.
This won't usually be visible to the end-user, since the pay plugin doesn't
do multi-part yet (and mpp requires EXPERIMENTAL_FEATURES), but we're ready
once it does.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2019-12-12 15:03:53 +01:00
Rusty Russell f1bc0b21f1 plugins: listpays ignores pre-0.7.0 or manual sendpay payments w/ no bolt11.
The pay plugin has been supplying the bolt11 string since 0.7.0, so only
ancient "pay" commands would be omitted by this change.

You can create a no-bolt11 "sendpay" manually, but then you'll find it
in 'listsendpays'.

Changelog-Removed: JSON: `listpays` won't shown payments made via sendpay without a bolt11 string, or before 0.7.0.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2019-12-12 15:03:53 +01:00
darosior fcbd11f0c5 plugins/libplugin: hook support
Changelog-Added: plugins: libplugin now supports writing plugins which register to hooks
2019-12-09 16:18:28 +01:00
darosior 3371f0cf78 plugins/libplugin: notifications support
Changelog-Added: plugins: libplugin now supports writing plugin which registers to notifications
2019-12-09 16:18:28 +01:00
lisa neigut a30ee2b7cd fundchannel: attempt to connect before funding channel
Attempts to connect to peer before funding the channel
2019-12-04 15:32:31 -06:00
darosior ff412a6c9a plugins/fundchannel: try to connect to peer before funding
Changelog-Added: RPC: The 'fundchannel' command now tries to connect to the peer before funding the channel, no need to 'connect' before 'fundchannel' anymore !
2019-12-04 15:32:31 -06:00
Rusty Russell 18e9144675 plugins/pay: hand payment_secret from bolt11 through to sendpay.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2019-11-24 23:33:17 +00:00
lisa neigut 963a1da958 addr: handle P2SH/P2PKH in scriptpubkey encoding
Previously, returned null if a scriptpubkey was not Segwit; now
handles encoding to Base58 for other types.
2019-11-13 03:31:20 +00: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 16f5af00c7 common/json: add a helper for json to u16
As Rusty pointed out to me, the gossip protocol restricts cltvs to u16
so at least we'll use this helper for them.
2019-11-08 03:27:58 +00:00
darosior 5766231d98 pay: restore payment value randomization through shadow routing
When doing the random walk through the channel, we now add the fees
(both the base and the proportional one) for that channel in addition to
the cltv delta.

Changelog-Added: Payment amount fuzzing is restored, but through shadow routing.
2019-11-08 03:27:58 +00:00
Rusty Russell fe17acf07b TAGS: reformat to fix when PRINTF_FMT() used.
I was wondering why TAGS was missing some functions, and finally
tracked it down: PRINTF_FMT() confuses etags if it's at the start
of a function, and it ignores the rest of the file.

So we put PRINTF_FMT at the end, but that doesn't work for
*definitions*, only *declarations*.  So we remove it from definitions
and add gratuitous declarations in the few static places.1

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2019-11-01 17:27:20 -05:00
Jorge Timón 61383408a4 pay: Return error when trying to pay to an invoice from unkown or different chain 2019-10-30 13:06:24 -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
Christian Decker 7283efa5b5 elements: Add amount_asset to support more than just plain satoshis
Currently the only source for amount_asset is the value getter on a tx output,
and we don't hand it too far around (mainly ignoring it if it isn't the
chain's main currency). Eventually we could bubble them up to the wallet, use
them to select outputs or actually support assets in the channels.

Since we don't hand them around too widely I thought it was ok for them to be
pass-by-value rather than having to allocate them and pass them around by
reference. They're just 41 bytes currently so the overhead should be ok.

Signed-off-by: Christian Decker <@cdecker>
2019-10-03 04:32:57 +00:00
Christian Decker d5f0c08a88 elements: Remove global is_elements variable in favor of chainparams
No need to keep duplicate globals.
2019-10-03 04:32:57 +00:00
Christian Decker 14247283b2 plugin: Tell the plugin which network we run on
The fundchannel plugin needs to know how to build a transaction, so we need to
tell it which chainparams to use. Also adds `chainparams` as a global, since
that seems to be the way to do things in plugins.
2019-10-03 04:32:57 +00:00
Rusty Russell 2a74d53841 Move gossip_constants.h into common/
Turns out we weren't checking the BOLT comments before, so they
needed an overhaul.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2019-09-25 04:01:56 +00:00
trueptolemy 765416f0ca cleanup: Use `json_out_add_u32` helper to add `max_hops` and `cltv` in `pay` plugin 2019-09-24 16:01:24 +02:00
trueptolemy 2d1a153975 plugins: Return `command_param_failed()` if `param()` fail 2019-09-19 01:07:11 +00:00
trueptolemy c737fa6b91 pay: Fix logic of the intereface `find_worst_channel` 2019-09-17 21:06:12 +02:00
trueptolemy bdbfbf7e55 fundchannel: Remove the link of `lightningd/json.h` 2019-09-17 21:05:51 +02:00
trueptolemy b4c6a5c0f0 plugins/.gitignore: Add `fundchannel` entry 2019-09-17 21:05:51 +02:00
trueptolemy 22e8d242fc pay: Exclude nodes if the failcode of `sendpay` has the NODE bit set 2019-09-16 12:22:06 +08:00
lisa neigut a35677fa0f fundchannel: use plugin; delete interior impl
Switch over to using the fundchannel plugin.
2019-09-11 23:56:27 +00:00
lisa neigut 548672ea0a fundchannel: populate max_funding from chainparams
Since we pull the chainparams out to get the funding_addr placeholder,
we can also get the max_funding now!
2019-09-11 23:56:27 +00:00
lisa neigut 42ef64941a fundchannel: have address work with any network
`txprepare` verifies that you're sending to an address on the
right network, so this builds a placeholder address for the
right network.
2019-09-11 23:56:27 +00:00
lisa neigut 7d069239aa fundchannel: only cap to 'max' if keyword 'all' passed in
in order to preserve current behavior, we cap at max if specified 'all';
otherwise we fail since the amount requested is larger than the
channel max capacity
2019-09-11 23:56:27 +00:00
lisa neigut d9843c1957 fundchannel: handle 'all' for satoshi amount
Previously, we'd fail on 'all'. `fundchannel_start` needs an amount
in order to start a funding transaction.

The way that we approach this is to first call `txprepare` with a
placeholder address and the 'all' amount; this will return the maximum
amount available. We then clamp this to the max_funding (currently
hardcoded, in the future we'd want to consult our/the peer's features) and
then use the amount on the output in the prepared transaction as the
funding amount. We then pass this amount to fundchannel_start,
after we've started it successfully we cancel the held placeholder
transaction and prepare a second transaction for the exact amount,
using the funding address that fundchannel_start passed back.
2019-09-11 23:56:27 +00:00
lisa neigut f155c61bdf fundchannel: cancel the fundchannel request if error
If txprepare hits an error, we need to cancel the pending request
with our peer.
2019-09-11 23:56:27 +00:00
lisa neigut 03a30c0981 fundchannel: wire in utxos
Allows a user to specify the utxo's they like to allow for a command.
2019-09-11 23:56:27 +00:00
lisa neigut f433f637ea plugins: add fundchannel plugin, as 'fc'
New plugin which mimics the functionality of the embedded 'fundchannel'.
2019-09-11 23:56:27 +00:00
lisa neigut 2fe490294e libplugin: new helper method for passing a raw error
Makes it easier to stash an error and then return it after another
RPC call has been made.
2019-09-11 23:56:27 +00:00
lisa neigut f784863603 libplugin: add required import
libplugin seems to need the time include, so move it up from pay.
2019-09-11 23:56:27 +00:00
Rusty Russell 884f4fa6d0 JSON: Remove description fields.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2019-09-06 14:19:14 +02:00
Rusty Russell acf3952acc JSON: remove handling of pre-Adelaide (B:T:N) short_channel_ids.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2019-09-06 14:19:14 +02:00
Rusty Russell a134062f98 bolt11: handle `9` fields for new features.
This implements https://github.com/lightningnetwork/lightning-rfc/pull/656

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2019-09-05 23:39:05 -05:00
darosior 0cd3823c98 libplugin: pass configuration to plugin's 'init' callback
So that a plugin can, for example, know if it has been loaded on startup
2019-08-03 13:15:40 +02:00
darosior 017ee7c916 libplugin: Add 'getmanifest' 'dynamic' field 2019-08-03 13:15:40 +02:00
Rusty Russell cc70b9c4ec wire: use common/bigsize routines
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2019-07-31 23:25:59 +00:00
Rusty Russell 068b593d98 plugins/pay: fix crash when we reach retry timeout.
pay: ccan/ccan/json_out/json_out.c:144: check_fieldname: Assertion `!fieldname' failed.
pay: FATAL SIGNAL 6 (version v0.7.1rc4-1-gf1bea55)
0x11d914 send_backtrace
        common/daemon.c:40
0x11d9ba crashdump
        common/daemon.c:53
0x5430f1f ???
        ???:0
0x5430e97 ???
        ???:0
0x5432800 ???
        ???:0
0x5422399 ???
        ???:0
0x5422411 ???
        ???:0
0x1325c3 check_fieldname
        ccan/ccan/json_out/json_out.c:144
0x132627 json_out_member_direct
        ccan/ccan/json_out/json_out.c:162
0x10c4a4 json_out_add_raw_len
        plugins/pay.c:122
0x10c4f9 json_out_add_raw
        plugins/pay.c:130
0x10c9ae waitsendpay_expired
        plugins/pay.c:236
0x10ce39 waitsendpay_error
        plugins/pay.c:322
0x111aa7 handle_rpc_reply
        plugins/libplugin.c:431

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2019-07-14 16:16:30 +02:00
Rusty Russell 0e336ac252 plugins/pay: use proper JSON construction for failure paths.
The string cut & paste hack was nasty; make ->failure a json_out
object so we can splice it in properly.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2019-06-12 02:00:15 +00:00
Rusty Russell c585f22711 libplugin: update API to use json_out.
We now hand around struct json_out members, rather than using formatted
strings, so plugins need to construct them properly.

There's no automatic conversion between ' and " any more, so those
are eliminated too.  pay still uses some manual construction of elements.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2019-06-12 02:00:15 +00:00
Rusty Russell c77e29c403 libplugin: use json_out internally.
Since this handles escaping for us, this automatically fixes our previous
escaping issued.

Fixes: #2612
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2019-06-12 02:00:15 +00:00
Rusty Russell 220449e1cd ccan: import ccan/json_out and ccan/json_escape.
These are generalized from our internal implementations.

The main difference is that 'struct json_escaped' is now 'struct
json_escape', so we replace that immediately.

The difference between lightningd's json-writing ringbuffer and the
more generic ccan/json_out is that the latter has a better API and
handles escaping transparently if something slips through (though
it does offer direct accessors so you can mess things up yourself!).

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2019-06-12 02:00:15 +00:00
Rusty Russell 26cdf9d3dc plugins/pay: don't retry routehint if it contains already-eliminated channel.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2019-06-12 02:00:15 +00:00