mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-19 15:14:23 +01:00
funding: rename fundchannel_continue -> _complete
Renaming. "complete" more accurately describes what we're doing here.
This commit is contained in:
committed by
Rusty Russell
parent
3ae78a61fa
commit
c00e0d2936
@@ -488,7 +488,7 @@ class LightningRpc(UnixDomainSocketRpc):
|
|||||||
If {announce} is False, don't send channel announcements.
|
If {announce} is False, don't send channel announcements.
|
||||||
Returns a Bech32 {funding_address} for an external wallet
|
Returns a Bech32 {funding_address} for an external wallet
|
||||||
to create a funding transaction for. Requires a call to
|
to create a funding transaction for. Requires a call to
|
||||||
'fundchannel_continue' to complete channel establishment
|
'fundchannel_complete' to complete channel establishment
|
||||||
with peer.
|
with peer.
|
||||||
"""
|
"""
|
||||||
payload = {
|
payload = {
|
||||||
@@ -508,7 +508,7 @@ class LightningRpc(UnixDomainSocketRpc):
|
|||||||
}
|
}
|
||||||
return self.call("fundchannel_cancel", payload)
|
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}
|
Complete channel establishment with {id}, using {funding_txid} at {funding_txout}
|
||||||
"""
|
"""
|
||||||
@@ -517,7 +517,7 @@ class LightningRpc(UnixDomainSocketRpc):
|
|||||||
"txid": funding_txid,
|
"txid": funding_txid,
|
||||||
"txout": funding_txout,
|
"txout": funding_txout,
|
||||||
}
|
}
|
||||||
return self.call("fundchannel_continue", payload)
|
return self.call("fundchannel_complete", payload)
|
||||||
|
|
||||||
def getinfo(self):
|
def getinfo(self):
|
||||||
"""
|
"""
|
||||||
|
|||||||
@@ -1020,7 +1020,7 @@ static unsigned int openingd_msg(struct subd *openingd,
|
|||||||
case WIRE_OPENING_INIT:
|
case WIRE_OPENING_INIT:
|
||||||
case WIRE_OPENING_FUNDER:
|
case WIRE_OPENING_FUNDER:
|
||||||
case WIRE_OPENING_FUNDER_START:
|
case WIRE_OPENING_FUNDER_START:
|
||||||
case WIRE_OPENING_FUNDER_CONTINUE:
|
case WIRE_OPENING_FUNDER_COMPLETE:
|
||||||
case WIRE_OPENING_FUNDER_CANCEL:
|
case WIRE_OPENING_FUNDER_CANCEL:
|
||||||
case WIRE_OPENING_GOT_OFFER_REPLY:
|
case WIRE_OPENING_GOT_OFFER_REPLY:
|
||||||
case WIRE_OPENING_DEV_MEMLEAK:
|
case WIRE_OPENING_DEV_MEMLEAK:
|
||||||
@@ -1098,7 +1098,7 @@ void peer_start_openingd(struct peer *peer,
|
|||||||
subd_send_msg(uc->openingd, take(msg));
|
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 char *buffer,
|
||||||
const jsmntok_t *obj UNNEEDED,
|
const jsmntok_t *obj UNNEEDED,
|
||||||
const jsmntok_t *params)
|
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 */
|
/* Update the cmd to the new cmd */
|
||||||
peer->uncommitted_channel->fc->cmd = cmd;
|
peer->uncommitted_channel->fc->cmd = cmd;
|
||||||
msg = towire_opening_funder_continue(NULL,
|
msg = towire_opening_funder_complete(NULL,
|
||||||
funding_txid,
|
funding_txid,
|
||||||
funding_txout);
|
funding_txout);
|
||||||
subd_send_msg(peer->uncommitted_channel->openingd, take(msg));
|
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
|
* 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
|
* to see if you've already called `complete` -- we expect you
|
||||||
* the caller to EITHER pick 'continue' or 'cancel'.
|
* the caller to EITHER pick 'complete' or 'cancel'.
|
||||||
* but if for some reason you've decided to test your luck, how much
|
* 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
|
* '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
|
* 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
|
* you've decided (for whatever reason) not to broadcast the transaction
|
||||||
* so your channels have ended up in this 'waiting' state. neither of us
|
* 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
|
* 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);
|
AUTODATA(json_command, &fund_channel_cancel_command);
|
||||||
|
|
||||||
static const struct json_command fund_channel_continue_command = {
|
static const struct json_command fund_channel_complete_command = {
|
||||||
"fundchannel_continue",
|
"fundchannel_complete",
|
||||||
"channels",
|
"channels",
|
||||||
json_fund_channel_continue,
|
json_fund_channel_complete,
|
||||||
"Complete channel establishment with peer {id} for funding transaction"
|
"Complete channel establishment with peer {id} for funding transaction"
|
||||||
"with {txid}. Returns true on success, false otherwise."
|
"with {txid}. Returns true on success, false otherwise."
|
||||||
};
|
};
|
||||||
AUTODATA(json_command, &fund_channel_continue_command);
|
AUTODATA(json_command, &fund_channel_complete_command);
|
||||||
|
|
||||||
#if DEVELOPER
|
#if DEVELOPER
|
||||||
/* Indented to avoid include ordering check */
|
/* Indented to avoid include ordering check */
|
||||||
|
|||||||
@@ -91,12 +91,12 @@ opening_funder_start_reply,6102
|
|||||||
opening_funder_start_reply,,script_len,u8
|
opening_funder_start_reply,,script_len,u8
|
||||||
opening_funder_start_reply,,scriptpubkey,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
|
# tx that will be paid for by an external wallet
|
||||||
# response to this is a normal `opening_funder_reply` ??
|
# response to this is a normal `opening_funder_reply` ??
|
||||||
opening_funder_continue,6012
|
opening_funder_complete,6012
|
||||||
opening_funder_continue,,funding_txid,struct bitcoin_txid
|
opening_funder_complete,,funding_txid,struct bitcoin_txid
|
||||||
opening_funder_continue,,funding_txout,u16
|
opening_funder_complete,,funding_txout,u16
|
||||||
|
|
||||||
#master->openingd: cancel channel establishment for a funding
|
#master->openingd: cancel channel establishment for a funding
|
||||||
opening_funder_cancel,6013
|
opening_funder_cancel,6013
|
||||||
|
|||||||
|
@@ -73,7 +73,7 @@ struct state {
|
|||||||
struct basepoints our_points;
|
struct basepoints our_points;
|
||||||
struct pubkey our_funding_pubkey;
|
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 basepoints their_points;
|
||||||
struct pubkey their_funding_pubkey;
|
struct pubkey their_funding_pubkey;
|
||||||
|
|
||||||
@@ -805,7 +805,7 @@ fail:
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static u8 *funder_channel_continue(struct state *state)
|
static u8 *funder_channel_complete(struct state *state)
|
||||||
{
|
{
|
||||||
struct bitcoin_tx *tx;
|
struct bitcoin_tx *tx;
|
||||||
struct bitcoin_signature sig;
|
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 */
|
/* We want to keep openingd alive, since we're not done yet */
|
||||||
wire_sync_write(REQ_FD, take(msg));
|
wire_sync_write(REQ_FD, take(msg));
|
||||||
return NULL;
|
return NULL;
|
||||||
case WIRE_OPENING_FUNDER_CONTINUE:
|
case WIRE_OPENING_FUNDER_COMPLETE:
|
||||||
if (!fromwire_opening_funder_continue(msg,
|
if (!fromwire_opening_funder_complete(msg,
|
||||||
&funding_txid,
|
&funding_txid,
|
||||||
&funding_txout))
|
&funding_txout))
|
||||||
master_badmsg(WIRE_OPENING_FUNDER_CONTINUE, msg);
|
master_badmsg(WIRE_OPENING_FUNDER_COMPLETE, msg);
|
||||||
state->funding_txid = funding_txid;
|
state->funding_txid = funding_txid;
|
||||||
state->funding_txout = funding_txout;
|
state->funding_txout = funding_txout;
|
||||||
return funder_channel_continue(state);
|
return funder_channel_complete(state);
|
||||||
case WIRE_OPENING_FUNDER_CANCEL:
|
case WIRE_OPENING_FUNDER_CANCEL:
|
||||||
/* We're aborting this, simple */
|
/* We're aborting this, simple */
|
||||||
if (!fromwire_opening_funder_cancel(msg))
|
if (!fromwire_opening_funder_cancel(msg))
|
||||||
|
|||||||
@@ -837,12 +837,12 @@ def test_funding_external_wallet_corners(node_factory, bitcoind):
|
|||||||
l1.rpc.fundchannel_start(l2.info['id'], amount)
|
l1.rpc.fundchannel_start(l2.info['id'], amount)
|
||||||
|
|
||||||
with pytest.raises(RpcError, match=r'Unknown peer'):
|
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.
|
# Should not be able to continue without being in progress.
|
||||||
l1.rpc.connect(l2.info['id'], 'localhost', l2.port)
|
l1.rpc.connect(l2.info['id'], 'localhost', l2.port)
|
||||||
with pytest.raises(RpcError, match=r'No channel funding in progress.'):
|
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)
|
l1.rpc.fundchannel_start(l2.info['id'], amount)
|
||||||
with pytest.raises(RpcError, match=r'Already funding channel'):
|
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']
|
txid = bitcoind.rpc.decoderawtransaction(raw_funded_tx)['txid']
|
||||||
txout = 1 if funded_tx_obj['changepos'] == 0 else 0
|
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
|
# Broadcast the transaction manually and confirm that channel locks in
|
||||||
signed_tx = bitcoind.rpc.signrawtransactionwithwallet(raw_funded_tx)['hex']
|
signed_tx = bitcoind.rpc.signrawtransactionwithwallet(raw_funded_tx)['hex']
|
||||||
|
|||||||
Reference in New Issue
Block a user