mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-02-20 13:54:36 +01:00
JSON: Rename rhash to payment_hash in delinvoice, invoice, listinvoice, waitinvoice, waitanyinvoice.
'rhash' is the old terminology, but 'payment_preimage' and 'payment_hash' were decided on for the BOLTs, so we should fix that here. We still use rhash internally, but that's much easier to fix. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
parent
f031120903
commit
66885163c9
8 changed files with 27 additions and 27 deletions
|
@ -115,4 +115,4 @@ if __name__ == "__main__":
|
|||
print(invoice)
|
||||
route = l1.getroute(info5['id'], 100, 1)
|
||||
print(route)
|
||||
print(l1.sendpay(route['route'], invoice['rhash']))
|
||||
print(l1.sendpay(route['route'], invoice['payment_hash']))
|
||||
|
|
|
@ -41,7 +41,7 @@ The \fImsatoshi\fR can be the string "any", which creates an invoice that can be
|
|||
The \fIlabel\fR must be unique; it is never revealed to other nodes on the lightning network, but it can be used to query the status of this invoice\&.
|
||||
.SH "RETURN VALUE"
|
||||
.sp
|
||||
On success, a hash is returned as \fIrhash\fR to be given to the payer, and the \fIexpiry_time\fR as a UNIX timestamp\&. It also returns a BOLT11 invoice as \fIbolt11\fR to be given to the payer\&. On failure, an error is returned and no invoice is created\&. If the lightning process fails before responding, the caller should use lightning\-listinvoice(7) to query whether this invoice was created or not\&.
|
||||
On success, a hash is returned as \fIpayment_hash\fR to be given to the payer, and the \fIexpiry_time\fR as a UNIX timestamp\&. It also returns a BOLT11 invoice as \fIbolt11\fR to be given to the payer\&. On failure, an error is returned and no invoice is created\&. If the lightning process fails before responding, the caller should use lightning\-listinvoice(7) to query whether this invoice was created or not\&.
|
||||
.SH "AUTHOR"
|
||||
.sp
|
||||
Rusty Russell <rusty@rustcorp\&.com\&.au> is mainly responsible\&.
|
||||
|
|
|
@ -26,7 +26,7 @@ invoice.
|
|||
RETURN VALUE
|
||||
------------
|
||||
|
||||
On success, a hash is returned as 'rhash' to be given to the payer,
|
||||
On success, a hash is returned as 'payment_hash' to be given to the payer,
|
||||
and the 'expiry_time' as a UNIX timestamp.
|
||||
It also returns a BOLT11 invoice as 'bolt11' to be given to the
|
||||
payer.
|
||||
|
|
|
@ -37,7 +37,7 @@ lightning-listinvoice \- Protocol for querying invoice status
|
|||
The \fBlistinvoice\fR RPC command gets the status of a specific invoice, if it exists, or the status of all invoices if given no argument\&.
|
||||
.SH "RETURN VALUE"
|
||||
.sp
|
||||
On success, an array \fIinvoices\fR of objects containing \fIlabel\fR, \fIrhash\fR, \fImsatoshi\fR (if not "any"), \fIcomplete\fR, \fIpay_index\fR (if paid) and \fIexpiry_time\fR} will be returned\&. \fIcomplete\fR is a boolean, and \fIexpiry_time\fR is the number of seconds since UNIX epoch\&.
|
||||
On success, an array \fIinvoices\fR of objects containing \fIlabel\fR, \fIpayment_hash, \*(Aqmsatoshi\fR (if not "any"), \fIcomplete\fR, \fIpay_index\fR (if paid) and \fIexpiry_time\fR} will be returned\&. \fIcomplete\fR is a boolean, and \fIexpiry_time\fR is the number of seconds since UNIX epoch\&.
|
||||
.SH "AUTHOR"
|
||||
.sp
|
||||
Rusty Russell <rusty@rustcorp\&.com\&.au> is mainly responsible\&.
|
||||
|
|
|
@ -17,7 +17,7 @@ it exists, or the status of all invoices if given no argument.
|
|||
|
||||
RETURN VALUE
|
||||
------------
|
||||
On success, an array 'invoices' of objects is returned. Each object contains 'label', 'rhash', 'complete' (a boolean), and 'expiry_time' (a UNIX timestamp). If the 'msatoshi' argument to lightning-invoice(7) was not "any", there will be an 'msatoshi' field. If the invoice has been paid, there will be a 'pay_index' field.
|
||||
On success, an array 'invoices' of objects is returned. Each object contains 'label', 'payment_hash, 'complete' (a boolean), and 'expiry_time' (a UNIX timestamp). If the 'msatoshi' argument to lightning-invoice(7) was not "any", there will be an 'msatoshi' field. If the invoice has been paid, there will be a 'pay_index' field.
|
||||
|
||||
//FIXME:Enumerate errors
|
||||
|
||||
|
|
|
@ -79,7 +79,7 @@ static void json_add_invoice(struct json_result *response,
|
|||
{
|
||||
json_object_start(response, NULL);
|
||||
json_add_string(response, "label", inv->label);
|
||||
json_add_hex(response, "rhash", &inv->rhash, sizeof(inv->rhash));
|
||||
json_add_hex(response, "payment_hash", &inv->rhash, sizeof(inv->rhash));
|
||||
if (inv->msatoshi)
|
||||
json_add_u64(response, "msatoshi", *inv->msatoshi);
|
||||
json_add_bool(response, "complete", inv->state == PAID);
|
||||
|
@ -283,7 +283,7 @@ static void json_invoice(struct command *cmd,
|
|||
}
|
||||
|
||||
json_object_start(response, NULL);
|
||||
json_add_hex(response, "rhash",
|
||||
json_add_hex(response, "payment_hash",
|
||||
&invoice->rhash, sizeof(invoice->rhash));
|
||||
json_add_u64(response, "expiry_time", invoice->expiry_time);
|
||||
json_add_string(response, "bolt11", b11enc);
|
||||
|
@ -298,7 +298,7 @@ static const struct json_command invoice_command = {
|
|||
"invoice",
|
||||
json_invoice,
|
||||
"Create invoice for {msatoshi} with {label} and {description} with optional {expiry} seconds (default 1 hour)",
|
||||
"Returns the {rhash}, {expiry_time} and {bolt11} on success, and {description} if too large for {bolt11}. "
|
||||
"Returns the {payment_hash}, {expiry_time} and {bolt11} on success, and {description} if too large for {bolt11}. "
|
||||
};
|
||||
AUTODATA(json_command, &invoice_command);
|
||||
|
||||
|
@ -343,7 +343,7 @@ static const struct json_command listinvoice_command = {
|
|||
"listinvoice",
|
||||
json_listinvoice,
|
||||
"Show invoice {label} (or all, if no {label}))",
|
||||
"Returns an array of {label}, {rhash}, {msatoshi} (if set), {complete}, {pay_index} (if paid) and {expiry_time} on success. "
|
||||
"Returns an array of {label}, {payment_hash}, {msatoshi} (if set), {complete}, {pay_index} (if paid) and {expiry_time} on success. "
|
||||
};
|
||||
AUTODATA(json_command, &listinvoice_command);
|
||||
|
||||
|
@ -395,7 +395,7 @@ static const struct json_command delinvoice_command = {
|
|||
"delinvoice",
|
||||
json_delinvoice,
|
||||
"Delete unpaid invoice {label}))",
|
||||
"Returns {label}, {rhash}, {msatoshi} (if set), {complete}, {pay_index} (if paid) and {expiry_time} on success. "
|
||||
"Returns {label}, {payment_hash}, {msatoshi} (if set), {complete}, {pay_index} (if paid) and {expiry_time} on success. "
|
||||
};
|
||||
AUTODATA(json_command, &delinvoice_command);
|
||||
|
||||
|
@ -455,7 +455,7 @@ static const struct json_command waitanyinvoice_command = {
|
|||
"waitanyinvoice",
|
||||
json_waitanyinvoice,
|
||||
"Wait for the next invoice to be paid, after {lastpay_index} (if supplied)))",
|
||||
"Returns {label}, {rhash}, {msatoshi} (if set), {complete}, {pay_index} and {expiry_time} on success. "
|
||||
"Returns {label}, {payment_hash}, {msatoshi} (if set), {complete}, {pay_index} and {expiry_time} on success. "
|
||||
};
|
||||
AUTODATA(json_command, &waitanyinvoice_command);
|
||||
|
||||
|
@ -502,7 +502,7 @@ static const struct json_command waitinvoice_command = {
|
|||
"waitinvoice",
|
||||
json_waitinvoice,
|
||||
"Wait for an incoming payment matching the invoice with {label}",
|
||||
"Returns {label}, {rhash}, {msatoshi} (if set), {complete}, {pay_index} and {expiry_time} on success"
|
||||
"Returns {label}, {payment_hash}, {msatoshi} (if set), {complete}, {pay_index} and {expiry_time} on success"
|
||||
};
|
||||
AUTODATA(json_command, &waitinvoice_command);
|
||||
|
||||
|
|
|
@ -59,7 +59,7 @@ def test_single_hop(node_factory, executor):
|
|||
fs = []
|
||||
invoices = []
|
||||
for i in tqdm(range(num_payments)):
|
||||
invoices.append(l2.rpc.invoice(1000, 'invoice-%d' % (i), 'desc')['rhash'])
|
||||
invoices.append(l2.rpc.invoice(1000, 'invoice-%d' % (i), 'desc')['payment_hash'])
|
||||
|
||||
route = l1.rpc.getroute(l2.rpc.getinfo()['id'], 1000, 1)['route']
|
||||
print("Sending payments")
|
||||
|
|
|
@ -276,7 +276,7 @@ class LightningDTests(BaseLightningDTests):
|
|||
if not label:
|
||||
label = ''.join(random.choice(string.ascii_letters + string.digits) for _ in range(20))
|
||||
|
||||
rhash = ldst.rpc.invoice(amt, label, label)['rhash']
|
||||
rhash = ldst.rpc.invoice(amt, label, label)['payment_hash']
|
||||
assert ldst.rpc.listinvoice(label)[0]['complete'] == False
|
||||
|
||||
routestep = {
|
||||
|
@ -331,7 +331,7 @@ class LightningDTests(BaseLightningDTests):
|
|||
assert b11['currency'] == 'tb'
|
||||
assert b11['timestamp'] >= before
|
||||
assert b11['timestamp'] <= after
|
||||
assert b11['payment_hash'] == inv['rhash']
|
||||
assert b11['payment_hash'] == inv['payment_hash']
|
||||
assert b11['description'] == 'description'
|
||||
assert b11['expiry'] == 3600
|
||||
assert b11['payee'] == l1.info['id']
|
||||
|
@ -633,7 +633,7 @@ class LightningDTests(BaseLightningDTests):
|
|||
self.fund_channel(l1, l2, 10**6)
|
||||
|
||||
amt = 200000000
|
||||
rhash = l2.rpc.invoice(amt, 'testpayment2', 'desc')['rhash']
|
||||
rhash = l2.rpc.invoice(amt, 'testpayment2', 'desc')['payment_hash']
|
||||
assert l2.rpc.listinvoice('testpayment2')[0]['complete'] == False
|
||||
|
||||
routestep = {
|
||||
|
@ -695,7 +695,7 @@ class LightningDTests(BaseLightningDTests):
|
|||
assert l2.rpc.listinvoice('testpayment2')[0]['complete'] == True
|
||||
|
||||
# Overpaying by "only" a factor of 2 succeeds.
|
||||
rhash = l2.rpc.invoice(amt, 'testpayment3', 'desc')['rhash']
|
||||
rhash = l2.rpc.invoice(amt, 'testpayment3', 'desc')['payment_hash']
|
||||
assert l2.rpc.listinvoice('testpayment3')[0]['complete'] == False
|
||||
routestep = { 'msatoshi' : amt * 2, 'id' : l2.info['id'], 'delay' : 5, 'channel': '1:1:1'}
|
||||
l1.rpc.sendpay(to_json([routestep]), rhash)
|
||||
|
@ -919,7 +919,7 @@ class LightningDTests(BaseLightningDTests):
|
|||
self.fund_channel(l1, l2, 10**6)
|
||||
|
||||
# Must be dust!
|
||||
rhash = l2.rpc.invoice(1, 'onchain_dust_out', 'desc')['rhash']
|
||||
rhash = l2.rpc.invoice(1, 'onchain_dust_out', 'desc')['payment_hash']
|
||||
routestep = {
|
||||
'msatoshi' : 1,
|
||||
'id' : l2.info['id'],
|
||||
|
@ -971,7 +971,7 @@ class LightningDTests(BaseLightningDTests):
|
|||
l1.rpc.connect(l2.info['id'], 'localhost', l2.info['port'])
|
||||
self.fund_channel(l1, l2, 10**6)
|
||||
|
||||
rhash = l2.rpc.invoice(10**8, 'onchain_timeout', 'desc')['rhash']
|
||||
rhash = l2.rpc.invoice(10**8, 'onchain_timeout', 'desc')['payment_hash']
|
||||
# We underpay, so it fails.
|
||||
routestep = {
|
||||
'msatoshi' : 10**8 - 1,
|
||||
|
@ -1044,7 +1044,7 @@ class LightningDTests(BaseLightningDTests):
|
|||
self.pay(l2, l1, 2 * 10**8)
|
||||
|
||||
# Must be bigger than dust!
|
||||
rhash = l3.rpc.invoice(10**8, 'middleman', 'desc')['rhash']
|
||||
rhash = l3.rpc.invoice(10**8, 'middleman', 'desc')['payment_hash']
|
||||
|
||||
route = l1.rpc.getroute(l3.info['id'], 10**8, 1)["route"]
|
||||
assert len(route) == 2
|
||||
|
@ -1529,7 +1529,7 @@ class LightningDTests(BaseLightningDTests):
|
|||
assert l2.rpc.getpeer(l1.info['id'])['channel'] == chanid1
|
||||
assert l3.rpc.getpeer(l2.info['id'])['channel'] == chanid2
|
||||
|
||||
rhash = l3.rpc.invoice(100000000, 'testpayment1', 'desc')['rhash']
|
||||
rhash = l3.rpc.invoice(100000000, 'testpayment1', 'desc')['payment_hash']
|
||||
assert l3.rpc.listinvoice('testpayment1')[0]['complete'] == False
|
||||
|
||||
# Fee for node2 is 10 millionths, plus 1.
|
||||
|
@ -1670,7 +1670,7 @@ class LightningDTests(BaseLightningDTests):
|
|||
assert route[1]['msatoshi'] == 4999999
|
||||
assert route[1]['delay'] == 9 + shadow_route
|
||||
|
||||
rhash = l3.rpc.invoice(4999999, 'test_forward_different_fees_and_cltv', 'desc')['rhash']
|
||||
rhash = l3.rpc.invoice(4999999, 'test_forward_different_fees_and_cltv', 'desc')['payment_hash']
|
||||
assert l3.rpc.listinvoice('test_forward_different_fees_and_cltv')[0]['complete'] == False
|
||||
|
||||
# This should work.
|
||||
|
@ -1727,7 +1727,7 @@ class LightningDTests(BaseLightningDTests):
|
|||
route[1]['delay'] += 10
|
||||
|
||||
# This should work.
|
||||
rhash = l3.rpc.invoice(4999999, 'test_forward_pad_fees_and_cltv', 'desc')['rhash']
|
||||
rhash = l3.rpc.invoice(4999999, 'test_forward_pad_fees_and_cltv', 'desc')['payment_hash']
|
||||
l1.rpc.sendpay(to_json(route), rhash)
|
||||
assert l3.rpc.listinvoice('test_forward_pad_fees_and_cltv')[0]['complete'] == True
|
||||
|
||||
|
@ -2017,7 +2017,7 @@ class LightningDTests(BaseLightningDTests):
|
|||
self.fund_channel(l1, l2, 10**6)
|
||||
|
||||
amt = 200000000
|
||||
rhash = l2.rpc.invoice(amt, 'test_reconnect_sender_add1', 'desc')['rhash']
|
||||
rhash = l2.rpc.invoice(amt, 'test_reconnect_sender_add1', 'desc')['payment_hash']
|
||||
assert l2.rpc.listinvoice('test_reconnect_sender_add1')[0]['complete'] == False
|
||||
|
||||
route = [ { 'msatoshi' : amt, 'id' : l2.info['id'], 'delay' : 5, 'channel': '1:1:1'} ]
|
||||
|
@ -2045,7 +2045,7 @@ class LightningDTests(BaseLightningDTests):
|
|||
self.fund_channel(l1, l2, 10**6)
|
||||
|
||||
amt = 200000000
|
||||
rhash = l2.rpc.invoice(amt, 'testpayment', 'desc')['rhash']
|
||||
rhash = l2.rpc.invoice(amt, 'testpayment', 'desc')['payment_hash']
|
||||
assert l2.rpc.listinvoice('testpayment')[0]['complete'] == False
|
||||
|
||||
route = [ { 'msatoshi' : amt, 'id' : l2.info['id'], 'delay' : 5, 'channel': '1:1:1'} ]
|
||||
|
@ -2071,7 +2071,7 @@ class LightningDTests(BaseLightningDTests):
|
|||
self.fund_channel(l1, l2, 10**6)
|
||||
|
||||
amt = 200000000
|
||||
rhash = l2.rpc.invoice(amt, 'testpayment2', 'desc')['rhash']
|
||||
rhash = l2.rpc.invoice(amt, 'testpayment2', 'desc')['payment_hash']
|
||||
assert l2.rpc.listinvoice('testpayment2')[0]['complete'] == False
|
||||
|
||||
route = [ { 'msatoshi' : amt, 'id' : l2.info['id'], 'delay' : 5, 'channel': '1:1:1'} ]
|
||||
|
@ -2101,7 +2101,7 @@ class LightningDTests(BaseLightningDTests):
|
|||
self.fund_channel(l1, l2, 10**6)
|
||||
|
||||
amt = 200000000
|
||||
rhash = l2.rpc.invoice(amt, 'testpayment2', 'desc')['rhash']
|
||||
rhash = l2.rpc.invoice(amt, 'testpayment2', 'desc')['payment_hash']
|
||||
assert l2.rpc.listinvoice('testpayment2')[0]['complete'] == False
|
||||
|
||||
route = [ { 'msatoshi' : amt, 'id' : l2.info['id'], 'delay' : 5, 'channel': '1:1:1'} ]
|
||||
|
|
Loading…
Add table
Reference in a new issue