Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove deprecated things for next release #4902

Merged
merged 12 commits into from
Nov 14, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fundchannel_complete: remove deprecated txid/txout params.
Changelog-Removed: JSON-RPC: `fundchannel_complete` `txid` and `txout` parameters (deprecated in v0.10.0)
  • Loading branch information
rustyrussell committed Nov 10, 2021
commit d7315d9136f38e507dd5716f60dabaf51fad8258
29 changes: 5 additions & 24 deletions contrib/pyln-client/pyln/client/lightning.py
Original file line number Diff line number Diff line change
@@ -2,7 +2,6 @@
import logging
import os
import socket
import warnings
from contextlib import contextmanager
from decimal import Decimal
from json import JSONEncoder
@@ -757,34 +756,16 @@ def fundchannel_cancel(self, node_id):
}
return self.call("fundchannel_cancel", payload)

def _deprecated_fundchannel_complete(self, node_id, funding_txid, funding_txout):
warnings.warn("fundchannel_complete: funding_txid & funding_txout replaced by psbt: expect removal"
" in Mid-2021",
DeprecationWarning)

def fundchannel_complete(self, node_id, psbt):
"""
Complete channel establishment with {id}, using {psbt}.
"""
payload = {
"id": node_id,
"txid": funding_txid,
"txout": funding_txout,
"psbt": psbt,
}
return self.call("fundchannel_complete", payload)

def fundchannel_complete(self, node_id, *args, **kwargs):
"""
Complete channel establishment with {id}, using {psbt}.
"""
if 'txid' in kwargs or len(args) == 2:
return self._deprecated_fundchannel_complete(node_id, *args, **kwargs)

def _fundchannel_complete(node_id, psbt):
payload = {
"id": node_id,
"psbt": psbt,
}
return self.call("fundchannel_complete", payload)

return _fundchannel_complete(node_id, *args, **kwargs)

def getinfo(self):
"""
Show information about this node.
96 changes: 36 additions & 60 deletions lightningd/opening_control.c
Original file line number Diff line number Diff line change
@@ -974,34 +974,12 @@ static struct command_result *json_fundchannel_complete(struct command *cmd,
struct wally_psbt *funding_psbt;
u32 *funding_txout_num = NULL;
struct funding_channel *fc;
bool old_api;

/* params is NULL for initial parameter desc generation! */
if (params && deprecated_apis) {
/* We used to have a three-arg version. */
if (params->type == JSMN_ARRAY)
old_api = (params->size == 3);
else
old_api = (json_get_member(buffer, params, "txid")
!= NULL);
if (old_api) {
if (!param(cmd, buffer, params,
p_req("id", param_node_id, &id),
p_req("txid", param_txid, &funding_txid),
p_req("txout", param_number, &funding_txout_num),
NULL))
return command_param_failed();
}
} else
old_api = false;

if (!old_api) {
if (!param(cmd, buffer, params,
p_req("id", param_node_id, &id),
p_req("psbt", param_psbt, &funding_psbt),
NULL))
return command_param_failed();
}

if (!param(cmd, buffer, params,
p_req("id", param_node_id, &id),
p_req("psbt", param_psbt, &funding_psbt),
NULL))
return command_param_failed();

peer = peer_by_id(cmd->ld, id);
if (!peer) {
@@ -1024,40 +1002,38 @@ static struct command_result *json_fundchannel_complete(struct command *cmd,

fc = peer->uncommitted_channel->fc;

if (!old_api) {
/* Figure out the correct output, and perform sanity checks. */
for (size_t i = 0; i < funding_psbt->tx->num_outputs; i++) {
if (memeq(funding_psbt->tx->outputs[i].script,
funding_psbt->tx->outputs[i].script_len,
fc->funding_scriptpubkey,
tal_bytelen(fc->funding_scriptpubkey))) {
if (funding_txout_num)
return command_fail(cmd, FUNDING_PSBT_INVALID,
"Two outputs to open channel");
funding_txout_num = tal(cmd, u32);
*funding_txout_num = i;
}
/* Figure out the correct output, and perform sanity checks. */
for (size_t i = 0; i < funding_psbt->tx->num_outputs; i++) {
if (memeq(funding_psbt->tx->outputs[i].script,
funding_psbt->tx->outputs[i].script_len,
fc->funding_scriptpubkey,
tal_bytelen(fc->funding_scriptpubkey))) {
if (funding_txout_num)
return command_fail(cmd, FUNDING_PSBT_INVALID,
"Two outputs to open channel");
funding_txout_num = tal(cmd, u32);
*funding_txout_num = i;
}
if (!funding_txout_num)
return command_fail(cmd, FUNDING_PSBT_INVALID,
"No output to open channel");

/* Can't really check amounts for elements. */
if (!chainparams->is_elements
&& !amount_sat_eq(amount_sat(funding_psbt->tx->outputs
[*funding_txout_num].satoshi),
fc->funding_sats))
return command_fail(cmd, FUNDING_PSBT_INVALID,
"Output to open channel is %"PRIu64"sat,"
" should be %s",
funding_psbt->tx->outputs
[*funding_txout_num].satoshi,
type_to_string(tmpctx, struct amount_sat,
&fc->funding_sats));

funding_txid = tal(cmd, struct bitcoin_txid);
psbt_txid(NULL, funding_psbt, funding_txid, NULL);
}
if (!funding_txout_num)
return command_fail(cmd, FUNDING_PSBT_INVALID,
"No output to open channel");

/* Can't really check amounts for elements. */
if (!chainparams->is_elements
&& !amount_sat_eq(amount_sat(funding_psbt->tx->outputs
[*funding_txout_num].satoshi),
fc->funding_sats))
return command_fail(cmd, FUNDING_PSBT_INVALID,
"Output to open channel is %"PRIu64"sat,"
" should be %s",
funding_psbt->tx->outputs
[*funding_txout_num].satoshi,
type_to_string(tmpctx, struct amount_sat,
&fc->funding_sats));

funding_txid = tal(cmd, struct bitcoin_txid);
psbt_txid(NULL, funding_psbt, funding_txid, NULL);

/* Fun fact: our wire protocol only allows 16 bits for outnum.
* That is reflected in our encoding scheme for short_channel_id. */