mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-03-03 10:46:58 +01:00
lightningd: add start for fundchannel_continue
Add an RPC method (not working at the moment) called `fundchannel_continue` that takes as its parameters a node_id and a txid for a transaction (that ostensibly has an output for a channel)
This commit is contained in:
parent
52042bde80
commit
dd11d3bd81
4 changed files with 77 additions and 0 deletions
|
@ -499,6 +499,16 @@ class LightningRpc(UnixDomainSocketRpc):
|
|||
}
|
||||
return self.call("fundchannel_start", payload)
|
||||
|
||||
def fundchannel_continue(self, node_id, funding_txid):
|
||||
"""
|
||||
Complete channel establishment with {id}, using {funding_txid}
|
||||
"""
|
||||
payload = {
|
||||
"id": node_id,
|
||||
"txid": funding_txid,
|
||||
}
|
||||
return self.call("fundchannel_continue", payload)
|
||||
|
||||
def getinfo(self):
|
||||
"""
|
||||
Show information about this node
|
||||
|
|
|
@ -969,6 +969,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_GOT_OFFER_REPLY:
|
||||
case WIRE_OPENING_DEV_MEMLEAK:
|
||||
/* Replies never get here */
|
||||
|
@ -1045,6 +1046,44 @@ 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,
|
||||
const char *buffer,
|
||||
const jsmntok_t *obj UNNEEDED,
|
||||
const jsmntok_t *params)
|
||||
{
|
||||
u8 *msg;
|
||||
struct node_id *id;
|
||||
struct bitcoin_txid *funding_txid;
|
||||
struct peer *peer;
|
||||
struct channel *channel;
|
||||
|
||||
if (!param(cmd, buffer, params,
|
||||
p_req("id", param_node_id, &id),
|
||||
p_req("txid", param_txid, &funding_txid),
|
||||
NULL))
|
||||
return command_param_failed();
|
||||
|
||||
peer = peer_by_id(cmd->ld, id);
|
||||
if (!peer) {
|
||||
return command_fail(cmd, LIGHTNINGD, "Unknown peer");
|
||||
}
|
||||
|
||||
channel = peer_active_channel(peer);
|
||||
if (channel)
|
||||
return command_fail(cmd, LIGHTNINGD, "Peer already %s",
|
||||
channel_state_name(channel));
|
||||
|
||||
if (!peer->uncommitted_channel)
|
||||
return command_fail(cmd, LIGHTNINGD, "Peer not connected");
|
||||
|
||||
if (!peer->uncommitted_channel->fc)
|
||||
return command_fail(cmd, LIGHTNINGD, "No channel funding in progress.");
|
||||
|
||||
msg = towire_opening_funder_continue(NULL, funding_txid);
|
||||
subd_send_msg(peer->uncommitted_channel->openingd, take(msg));
|
||||
return command_still_pending(cmd);
|
||||
}
|
||||
|
||||
static struct command_result *json_fund_channel_start(struct command *cmd,
|
||||
const char *buffer,
|
||||
const jsmntok_t *obj UNNEEDED,
|
||||
|
@ -1262,6 +1301,15 @@ static const struct json_command fund_channel_start_command = {
|
|||
};
|
||||
AUTODATA(json_command, &fund_channel_start_command);
|
||||
|
||||
static const struct json_command fund_channel_continue_command = {
|
||||
"fundchannel_continue",
|
||||
"channels",
|
||||
json_fund_channel_continue,
|
||||
"Complete channel establishment with peer {id} for funding transaction"
|
||||
"with {txid}. Returns true on success, false otherwise."
|
||||
};
|
||||
AUTODATA(json_command, &fund_channel_continue_command);
|
||||
|
||||
#if DEVELOPER
|
||||
/* Indented to avoid include ordering check */
|
||||
#include <lightningd/memdump.h>
|
||||
|
|
|
@ -90,6 +90,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 establsihment 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
|
||||
|
||||
# Openingd->master: we failed to negotiation channel
|
||||
opening_funder_failed,6004
|
||||
opening_funder_failed,,reason,wirestring
|
||||
|
|
|
|
@ -617,6 +617,13 @@ static u8 *funder_channel_start(struct state *state,
|
|||
return towire_opening_funder_start_reply(state, funding_output_script);
|
||||
}
|
||||
|
||||
static u8 *funder_channel_continue(struct state *state,
|
||||
struct bitcoin_txid *funding_txid)
|
||||
{
|
||||
// now the what. ok we've got a funding_txid..
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*~ OK, let's fund a channel! Returns the reply for lightningd on success,
|
||||
* or NULL if something goes wrong. */
|
||||
static u8 *funder_channel(struct state *state,
|
||||
|
@ -1565,6 +1572,7 @@ static u8 *handle_master_in(struct state *state)
|
|||
struct amount_sat change;
|
||||
u32 change_keyindex;
|
||||
u8 channel_flags;
|
||||
struct bitcoin_txid funding_txid;
|
||||
struct utxo **utxos;
|
||||
struct ext_key bip32_base;
|
||||
|
||||
|
@ -1596,6 +1604,11 @@ 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,
|
||||
&funding_txid))
|
||||
master_badmsg(WIRE_OPENING_FUNDER_CONTINUE, msg);
|
||||
return funder_channel_continue(state, &funding_txid);
|
||||
case WIRE_OPENING_DEV_MEMLEAK:
|
||||
#if DEVELOPER
|
||||
handle_dev_memleak(state, msg);
|
||||
|
|
Loading…
Add table
Reference in a new issue