From 8e8d7c2aba3d5477125c56c43cb858f9c548bf67 Mon Sep 17 00:00:00 2001 From: ZmnSCPxj Date: Fri, 2 Mar 2018 12:54:37 +0000 Subject: [PATCH] pay/sendpay: Use spec names for rhash and r. --- contrib/pylightning/lightning/lightning.py | 6 +++--- lightningd/pay.c | 6 +++--- lightningd/payalgo.c | 2 +- tests/test_lightningd.py | 8 ++++---- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/contrib/pylightning/lightning/lightning.py b/contrib/pylightning/lightning/lightning.py index 49df328b9..15b142ec4 100644 --- a/contrib/pylightning/lightning/lightning.py +++ b/contrib/pylightning/lightning/lightning.py @@ -254,13 +254,13 @@ class LightningRpc(UnixDomainSocketRpc): """ return self.call("getinfo") - def sendpay(self, route, rhash): + def sendpay(self, route, payment_hash): """ - Send along {route} in return for preimage of {rhash} + Send along {route} in return for preimage of {payment_hash} """ payload = { "route": route, - "rhash": rhash + "payment_hash": payment_hash } return self.call("sendpay", payload) diff --git a/lightningd/pay.c b/lightningd/pay.c index d77b8b1d6..a10798b4a 100644 --- a/lightningd/pay.c +++ b/lightningd/pay.c @@ -640,7 +640,7 @@ json_sendpay_success(struct command *cmd, response = new_json_result(cmd); json_object_start(response, NULL); - json_add_hex(response, "preimage", + json_add_hex(response, "payment_preimage", payment_preimage, sizeof(*payment_preimage)); json_object_end(response); command_success(cmd, response); @@ -724,7 +724,7 @@ static void json_sendpay(struct command *cmd, if (!json_get_params(cmd, buffer, params, "route", &routetok, - "rhash", &rhashtok, + "payment_hash", &rhashtok, NULL)) { return; } @@ -807,7 +807,7 @@ static void json_sendpay(struct command *cmd, static const struct json_command sendpay_command = { "sendpay", json_sendpay, - "Send along {route} in return for preimage of {rhash}" + "Send along {route} in return for preimage of {payment_hash}" }; AUTODATA(json_command, &sendpay_command); diff --git a/lightningd/payalgo.c b/lightningd/payalgo.c index ad0a85d59..c2aa3c9a2 100644 --- a/lightningd/payalgo.c +++ b/lightningd/payalgo.c @@ -53,7 +53,7 @@ json_pay_success(struct command *cmd, response = new_json_result(cmd); json_object_start(response, NULL); - json_add_hex(response, "preimage", + json_add_hex(response, "payment_preimage", payment_preimage, sizeof(*payment_preimage)); json_add_num(response, "getroute_tries", getroute_tries); json_add_num(response, "sendpay_tries", sendpay_tries); diff --git a/tests/test_lightningd.py b/tests/test_lightningd.py index 30f75625b..be544f969 100644 --- a/tests/test_lightningd.py +++ b/tests/test_lightningd.py @@ -838,14 +838,14 @@ class LightningDTests(BaseLightningDTests): assert len(payments) == 1 assert payments[0]['status'] == 'complete' - assert payments[0]['payment_preimage'] == preimage2['preimage'] + assert payments[0]['payment_preimage'] == preimage2['payment_preimage'] invoice3 = l2.rpc.listinvoices('testpayment3')['invoices'][0] payments = l1.rpc.listpayments(payment_hash=invoice3['payment_hash'])['payments'] assert len(payments) == 1 assert payments[0]['status'] == 'complete' - assert payments[0]['payment_preimage'] == preimage3['preimage'] + assert payments[0]['payment_preimage'] == preimage3['payment_preimage'] def test_sendpay_cant_afford(self): l1, l2 = self.connect() @@ -938,7 +938,7 @@ class LightningDTests(BaseLightningDTests): # Test listpayments indexed by bolt11. assert len(l1.rpc.listpayments(inv)['payments']) == 1 - assert l1.rpc.listpayments(inv)['payments'][0]['payment_preimage'] == preimage['preimage'] + assert l1.rpc.listpayments(inv)['payments'][0]['payment_preimage'] == preimage['payment_preimage'] def test_pay_optional_args(self): l1, l2 = self.connect() @@ -3110,7 +3110,7 @@ class LightningDTests(BaseLightningDTests): self.wait_for_routes(l1, [chanid]) # A duplicate should succeed immediately (nop) and return correct preimage. - preimage = l1.rpc.pay(inv1['bolt11'])['preimage'] + preimage = l1.rpc.pay(inv1['bolt11'])['payment_preimage'] assert l1.rpc.dev_rhash(preimage)['rhash'] == inv1['payment_hash'] @unittest.skipIf(not DEVELOPER, "needs DEVELOPER=1")