mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-01-19 05:44:12 +01:00
fundchannel_complete: remove deprecated txid/txout params.
Changelog-Removed: JSON-RPC: `fundchannel_complete` `txid` and `txout` parameters (deprecated in v0.10.0)
This commit is contained in:
parent
c00202a0da
commit
0c0a301062
@ -2,7 +2,6 @@ import json
|
||||
import logging
|
||||
import os
|
||||
import socket
|
||||
import warnings
|
||||
from contextlib import contextmanager
|
||||
from decimal import Decimal
|
||||
from json import JSONEncoder
|
||||
@ -757,33 +756,15 @@ class LightningRpc(UnixDomainSocketRpc):
|
||||
}
|
||||
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)
|
||||
|
||||
payload = {
|
||||
"id": node_id,
|
||||
"txid": funding_txid,
|
||||
"txout": funding_txout,
|
||||
}
|
||||
return self.call("fundchannel_complete", payload)
|
||||
|
||||
def fundchannel_complete(self, node_id, *args, **kwargs):
|
||||
def fundchannel_complete(self, node_id, psbt):
|
||||
"""
|
||||
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)
|
||||
payload = {
|
||||
"id": node_id,
|
||||
"psbt": psbt,
|
||||
}
|
||||
return self.call("fundchannel_complete", payload)
|
||||
|
||||
def getinfo(self):
|
||||
"""
|
||||
|
@ -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. */
|
||||
|
Loading…
Reference in New Issue
Block a user