mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-01-17 19:03:42 +01:00
common/features: add payment_secret
feature if EXPERIMENTAL.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
parent
3b37c9d426
commit
8393d21503
@ -10,6 +10,7 @@ static const u32 our_features[] = {
|
||||
OPTIONAL_FEATURE(OPT_GOSSIP_QUERIES),
|
||||
#if EXPERIMENTAL_FEATURES
|
||||
OPTIONAL_FEATURE(OPT_VAR_ONION),
|
||||
OPTIONAL_FEATURE(OPT_PAYMENT_SECRET),
|
||||
#endif
|
||||
OPTIONAL_FEATURE(OPT_GOSSIP_QUERIES_EX),
|
||||
OPTIONAL_FEATURE(OPT_STATIC_REMOTEKEY),
|
||||
|
@ -827,6 +827,7 @@ static struct command_result *json_invoice(struct command *cmd,
|
||||
info->b11->description_hash = NULL;
|
||||
info->b11->payment_secret = tal_dup(info->b11, struct secret,
|
||||
&payment_secret);
|
||||
info->b11->features = get_offered_bolt11features(info->b11);
|
||||
|
||||
|
||||
#if DEVELOPER
|
||||
|
@ -123,6 +123,9 @@ void fulfill_htlc(struct htlc_in *hin UNNEEDED, const struct preimage *preimage
|
||||
/* Generated stub for get_block_height */
|
||||
u32 get_block_height(const struct chain_topology *topo UNNEEDED)
|
||||
{ fprintf(stderr, "get_block_height called!\n"); abort(); }
|
||||
/* Generated stub for get_offered_bolt11features */
|
||||
u8 *get_offered_bolt11features(const tal_t *ctx UNNEEDED)
|
||||
{ fprintf(stderr, "get_offered_bolt11features called!\n"); abort(); }
|
||||
/* Generated stub for htlc_is_trimmed */
|
||||
bool htlc_is_trimmed(enum side htlc_owner UNNEEDED,
|
||||
struct amount_msat htlc_amount UNNEEDED,
|
||||
|
@ -1709,8 +1709,10 @@ def test_list_features_only(node_factory):
|
||||
'option_upfront_shutdown_script/odd',
|
||||
'option_gossip_queries/odd',
|
||||
'option_var_onion_optin/odd',
|
||||
'option_payment_secret/odd',
|
||||
'option_gossip_queries_ex/odd',
|
||||
'option_static_remotekey/odd']
|
||||
'option_static_remotekey/odd',
|
||||
]
|
||||
else:
|
||||
expected = ['option_data_loss_protect/odd',
|
||||
'option_upfront_shutdown_script/odd',
|
||||
|
@ -2371,9 +2371,12 @@ def test_tlv_or_legacy(node_factory, bitcoind):
|
||||
'cltv_expiry_delta': 6}]]})['bolt11']
|
||||
l1.rpc.pay(inv)
|
||||
|
||||
# Since L1 hasn't seen broadcast, it doesn't know they're TLV.
|
||||
# Since L1 hasn't seen broadcast, it doesn't know L2 is TLV, but invoice tells it about L3
|
||||
l2.daemon.wait_for_log("Got onion.*'type': 'legacy'")
|
||||
l3.daemon.wait_for_log("Got onion.*'type': 'legacy'")
|
||||
if EXPERIMENTAL_FEATURES:
|
||||
l3.daemon.wait_for_log("Got onion.*'type': 'tlv'")
|
||||
else:
|
||||
l3.daemon.wait_for_log("Got onion.*'type': 'legacy'")
|
||||
|
||||
# Turns out we only need 3 more blocks to announce l1->l2 channel.
|
||||
bitcoind.generate_block(3)
|
||||
@ -2384,24 +2387,9 @@ def test_tlv_or_legacy(node_factory, bitcoind):
|
||||
# Make sure l3 knows about l1->l2, so it will add route hint now.
|
||||
wait_for(lambda: len(l3.rpc.listchannels(scid12)['channels']) > 0)
|
||||
|
||||
# Now it should send TLV to l2, but not l3.
|
||||
# Now it should send TLV to l2.
|
||||
inv = l3.rpc.invoice(10000, "test_tlv2", "test_tlv2")['bolt11']
|
||||
|
||||
l1.rpc.pay(inv)
|
||||
if EXPERIMENTAL_FEATURES:
|
||||
l2.daemon.wait_for_log("Got onion.*'type': 'tlv'")
|
||||
else:
|
||||
l2.daemon.wait_for_log("Got onion.*'type': 'legacy'")
|
||||
l3.daemon.wait_for_log("Got onion.*'type': 'legacy'")
|
||||
|
||||
# Now we finally announce l2->l3 channel, so l3 can announce tlv support.
|
||||
bitcoind.generate_block(2)
|
||||
|
||||
wait_for(lambda: len(l1.rpc.listnodes(l3.info['id'])['nodes']) > 0)
|
||||
wait_for(lambda: 'alias' in l1.rpc.listnodes(l3.info['id'])['nodes'][0])
|
||||
|
||||
inv = l3.rpc.invoice(10000, "test_tlv3", "test_tlv3")['bolt11']
|
||||
|
||||
l1.rpc.pay(inv)
|
||||
if EXPERIMENTAL_FEATURES:
|
||||
l2.daemon.wait_for_log("Got onion.*'type': 'tlv'")
|
||||
@ -2414,7 +2402,7 @@ def test_tlv_or_legacy(node_factory, bitcoind):
|
||||
@unittest.skipIf(not EXPERIMENTAL_FEATURES, 'Needs invoice secret support')
|
||||
@unittest.skipIf(not DEVELOPER, 'Needs dev-routes')
|
||||
def test_pay_no_secret(node_factory, bitcoind):
|
||||
l1, l2 = node_factory.line_graph(2, wait_for_announce=True)
|
||||
l1, l2 = node_factory.line_graph(2, wait_for_announce=False)
|
||||
|
||||
l2.rpc.invoice(100000, "test_pay_no_secret", "test_pay_no_secret",
|
||||
preimage='00' * 32, expiry=2000000000)
|
||||
|
@ -9,8 +9,8 @@ COMPAT = env("COMPAT", "1") == "1"
|
||||
def expected_features():
|
||||
"""Return the expected features hexstring for this configuration"""
|
||||
if EXPERIMENTAL_FEATURES:
|
||||
# features 1, 3, 7, 9, 11 and 13 (0x2aa2).
|
||||
return "2aa2"
|
||||
# features 1, 3, 7, 9, 11, 13 and 15 (0xaaa2).
|
||||
return "aaa2"
|
||||
else:
|
||||
# features 1, 3, 7, 11 and 13 (0x28a2).
|
||||
return "28a2"
|
||||
|
Loading…
Reference in New Issue
Block a user