Commit Graph

6686 Commits

Author SHA1 Message Date
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 fdcacbc7f0 wallet: check that funding_tx is affordabe if we trim change
In some cases, the funding transaction is affordable only
if we leave out the change amount.
2019-09-11 23:56:27 +00:00
lisa neigut 38e404af51 wallet: add flag to specify whether or not to include change output
Will allow for more intelligent change policy
2019-09-11 23:56:27 +00:00
lisa neigut 8854bc8ae6 fundchannel_start: don't return null message
When the peer sends back an error, we return null, but sending
a NULL message back to lightningd causes a parsing error on their
side. negotiation_failed already calls back the peer, all we need
to do here is exit.
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
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
lisa neigut b1f05795a8 rpc: have fundchannel_start also return scriptpubkey
Easier to pass it back than dig it out of the address, since we
have it. Needed for extracting fundchannel
2019-09-11 23:56:27 +00:00
lisa neigut 19e65068a9 json: move param node_id parser to common
Going to need this for a plugin that's external
2019-09-11 23:56:27 +00:00
trueptolemy 8d28e52515 pytest: Test `fundchannel_cancel` can catch tx braodcast by bitcoind
For now, we can't fully ensure that the broadcast was catched from a third pary. Only when the transaction (broadcast by a third pary) is onchain, we can catch it.
2019-09-11 17:04:14 -05:00
trueptolemy 4c2bc91955 CHANGLOG: Add the CHANGLOG entry of extending `fundchannel_cancel` 2019-09-11 17:04:14 -05:00
trueptolemy 264b3692fb doc: update the document of `fundchannel_cancel` 2019-09-11 17:04:14 -05:00
trueptolemy f1822e3650 pytest: Test `fundchannel_cancel` can work after `fundchannel_complete` 2019-09-11 17:04:14 -05:00
trueptolemy 6c708b5854 API: `fundchannel_cancel` can cancel fundchannel process before funding broadcast 2019-09-11 17:04:14 -05:00
trueptolemy 1e5b619832 lightningd: Store commands that try to forget channel in `struct channel` 2019-09-11 17:04:14 -05:00
trueptolemy db145f575b Fix: fundee can forget channel if it receives error during CHANNELD_AWAITING_LOCKIN 2019-09-11 17:04:14 -05:00
trueptolemy a3b43fa196 Cleanup: Remove the duplicated code of getting txid in `json_withdraw` 2019-09-11 17:04:14 -05:00
trueptolemy b7ae2f3ac7 Fix: Store the transaction(broadcast by `txsend`) into DB 2019-09-11 17:04:14 -05:00
Rusty Russell afbed94a6c gossipd: work around missing pwritev().
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2019-09-11 05:58:36 +00:00
Rusty Russell 8843ab4fb7 configure: test for pwritev
MacOS doesn't have it apparently.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2019-09-11 05:58:36 +00:00
trueptolemy 8df27a7bbb CHANGELOG: Add the entry for `sendpay_success` and `sendpay_failure` 2019-09-11 00:57:39 +00:00
trueptolemy 3722d169ae doc: Add the description for 'sendpay_success' and 'sendpay_failure' notifications 2019-09-11 00:57:39 +00:00
trueptolemy f715e3ad84 pay: A cleanup for the comment about wait_payment()
json_waitsendpay_on_resolve() has been replaced by wait_payment(), so correct it here.
2019-09-11 00:57:39 +00:00
trueptolemy 619362ae19 pytest: Add a test for 'sendpay_success' and 'sendpay_failure' 2019-09-11 00:57:39 +00:00
trueptolemy 5fa3a50896 pytest: Add a simple plugin to test 'sendpay_success' and 'sendpay_failure' 2019-09-11 00:57:39 +00:00
trueptolemy 086f096b86 Pay: Notify 'sendpay_success' and 'sendpay_failure' when sendpay succeeds and fails 2019-09-11 00:57:39 +00:00
trueptolemy 82e8db4ba4 plugin: Another new notification type, 'sendpay_failure'
(The json when sendpay successes is too different when sendpay fails, so
divide the sendpay result into two notifications: `sendpay_success` and
`sendpay_failure`)

`sendpay_failure`

A notification for topic `sendpay_failure` is sent every time a sendpay
success(with `failed` status). The json is same as the return value of
command `sendpay`/`waitsendpay` when this cammand fails.

```json
{
  "sendpay_failure": {
  "code": 204,
  "message": "failed: WIRE_UNKNOWN_NEXT_PEER (reply from remote)",
  "data": {
    "id": 2,
    "payment_hash": "9036e3bdbd2515f1e653cb9f22f8e4c49b73aa2c36e937c926f43e33b8db8851",
    "destination": "035d2b1192dfba134e10e540875d366ebc8bc353d5aa766b80c090b39c3a5d885d",
    "msatoshi": 100000000,
    "amount_msat": "100000000msat",
    "msatoshi_sent": 100001001,
    "amount_sent_msat": "100001001msat",
    "created_at": 1561395134,
    "status": "failed",
    "erring_index": 1,
    "failcode": 16394,
    "failcodename": "WIRE_UNKNOWN_NEXT_PEER",
    "erring_node": "022d223620a359a47ff7f7ac447c85c46c923da53389221a0054c11c1e3ca31d59",
    "erring_channel": "103x2x1",
    "erring_direction": 0
    }
  }
}
```
`sendpay` doesn't wait for the result of sendpay and `waitsendpay`
returns the result of sendpay in specified time or timeout, but
`sendpay_failure` will always return the result anytime when sendpay
fails if is was subscribed.
2019-09-11 00:57:39 +00:00
trueptolemy 9d8f46149a API: Add payment fields(if not NULL) into return value when sendpay fails
pPayment field includes the basic information of the payment, so the return valves of 'sendpay_success()' and 'sendpay_fail()' should include this field.
Note "immediate_routing_failure" is before payment creation, and for this case, return won't include payment fields.
2019-09-11 00:57:39 +00:00
trueptolemy 507f8d46df pay: Warp the json process of payment fail field
We will also call this warped function in the json process of the 'sendpay_failure' notification.
2019-09-11 00:57:39 +00:00
trueptolemy 07f85cbf72 plugin: A new notification type, 'sendpay_success'
`sendpay_success`

A notification for topic `sendpay_success` is sent every time a sendpay
success(with `complete` status). The json is same as the return value of
command `sendpay`/`waitsendpay` when these cammand succeeds.

```json
{
	"sendpay_success": {
  "id": 1,
  "payment_hash": "5c85bf402b87d4860f4a728e2e58a2418bda92cd7aea0ce494f11670cfbfb206",
  "destination": "035d2b1192dfba134e10e540875d366ebc8bc353d5aa766b80c090b39c3a5d885d",
  "msatoshi": 100000000,
  "amount_msat": "100000000msat",
  "msatoshi_sent": 100001001,
  "amount_sent_msat": "100001001msat",
  "created_at": 1561390572,
  "status": "complete",
  "payment_preimage": "9540d98095fd7f37687ebb7759e733934234d4f934e34433d4998a37de3733ee"
  }
}
```
`sendpay` doesn't wait for the result of sendpay and `waitsendpay`
returns the result of sendpay in specified time or timeout, but
`sendpay_success` will always return the result anytime when sendpay
successes if is was subscribed.
2019-09-11 00:57:39 +00:00
Rusty Russell 226e2aee48 option_static_remotekey: update to latest draft.
531c8d7d9b

In this one, we always send my_current_per_commitment_point, though it's
ignored.  And we have our official feature numbers.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2019-09-10 16:18:25 -05:00
Rusty Russell e467e6a5c6 Makefile: fix race if we run `make update-mocks` in a clean tree.
/bin/sh: 1: ccan/ccan/cdump/tools/cdump-enumstr: Text file busy
    make[1]: *** [common/Makefile:81: common/gen_htlc_state_names.h] Error 2
    make[1]: *** Waiting for unfinished jobs....

The fix is to make sure all generated headers are made first, and
thus cdump-enumstr.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2019-09-10 16:18:25 -05:00
Rusty Russell 0861279b65 channeld: don't exchange my_current_per_commitment_point if option_static_remotekey
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2019-09-10 16:18:25 -05:00
Rusty Russell ee3480e56b derive_keyset: don't rotate key for remote iff option_static_remotekey.
The largest change is inside hsmd: it hands a null per-commitment key
to the wallet to tell it to spend the to_remote output.

It can also now resolve unknown commitments, even if it doesn't have a
possible_remote_per_commitment_point from the peer.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2019-09-10 16:18:25 -05:00
Rusty Russell 160f27061e common/utxo: make commitment_point optional in close_info.
We don't rotate key for option_static_remotekey, so we don't need
this point for such channels.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2019-09-10 16:18:25 -05:00
Rusty Russell 87f0ee6351 channeld: set option_static_remotekey when negotiated.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2019-09-10 16:18:25 -05:00
Rusty Russell 11ee089d4b db: store option_static_remotekey for each channel.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2019-09-10 16:18:25 -05:00
Rusty Russell 5203847025 common/features: if EXPERIMENTAL_FEATURES, advertise `option_static_remotekey`
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2019-09-10 16:18:25 -05:00
Rusty Russell ded8eb7b31 wire/extracted_peer_experimental_csv: option_static_remotekey
Aka. BOLTVERSION=930a9b44076a8f25a8626b31b3d5a55c0888308c from
https://github.com/lightningnetwork/lightning-rfc/pull/642

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2019-09-10 16:18:25 -05:00
Rusty Russell 6a293fd135 tools/generate-wire.py: accept multiple comma-separated options.
Somehow this change got lost, but it's needed for option_static_remotekey,
to quote gen_peer_wire_csv:

    msgtype,channel_reestablish,136
    msgdata,channel_reestablish,channel_id,channel_id,
    msgdata,channel_reestablish,next_commitment_number,u64,
    msgdata,channel_reestablish,next_revocation_number,u64,
    msgdata,channel_reestablish,your_last_per_commitment_secret,byte,32,option_data_loss_protect,option_static_remotekey
    msgdata,channel_reestablish,my_current_per_commitment_point,point,,option_data_loss_protect

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2019-09-10 16:18:25 -05:00
Rusty Russell 51d7a1404f tools/check-bolt: don't get confused by 'BOLT #1' in middle of a comment.
Insist it be prefixed with '* '.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2019-09-10 16:18:25 -05:00
darosior e52af0d1ea doc: Document the new dependency 2019-09-10 02:17:27 +00:00
darosior 0b0ad4c22d transition from status_trace() to status_debug 2019-09-10 02:02:51 +00:00
darosior 0504a51211 channeld/full_channel: use louder warning when peer is about to be failed 2019-09-10 02:02:51 +00:00
darosior 6193d22594 onchaind: Use louder warning where needed 2019-09-10 02:02:51 +00:00