Skip to content

Commit

Permalink
funding: rename fundchannel_continue -> _complete
Browse files Browse the repository at this point in the history
Renaming. "complete" more accurately describes what we're doing here.
  • Loading branch information
niftynei authored and rustyrussell committed Jun 12, 2019
1 parent 3ae78a6 commit c00e0d2
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 27 deletions.
6 changes: 3 additions & 3 deletions contrib/pylightning/lightning/lightning.py
Original file line number Diff line number Diff line change
Expand Up @@ -488,7 +488,7 @@ def fundchannel_start(self, node_id, satoshi, feerate=None, announce=True):
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 = {
Expand All @@ -508,7 +508,7 @@ def fundchannel_cancel(self, node_id):
}
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}
"""
Expand All @@ -517,7 +517,7 @@ def fundchannel_continue(self, node_id, funding_txid, funding_txout):
"txid": funding_txid,
"txout": funding_txout,
}
return self.call("fundchannel_continue", payload)
return self.call("fundchannel_complete", payload)

def getinfo(self):
"""
Expand Down
22 changes: 11 additions & 11 deletions lightningd/opening_control.c
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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));
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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 */
Expand Down
8 changes: 4 additions & 4 deletions openingd/opening_wire.csv
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 6 additions & 6 deletions openingd/openingd.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -805,7 +805,7 @@ static bool funder_finalize_channel_setup(struct state *state,
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;
Expand Down Expand Up @@ -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))
Expand Down
6 changes: 3 additions & 3 deletions tests/test_connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'):
Expand Down Expand Up @@ -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']
Expand Down

0 comments on commit c00e0d2

Please sign in to comment.