Browse Source

funding: rename fundchannel_continue -> _complete

Renaming. "complete" more accurately describes what we're doing here.
pull/2938/head
lisa neigut 6 years ago
committed by Rusty Russell
parent
commit
c00e0d2936
  1. 6
      contrib/pylightning/lightning/lightning.py
  2. 22
      lightningd/opening_control.c
  3. 8
      openingd/opening_wire.csv
  4. 12
      openingd/openingd.c
  5. 6
      tests/test_connection.py

6
contrib/pylightning/lightning/lightning.py

@ -488,7 +488,7 @@ class LightningRpc(UnixDomainSocketRpc):
If {announce} is False, don't send channel announcements.
Returns a Bech32 {funding_address} for an external wallet
to create a funding transaction for. Requires a call to
'fundchannel_continue' to complete channel establishment
'fundchannel_complete' to complete channel establishment
with peer.
"""
payload = {
@ -508,7 +508,7 @@ class LightningRpc(UnixDomainSocketRpc):
}
return self.call("fundchannel_cancel", payload)
def fundchannel_continue(self, node_id, funding_txid, funding_txout):
def fundchannel_complete(self, node_id, funding_txid, funding_txout):
"""
Complete channel establishment with {id}, using {funding_txid} at {funding_txout}
"""
@ -517,7 +517,7 @@ class LightningRpc(UnixDomainSocketRpc):
"txid": funding_txid,
"txout": funding_txout,
}
return self.call("fundchannel_continue", payload)
return self.call("fundchannel_complete", payload)
def getinfo(self):
"""

22
lightningd/opening_control.c

@ -1020,7 +1020,7 @@ static unsigned int openingd_msg(struct subd *openingd,
case WIRE_OPENING_INIT:
case WIRE_OPENING_FUNDER:
case WIRE_OPENING_FUNDER_START:
case WIRE_OPENING_FUNDER_CONTINUE:
case WIRE_OPENING_FUNDER_COMPLETE:
case WIRE_OPENING_FUNDER_CANCEL:
case WIRE_OPENING_GOT_OFFER_REPLY:
case WIRE_OPENING_DEV_MEMLEAK:
@ -1098,7 +1098,7 @@ void peer_start_openingd(struct peer *peer,
subd_send_msg(uc->openingd, take(msg));
}
static struct command_result *json_fund_channel_continue(struct command *cmd,
static struct command_result *json_fund_channel_complete(struct command *cmd,
const char *buffer,
const jsmntok_t *obj UNNEEDED,
const jsmntok_t *params)
@ -1142,7 +1142,7 @@ static struct command_result *json_fund_channel_continue(struct command *cmd,
/* Update the cmd to the new cmd */
peer->uncommitted_channel->fc->cmd = cmd;
msg = towire_opening_funder_continue(NULL,
msg = towire_opening_funder_complete(NULL,
funding_txid,
funding_txout);
subd_send_msg(peer->uncommitted_channel->openingd, take(msg));
@ -1181,14 +1181,14 @@ static struct command_result *json_fund_channel_cancel(struct command *cmd,
/**
* there's a question of 'state machinery' here. as is, we're not checking
* to see if you've already called `continue` -- we expect you
* the caller to EITHER pick 'continue' or 'cancel'.
* to see if you've already called `complete` -- we expect you
* the caller to EITHER pick 'complete' or 'cancel'.
* but if for some reason you've decided to test your luck, how much
* 'handling' can we do for that case? the easiest thing to do is to
* say "sorry you've already called continue", we can't cancel this.
* say "sorry you've already called complete", we can't cancel this.
*
* there's also the state you might end up in where you've called
* continue (and it's completed and been passed off to channeld) but
* complete (and it's completed and been passed off to channeld) but
* you've decided (for whatever reason) not to broadcast the transaction
* so your channels have ended up in this 'waiting' state. neither of us
* are actually out any amount of cash, but it'd be nice if there's a way
@ -1438,14 +1438,14 @@ static const struct json_command fund_channel_cancel_command = {
};
AUTODATA(json_command, &fund_channel_cancel_command);
static const struct json_command fund_channel_continue_command = {
"fundchannel_continue",
static const struct json_command fund_channel_complete_command = {
"fundchannel_complete",
"channels",
json_fund_channel_continue,
json_fund_channel_complete,
"Complete channel establishment with peer {id} for funding transaction"
"with {txid}. Returns true on success, false otherwise."
};
AUTODATA(json_command, &fund_channel_continue_command);
AUTODATA(json_command, &fund_channel_complete_command);
#if DEVELOPER
/* Indented to avoid include ordering check */

8
openingd/opening_wire.csv

@ -91,12 +91,12 @@ opening_funder_start_reply,6102
opening_funder_start_reply,,script_len,u8
opening_funder_start_reply,,scriptpubkey,script_len*u8
# master->openingd: continue channel establishment for a funding
# master->openingd: complete channel establishment for a funding
# tx that will be paid for by an external wallet
# response to this is a normal `opening_funder_reply` ??
opening_funder_continue,6012
opening_funder_continue,,funding_txid,struct bitcoin_txid
opening_funder_continue,,funding_txout,u16
opening_funder_complete,6012
opening_funder_complete,,funding_txid,struct bitcoin_txid
opening_funder_complete,,funding_txout,u16
#master->openingd: cancel channel establishment for a funding
opening_funder_cancel,6013

Can't render this file because it has a wrong number of fields in line 6.

12
openingd/openingd.c

@ -73,7 +73,7 @@ struct state {
struct basepoints our_points;
struct pubkey our_funding_pubkey;
/* Information we need between funding_start and funding_continue */
/* Information we need between funding_start and funding_complete */
struct basepoints their_points;
struct pubkey their_funding_pubkey;
@ -805,7 +805,7 @@ fail:
return false;
}
static u8 *funder_channel_continue(struct state *state)
static u8 *funder_channel_complete(struct state *state)
{
struct bitcoin_tx *tx;
struct bitcoin_signature sig;
@ -1675,14 +1675,14 @@ static u8 *handle_master_in(struct state *state)
/* We want to keep openingd alive, since we're not done yet */
wire_sync_write(REQ_FD, take(msg));
return NULL;
case WIRE_OPENING_FUNDER_CONTINUE:
if (!fromwire_opening_funder_continue(msg,
case WIRE_OPENING_FUNDER_COMPLETE:
if (!fromwire_opening_funder_complete(msg,
&funding_txid,
&funding_txout))
master_badmsg(WIRE_OPENING_FUNDER_CONTINUE, msg);
master_badmsg(WIRE_OPENING_FUNDER_COMPLETE, msg);
state->funding_txid = funding_txid;
state->funding_txout = funding_txout;
return funder_channel_continue(state);
return funder_channel_complete(state);
case WIRE_OPENING_FUNDER_CANCEL:
/* We're aborting this, simple */
if (!fromwire_opening_funder_cancel(msg))

6
tests/test_connection.py

@ -837,12 +837,12 @@ def test_funding_external_wallet_corners(node_factory, bitcoind):
l1.rpc.fundchannel_start(l2.info['id'], amount)
with pytest.raises(RpcError, match=r'Unknown peer'):
l1.rpc.fundchannel_continue(l2.info['id'], fake_txid, fake_txout)
l1.rpc.fundchannel_complete(l2.info['id'], fake_txid, fake_txout)
# Should not be able to continue without being in progress.
l1.rpc.connect(l2.info['id'], 'localhost', l2.port)
with pytest.raises(RpcError, match=r'No channel funding in progress.'):
l1.rpc.fundchannel_continue(l2.info['id'], fake_txid, fake_txout)
l1.rpc.fundchannel_complete(l2.info['id'], fake_txid, fake_txout)
l1.rpc.fundchannel_start(l2.info['id'], amount)
with pytest.raises(RpcError, match=r'Already funding channel'):
@ -886,7 +886,7 @@ def test_funding_external_wallet(node_factory, bitcoind):
txid = bitcoind.rpc.decoderawtransaction(raw_funded_tx)['txid']
txout = 1 if funded_tx_obj['changepos'] == 0 else 0
assert l1.rpc.fundchannel_continue(l2.info['id'], txid, txout)['commitments_secured']
assert l1.rpc.fundchannel_complete(l2.info['id'], txid, txout)['commitments_secured']
# Broadcast the transaction manually and confirm that channel locks in
signed_tx = bitcoind.rpc.signrawtransactionwithwallet(raw_funded_tx)['hex']

Loading…
Cancel
Save