mirror of
https://github.com/ElementsProject/lightning.git
synced 2024-11-19 01:43:36 +01:00
autoclean: remove autocleaninvoice command.
Changelog-Removed: JSON-RPC: `autocleaninvoice` command (deprecated v22.11, EOL v24.02) Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
parent
b525e26fa5
commit
84b6601bb3
BIN
cln-grpc/proto/node.proto
generated
BIN
cln-grpc/proto/node.proto
generated
Binary file not shown.
BIN
cln-grpc/src/convert.rs
generated
BIN
cln-grpc/src/convert.rs
generated
Binary file not shown.
@ -306,38 +306,6 @@ impl Node for Server
|
||||
|
||||
}
|
||||
|
||||
async fn auto_clean_invoice(
|
||||
&self,
|
||||
request: tonic::Request<pb::AutocleaninvoiceRequest>,
|
||||
) -> Result<tonic::Response<pb::AutocleaninvoiceResponse>, tonic::Status> {
|
||||
let req = request.into_inner();
|
||||
let req: requests::AutocleaninvoiceRequest = req.into();
|
||||
debug!("Client asked for auto_clean_invoice");
|
||||
trace!("auto_clean_invoice request: {:?}", req);
|
||||
let mut rpc = ClnRpc::new(&self.rpc_path)
|
||||
.await
|
||||
.map_err(|e| Status::new(Code::Internal, e.to_string()))?;
|
||||
let result = rpc.call(Request::AutoCleanInvoice(req))
|
||||
.await
|
||||
.map_err(|e| Status::new(
|
||||
Code::Unknown,
|
||||
format!("Error calling method AutoCleanInvoice: {:?}", e)))?;
|
||||
match result {
|
||||
Response::AutoCleanInvoice(r) => {
|
||||
trace!("auto_clean_invoice response: {:?}", r);
|
||||
Ok(tonic::Response::new(r.into()))
|
||||
},
|
||||
r => Err(Status::new(
|
||||
Code::Internal,
|
||||
format!(
|
||||
"Unexpected result {:?} to method call AutoCleanInvoice",
|
||||
r
|
||||
)
|
||||
)),
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
async fn auto_clean_once(
|
||||
&self,
|
||||
request: tonic::Request<pb::AutocleanonceRequest>,
|
||||
|
BIN
cln-rpc/src/model.rs
generated
BIN
cln-rpc/src/model.rs
generated
Binary file not shown.
@ -917,128 +917,6 @@
|
||||
"Main web site: <https://github.com/ElementsProject/lightning>"
|
||||
]
|
||||
},
|
||||
"lightning-autocleaninvoice.json": {
|
||||
"$schema": "../rpc-schema-draft.json",
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
"rpc": "setchannel",
|
||||
"title": "Command for configuring fees / htlc range advertized for a channel",
|
||||
"description": [],
|
||||
"request": {
|
||||
"required": [],
|
||||
"properties": {
|
||||
"expired_by": {
|
||||
"type": "u64",
|
||||
"description": [
|
||||
"How long an invoice must be expired (seconds) before we delete it."
|
||||
]
|
||||
},
|
||||
"cycle_seconds": {
|
||||
"type": "u64",
|
||||
"description": [
|
||||
"The interval (in seconds) between cleaning expired invoices."
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
"response": {
|
||||
"required": [
|
||||
"enabled"
|
||||
],
|
||||
"properties": {
|
||||
"enabled": {
|
||||
"type": "boolean",
|
||||
"description": [
|
||||
"Whether invoice autocleaning is active."
|
||||
]
|
||||
}
|
||||
},
|
||||
"allOf": [
|
||||
{
|
||||
"if": {
|
||||
"properties": {
|
||||
"enabled": {
|
||||
"type": "boolean",
|
||||
"enum": [
|
||||
true
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
"then": {
|
||||
"additionalProperties": false,
|
||||
"required": [
|
||||
"expired_by",
|
||||
"cycle_seconds"
|
||||
],
|
||||
"properties": {
|
||||
"enabled": {},
|
||||
"expired_by": {
|
||||
"type": "u64",
|
||||
"description": [
|
||||
"How long an invoice must be expired (seconds) before we delete it."
|
||||
]
|
||||
},
|
||||
"cycle_seconds": {
|
||||
"type": "u64",
|
||||
"description": [
|
||||
"How long an invoice must be expired (seconds) before we delete it."
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
"else": {
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
"enabled": {}
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"json_example": [
|
||||
{
|
||||
"request": {
|
||||
"id": "example:autocleaninvoice#1",
|
||||
"method": "autocleaninvoice",
|
||||
"params": {
|
||||
"cycle_seconds": 8,
|
||||
"expired_by": 2
|
||||
}
|
||||
},
|
||||
"response": {
|
||||
"enabled": true,
|
||||
"cycle_seconds": 8,
|
||||
"expired_by": 2
|
||||
}
|
||||
},
|
||||
{
|
||||
"request": {
|
||||
"id": "example:autocleaninvoice#2",
|
||||
"method": "autocleaninvoice",
|
||||
"params": {
|
||||
"cycle_seconds": 1,
|
||||
"expired_by": 1
|
||||
}
|
||||
},
|
||||
"response": {
|
||||
"enabled": true,
|
||||
"cycle_seconds": 1,
|
||||
"expired_by": 1
|
||||
}
|
||||
}
|
||||
],
|
||||
"author": [
|
||||
"Rusty Russell <<rusty@rustcorp.com.au>> is mainly responsible."
|
||||
],
|
||||
"see_also": [
|
||||
"lightningd-config(5)",
|
||||
"lightning-listinvoices(7)"
|
||||
],
|
||||
"resources": [
|
||||
"Main web site: <https://github.com/ElementsProject/lightning>"
|
||||
]
|
||||
},
|
||||
"lightning-batching.json": {
|
||||
"$schema": "../rpc-schema-draft.json",
|
||||
"type": "object",
|
||||
|
@ -99,7 +99,6 @@ def load_jsonrpc_service():
|
||||
"ListChannels",
|
||||
"AddGossip",
|
||||
"AddPsbtOutput",
|
||||
"AutoCleanInvoice",
|
||||
"AutoClean-Once",
|
||||
"AutoClean-Status",
|
||||
"CheckMessage",
|
||||
|
@ -490,19 +490,6 @@ class LightningRpc(UnixDomainSocketRpc):
|
||||
}
|
||||
return self.call("addgossip", payload)
|
||||
|
||||
def autocleaninvoice(self, cycle_seconds=None, expired_by=None):
|
||||
"""
|
||||
Sets up automatic cleaning of expired invoices. {cycle_seconds} sets
|
||||
the cleaning frequency in seconds (defaults to 3600) and {expired_by}
|
||||
sets the minimum time an invoice should have been expired for to be
|
||||
cleaned in seconds (defaults to 86400).
|
||||
"""
|
||||
payload = {
|
||||
"cycle_seconds": cycle_seconds,
|
||||
"expired_by": expired_by
|
||||
}
|
||||
return self.call("autocleaninvoice", payload)
|
||||
|
||||
def autoclean_status(self, subsystem=None):
|
||||
"""
|
||||
Print status of autocleaning (optionally, just for {subsystem}).
|
||||
|
File diff suppressed because one or more lines are too long
@ -49,11 +49,6 @@ class NodeStub(object):
|
||||
request_serializer=node__pb2.AddpsbtoutputRequest.SerializeToString,
|
||||
response_deserializer=node__pb2.AddpsbtoutputResponse.FromString,
|
||||
)
|
||||
self.AutoCleanInvoice = channel.unary_unary(
|
||||
'/cln.Node/AutoCleanInvoice',
|
||||
request_serializer=node__pb2.AutocleaninvoiceRequest.SerializeToString,
|
||||
response_deserializer=node__pb2.AutocleaninvoiceResponse.FromString,
|
||||
)
|
||||
self.AutoCleanOnce = channel.unary_unary(
|
||||
'/cln.Node/AutoCleanOnce',
|
||||
request_serializer=node__pb2.AutocleanonceRequest.SerializeToString,
|
||||
@ -651,12 +646,6 @@ class NodeServicer(object):
|
||||
context.set_details('Method not implemented!')
|
||||
raise NotImplementedError('Method not implemented!')
|
||||
|
||||
def AutoCleanInvoice(self, request, context):
|
||||
"""Missing associated documentation comment in .proto file."""
|
||||
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
|
||||
context.set_details('Method not implemented!')
|
||||
raise NotImplementedError('Method not implemented!')
|
||||
|
||||
def AutoCleanOnce(self, request, context):
|
||||
"""Missing associated documentation comment in .proto file."""
|
||||
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
|
||||
@ -1355,11 +1344,6 @@ def add_NodeServicer_to_server(servicer, server):
|
||||
request_deserializer=node__pb2.AddpsbtoutputRequest.FromString,
|
||||
response_serializer=node__pb2.AddpsbtoutputResponse.SerializeToString,
|
||||
),
|
||||
'AutoCleanInvoice': grpc.unary_unary_rpc_method_handler(
|
||||
servicer.AutoCleanInvoice,
|
||||
request_deserializer=node__pb2.AutocleaninvoiceRequest.FromString,
|
||||
response_serializer=node__pb2.AutocleaninvoiceResponse.SerializeToString,
|
||||
),
|
||||
'AutoCleanOnce': grpc.unary_unary_rpc_method_handler(
|
||||
servicer.AutoCleanOnce,
|
||||
request_deserializer=node__pb2.AutocleanonceRequest.FromString,
|
||||
@ -2039,23 +2023,6 @@ class Node(object):
|
||||
options, channel_credentials,
|
||||
insecure, call_credentials, compression, wait_for_ready, timeout, metadata)
|
||||
|
||||
@staticmethod
|
||||
def AutoCleanInvoice(request,
|
||||
target,
|
||||
options=(),
|
||||
channel_credentials=None,
|
||||
call_credentials=None,
|
||||
insecure=False,
|
||||
compression=None,
|
||||
wait_for_ready=None,
|
||||
timeout=None,
|
||||
metadata=None):
|
||||
return grpc.experimental.unary_unary(request, target, '/cln.Node/AutoCleanInvoice',
|
||||
node__pb2.AutocleaninvoiceRequest.SerializeToString,
|
||||
node__pb2.AutocleaninvoiceResponse.FromString,
|
||||
options, channel_credentials,
|
||||
insecure, call_credentials, compression, wait_for_ready, timeout, metadata)
|
||||
|
||||
@staticmethod
|
||||
def AutoCleanOnce(request,
|
||||
target,
|
||||
|
@ -198,14 +198,6 @@ def addpsbtoutput2py(m):
|
||||
})
|
||||
|
||||
|
||||
def autocleaninvoice2py(m):
|
||||
return remove_default({
|
||||
"cycle_seconds": m.cycle_seconds, # PrimitiveField in generate_composite
|
||||
"enabled": m.enabled, # PrimitiveField in generate_composite
|
||||
"expired_by": m.expired_by, # PrimitiveField in generate_composite
|
||||
})
|
||||
|
||||
|
||||
def autoclean_once_autoclean_expiredinvoices2py(m):
|
||||
return remove_default({
|
||||
"cleaned": m.cleaned, # PrimitiveField in generate_composite
|
||||
|
@ -1,122 +0,0 @@
|
||||
{
|
||||
"$schema": "../rpc-schema-draft.json",
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
"rpc": "setchannel",
|
||||
"title": "Command for configuring fees / htlc range advertized for a channel",
|
||||
"description": [],
|
||||
"request": {
|
||||
"required": [],
|
||||
"properties": {
|
||||
"expired_by": {
|
||||
"type": "u64",
|
||||
"description": [
|
||||
"How long an invoice must be expired (seconds) before we delete it."
|
||||
]
|
||||
},
|
||||
"cycle_seconds": {
|
||||
"type": "u64",
|
||||
"description": [
|
||||
"The interval (in seconds) between cleaning expired invoices."
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
"response": {
|
||||
"required": [
|
||||
"enabled"
|
||||
],
|
||||
"properties": {
|
||||
"enabled": {
|
||||
"type": "boolean",
|
||||
"description": [
|
||||
"Whether invoice autocleaning is active."
|
||||
]
|
||||
}
|
||||
},
|
||||
"allOf": [
|
||||
{
|
||||
"if": {
|
||||
"properties": {
|
||||
"enabled": {
|
||||
"type": "boolean",
|
||||
"enum": [
|
||||
true
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
"then": {
|
||||
"additionalProperties": false,
|
||||
"required": [
|
||||
"expired_by",
|
||||
"cycle_seconds"
|
||||
],
|
||||
"properties": {
|
||||
"enabled": {},
|
||||
"expired_by": {
|
||||
"type": "u64",
|
||||
"description": [
|
||||
"How long an invoice must be expired (seconds) before we delete it."
|
||||
]
|
||||
},
|
||||
"cycle_seconds": {
|
||||
"type": "u64",
|
||||
"description": [
|
||||
"How long an invoice must be expired (seconds) before we delete it."
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
"else": {
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
"enabled": {}
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"json_example": [
|
||||
{
|
||||
"request": {
|
||||
"id": "example:autocleaninvoice#1",
|
||||
"method": "autocleaninvoice",
|
||||
"params": {
|
||||
"cycle_seconds": 8,
|
||||
"expired_by": 2
|
||||
}
|
||||
},
|
||||
"response": {
|
||||
"enabled": true,
|
||||
"cycle_seconds": 8,
|
||||
"expired_by": 2
|
||||
}
|
||||
},
|
||||
{
|
||||
"request": {
|
||||
"id": "example:autocleaninvoice#2",
|
||||
"method": "autocleaninvoice",
|
||||
"params": {
|
||||
"cycle_seconds": 1,
|
||||
"expired_by": 1
|
||||
}
|
||||
},
|
||||
"response": {
|
||||
"enabled": true,
|
||||
"cycle_seconds": 1,
|
||||
"expired_by": 1
|
||||
}
|
||||
}
|
||||
],
|
||||
"author": [
|
||||
"Rusty Russell <<rusty@rustcorp.com.au>> is mainly responsible."
|
||||
],
|
||||
"see_also": [
|
||||
"lightningd-config(5)",
|
||||
"lightning-listinvoices(7)"
|
||||
],
|
||||
"resources": [
|
||||
"Main web site: <https://github.com/ElementsProject/lightning>"
|
||||
]
|
||||
}
|
@ -442,41 +442,6 @@ static void do_clean_timer(void *unused)
|
||||
do_clean(&timer_cinfo);
|
||||
}
|
||||
|
||||
static struct command_result *json_autocleaninvoice(struct command *cmd,
|
||||
const char *buffer,
|
||||
const jsmntok_t *params)
|
||||
{
|
||||
u64 *cycle;
|
||||
u64 *exby;
|
||||
struct json_stream *response;
|
||||
|
||||
if (!param(cmd, buffer, params,
|
||||
p_opt_def("cycle_seconds", param_u64, &cycle, 3600),
|
||||
p_opt_def("expired_by", param_u64, &exby, 86400),
|
||||
NULL))
|
||||
return command_param_failed();
|
||||
|
||||
cleantimer = tal_free(cleantimer);
|
||||
|
||||
if (*cycle == 0) {
|
||||
timer_cinfo.subsystem_age[EXPIREDINVOICES] = 0;
|
||||
response = jsonrpc_stream_success(cmd);
|
||||
json_add_bool(response, "enabled", false);
|
||||
return command_finished(cmd, response);
|
||||
}
|
||||
|
||||
cycle_seconds = *cycle;
|
||||
timer_cinfo.subsystem_age[EXPIREDINVOICES] = *exby;
|
||||
cleantimer = plugin_timer(cmd->plugin, time_from_sec(cycle_seconds),
|
||||
do_clean_timer, NULL);
|
||||
|
||||
response = jsonrpc_stream_success(cmd);
|
||||
json_add_bool(response, "enabled", true);
|
||||
json_add_u64(response, "cycle_seconds", cycle_seconds);
|
||||
json_add_u64(response, "expired_by", timer_cinfo.subsystem_age[EXPIREDINVOICES]);
|
||||
return command_finished(cmd, response);
|
||||
}
|
||||
|
||||
static struct command_result *param_subsystem(struct command *cmd,
|
||||
const char *name,
|
||||
const char *buffer,
|
||||
@ -605,14 +570,6 @@ static bool u64_jsonfmt_unless_zero(struct plugin *plugin,
|
||||
}
|
||||
|
||||
static const struct plugin_command commands[] = { {
|
||||
"autocleaninvoice",
|
||||
"payment",
|
||||
"Set up autoclean of expired invoices. ",
|
||||
"Perform cleanup every {cycle_seconds} (default 3600), or disable autoclean if 0. "
|
||||
"Clean up expired invoices that have expired for {expired_by} seconds (default 86400). ",
|
||||
json_autocleaninvoice,
|
||||
"v22.11", "v24.02",
|
||||
}, {
|
||||
"autoclean-status",
|
||||
"utility",
|
||||
"Show status of autocleaning",
|
||||
|
@ -567,56 +567,6 @@ def test_waitanyinvoice_reversed(node_factory, executor):
|
||||
assert r['label'] == 'inv1'
|
||||
|
||||
|
||||
def test_autocleaninvoice_deprecated(node_factory):
|
||||
# This is so deprecated we have to re-enable it by name!
|
||||
l1 = node_factory.get_node(options={'i-promise-to-fix-broken-api-user': 'autocleaninvoice'})
|
||||
|
||||
l1.rpc.invoice(amount_msat=12300, label='inv1', description='description1', expiry=4)
|
||||
l1.rpc.invoice(amount_msat=12300, label='inv2', description='description2', expiry=12)
|
||||
l1.rpc.autocleaninvoice(cycle_seconds=8, expired_by=2)
|
||||
|
||||
start_time = time.time()
|
||||
|
||||
# time 0
|
||||
# Both should still be there.
|
||||
assert len(l1.rpc.listinvoices('inv1')['invoices']) == 1
|
||||
assert len(l1.rpc.listinvoices('inv2')['invoices']) == 1
|
||||
|
||||
assert l1.rpc.listinvoices('inv1')['invoices'][0]['description'] == 'description1'
|
||||
|
||||
time.sleep(start_time - time.time() + 6) # total 6
|
||||
# Both should still be there - auto clean cycle not started.
|
||||
# inv1 should be expired
|
||||
assert len(l1.rpc.listinvoices('inv1')['invoices']) == 1
|
||||
assert only_one(l1.rpc.listinvoices('inv1')['invoices'])['status'] == 'expired'
|
||||
assert len(l1.rpc.listinvoices('inv2')['invoices']) == 1
|
||||
assert only_one(l1.rpc.listinvoices('inv2')['invoices'])['status'] != 'expired'
|
||||
|
||||
time.sleep(start_time - time.time() + 10) # total 10
|
||||
# inv1 should have deleted, inv2 still there and unexpired.
|
||||
assert len(l1.rpc.listinvoices('inv1')['invoices']) == 0
|
||||
assert len(l1.rpc.listinvoices('inv2')['invoices']) == 1
|
||||
assert only_one(l1.rpc.listinvoices('inv2')['invoices'])['status'] != 'expired'
|
||||
|
||||
time.sleep(start_time - time.time() + 14) # total 14
|
||||
# inv2 should still be there, but expired
|
||||
assert len(l1.rpc.listinvoices('inv1')['invoices']) == 0
|
||||
assert len(l1.rpc.listinvoices('inv2')['invoices']) == 1
|
||||
assert only_one(l1.rpc.listinvoices('inv2')['invoices'])['status'] == 'expired'
|
||||
|
||||
time.sleep(start_time - time.time() + 18) # total 18
|
||||
# Everything deleted
|
||||
assert len(l1.rpc.listinvoices('inv1')['invoices']) == 0
|
||||
assert len(l1.rpc.listinvoices('inv2')['invoices']) == 0
|
||||
|
||||
# stress test
|
||||
l1.rpc.autocleaninvoice(cycle_seconds=0)
|
||||
l1.rpc.autocleaninvoice(cycle_seconds=1)
|
||||
l1.rpc.autocleaninvoice(cycle_seconds=0)
|
||||
time.sleep(1)
|
||||
l1.rpc.autocleaninvoice(cycle_seconds=1, expired_by=1)
|
||||
|
||||
|
||||
def test_decode_unknown(node_factory):
|
||||
l1 = node_factory.get_node()
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user