Skip to content

Commit b7856e3

Browse files
alaniz3rustyrussell
authored andcommitted
Onboarding: tweak grammar conventions for RPC responses
1 parent 505a249 commit b7856e3

File tree

6 files changed

+24
-24
lines changed

6 files changed

+24
-24
lines changed

lightningd/chaintopology.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -563,7 +563,7 @@ void json_dev_broadcast(struct command *cmd,
563563
}
564564

565565
if (!json_tok_bool(buffer, enabletok, &enable)) {
566-
command_fail(cmd, "enable must be true or false");
566+
command_fail(cmd, "Enable must be true or false");
567567
return;
568568
}
569569

@@ -625,7 +625,7 @@ static void json_dev_setfees(struct command *cmd,
625625
continue;
626626
if (!json_tok_number(buffer, ratetok[i],
627627
&topo->override_fee_rate[i])) {
628-
command_fail(cmd, "invalid feerate %.*s",
628+
command_fail(cmd, "Invalid feerate %.*s",
629629
(int)(ratetok[i]->end - ratetok[i]->start),
630630
buffer + ratetok[i]->start);
631631
return;

lightningd/invoice.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ static void tell_waiter(struct command *cmd, const struct invoice *paid)
6666
}
6767
static void tell_waiter_deleted(struct command *cmd)
6868
{
69-
command_fail(cmd, "invoice deleted during wait");
69+
command_fail(cmd, "Invoice deleted during wait");
7070
}
7171
static void wait_on_invoice(const struct invoice *invoice, void *cmd)
7272
{
@@ -140,12 +140,12 @@ static void json_invoice(struct command *cmd,
140140
return;
141141
}
142142
if (strlen(label_val) > INVOICE_MAX_LABEL_LEN) {
143-
command_fail(cmd, "label '%s' over %u bytes", label_val,
143+
command_fail(cmd, "Label '%s' over %u bytes", label_val,
144144
INVOICE_MAX_LABEL_LEN);
145145
return;
146146
}
147147
if (exp && !json_tok_u64(buffer, exp, &expiry)) {
148-
command_fail(cmd, "expiry '%.*s' invalid seconds",
148+
command_fail(cmd, "Expiry '%.*s' invalid seconds",
149149
exp->end - exp->start,
150150
buffer + exp->start);
151151
return;

lightningd/jsonrpc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -617,7 +617,7 @@ static void parse_request(struct json_connection *jcon, const jsmntok_t tok[])
617617
if (cmd->deprecated && !deprecated_apis) {
618618
command_fail_detailed(jcon->current,
619619
JSONRPC2_METHOD_NOT_FOUND, NULL,
620-
"command '%.*s' is deprecated",
620+
"Command '%.*s' is deprecated",
621621
(int)(method->end - method->start),
622622
jcon->buffer + method->start);
623623
return;

lightningd/pay.c

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ static void json_pay_failed(struct command *cmd,
3939
{
4040
/* Can be NULL if JSON RPC goes away. */
4141
if (cmd) {
42-
command_fail(cmd, "failed: %s (%s)",
42+
command_fail(cmd, "Failed: %s (%s)",
4343
onion_type_name(failure_code), details);
4444
}
4545
}
@@ -342,22 +342,22 @@ static bool send_payment(struct command *cmd,
342342
/* FIXME: We should really do something smarter here! */
343343
log_debug(cmd->ld->log, "json_sendpay: found previous");
344344
if (payment->status == PAYMENT_PENDING) {
345-
log_add(cmd->ld->log, "... still in progress");
346-
command_fail(cmd, "still in progress");
345+
log_add(cmd->ld->log, "Payment is still in progress");
346+
command_fail(cmd, "Payment is still in progress");
347347
return false;
348348
}
349349
if (payment->status == PAYMENT_COMPLETE) {
350350
log_add(cmd->ld->log, "... succeeded");
351351
/* Must match successful payment parameters. */
352352
if (payment->msatoshi != hop_data[n_hops-1].amt_forward) {
353353
command_fail(cmd,
354-
"already succeeded with amount %"
354+
"Already succeeded with amount %"
355355
PRIu64, payment->msatoshi);
356356
return false;
357357
}
358358
if (!structeq(&payment->destination, &ids[n_hops-1])) {
359359
command_fail(cmd,
360-
"already succeeded to %s",
360+
"Already succeeded to %s",
361361
type_to_string(cmd, struct pubkey,
362362
&payment->destination));
363363
return false;
@@ -371,7 +371,7 @@ static bool send_payment(struct command *cmd,
371371

372372
peer = peer_by_id(cmd->ld, &ids[0]);
373373
if (!peer) {
374-
command_fail(cmd, "no connection to first peer found");
374+
command_fail(cmd, "No connection to first peer found");
375375
return false;
376376
}
377377

@@ -390,7 +390,7 @@ static bool send_payment(struct command *cmd,
390390
rhash, onion, NULL, cmd,
391391
&hout);
392392
if (failcode) {
393-
command_fail(cmd, "first peer not ready: %s",
393+
command_fail(cmd, "First peer not ready: %s",
394394
onion_type_name(failcode));
395395
return false;
396396
}
@@ -463,7 +463,7 @@ static void json_sendpay(struct command *cmd,
463463
const jsmntok_t *amttok, *idtok, *delaytok, *chantok;
464464

465465
if (t->type != JSMN_OBJECT) {
466-
command_fail(cmd, "route %zu '%.*s' is not an object",
466+
command_fail(cmd, "Route %zu '%.*s' is not an object",
467467
n_hops,
468468
(int)(t->end - t->start),
469469
buffer + t->start);
@@ -474,7 +474,7 @@ static void json_sendpay(struct command *cmd,
474474
delaytok = json_get_member(buffer, t, "delay");
475475
chantok = json_get_member(buffer, t, "channel");
476476
if (!amttok || !idtok || !delaytok || !chantok) {
477-
command_fail(cmd, "route %zu needs msatoshi/id/channel/delay",
477+
command_fail(cmd, "Route %zu needs msatoshi/id/channel/delay",
478478
n_hops);
479479
return;
480480
}
@@ -483,22 +483,22 @@ static void json_sendpay(struct command *cmd,
483483

484484
/* What that hop will forward */
485485
if (!json_tok_number(buffer, amttok, &route[n_hops].amount)) {
486-
command_fail(cmd, "route %zu invalid msatoshi",
486+
command_fail(cmd, "Route %zu invalid msatoshi",
487487
n_hops);
488488
return;
489489
}
490490

491491
if (!json_tok_short_channel_id(buffer, chantok,
492492
&route[n_hops].channel_id)) {
493-
command_fail(cmd, "route %zu invalid channel_id", n_hops);
493+
command_fail(cmd, "Route %zu invalid channel_id", n_hops);
494494
return;
495495
}
496496
if (!json_tok_pubkey(buffer, idtok, &route[n_hops].nodeid)) {
497-
command_fail(cmd, "route %zu invalid id", n_hops);
497+
command_fail(cmd, "Route %zu invalid id", n_hops);
498498
return;
499499
}
500500
if (!json_tok_number(buffer, delaytok, &route[n_hops].delay)) {
501-
command_fail(cmd, "route %zu invalid delay", n_hops);
501+
command_fail(cmd, "Route %zu invalid delay", n_hops);
502502
return;
503503
}
504504
n_hops++;

lightningd/peer_control.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -769,7 +769,7 @@ static void json_connect(struct command *cmd,
769769
if (porttok) {
770770
u32 port;
771771
if (!json_tok_number(buffer, porttok, &port)) {
772-
command_fail(cmd, "port %.*s not valid",
772+
command_fail(cmd, "Port %.*s not valid",
773773
porttok->end - porttok->start,
774774
buffer + porttok->start);
775775
return;
@@ -779,7 +779,7 @@ static void json_connect(struct command *cmd,
779779
addr.port = DEFAULT_PORT;
780780
}
781781
if (!parse_wireaddr(name, &addr, addr.port) || !addr.port) {
782-
command_fail(cmd, "host %s:%u not valid",
782+
command_fail(cmd, "Host %s:%u not valid",
783783
name, addr.port);
784784
return;
785785
}

tests/test_lightningd.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3151,12 +3151,12 @@ def test_pay_disconnect(self):
31513151

31523152
# Can't pay while its offline.
31533153
self.assertRaises(ValueError, l1.rpc.sendpay, to_json(route), rhash)
3154-
l1.daemon.wait_for_log('Failing: first peer not ready: WIRE_TEMPORARY_CHANNEL_FAILURE')
3154+
l1.daemon.wait_for_log('Failing: First peer not ready: WIRE_TEMPORARY_CHANNEL_FAILURE')
31553155

31563156
# Should fail due to temporary channel fail
31573157
self.assertRaises(ValueError, l1.rpc.sendpay, to_json(route), rhash)
3158-
l1.daemon.wait_for_log('Failing: first peer not ready: WIRE_TEMPORARY_CHANNEL_FAILURE')
3159-
assert not l1.daemon.is_in_log('... still in progress')
3158+
l1.daemon.wait_for_log('Failing: First peer not ready: WIRE_TEMPORARY_CHANNEL_FAILURE')
3159+
assert not l1.daemon.is_in_log('Payment is still in progress')
31603160

31613161
# After it sees block, someone should close channel.
31623162
bitcoind.generate_block(1)

0 commit comments

Comments
 (0)