Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Blinded payments spec update and infrastructure for forwarding #5646

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
c4b6be4
hsmd: introduce a simple API versioning scheme.
rustyrussell Oct 17, 2022
01ce207
Makefile: check that hsm_version.h changes if wire/hsmd_wire.csv cont…
rustyrussell Oct 17, 2022
6a263d8
lightningd: use 33 byte pubkeys internally.
rustyrussell Oct 17, 2022
b013742
hsmd: don't use point32 for bolt12, but use pubkeys (though still alw…
rustyrussell Oct 17, 2022
b77aa11
bolt12: change our payer_key calculation.
rustyrussell Oct 17, 2022
5ba948c
gossmap: move gossmap_guess_node_id to pay plugin.
rustyrussell Oct 17, 2022
f9ea16b
Makefile: separate bolt12 wireobjects
rustyrussell Oct 17, 2022
94f5a09
BOLTs: update to more recent bolt12 spec.
rustyrussell Oct 17, 2022
0f65df7
offers: print out more details, fix up schema for decode of blinded p…
rustyrussell Oct 17, 2022
39881a5
Remove point32.
rustyrussell Oct 17, 2022
ce98096
wire: add latest Route Blinding htlc fields from https://github.com/l…
rustyrussell Oct 17, 2022
2a7a8ae
common: remove old route-blinding-override test, update route-blindin…
rustyrussell Oct 17, 2022
5de5afa
channeld: don't calculate blinding shared secret, let lightningd do it.
rustyrussell Oct 17, 2022
a5791ed
common/blindedpath: generalize routines.
rustyrussell Oct 17, 2022
a9a7367
common/blindedpath: generalize construction routines.
rustyrussell Oct 17, 2022
f036961
common/features: understand the route_blinding feature (feature 24)
rustyrussell Oct 17, 2022
19fd6ec
common/onion: blinded payment support.
rustyrussell Oct 17, 2022
0fcdcc3
common/onion: enforce payment constraints.
rustyrussell Oct 17, 2022
1efe4a3
common/onion: cleanup by removing unnecessary local temporary.
rustyrussell Oct 17, 2022
c342175
common/blindedpay: routines to construct a blinded payment.
rustyrussell Oct 17, 2022
9aab252
lightningd: return invalid_onon_blinding for any blinded payment error.
rustyrussell Oct 17, 2022
018c609
channeld, lightningd: allow blinded payments with !EXPERIMENTAL_FEATU…
rustyrussell Oct 17, 2022
c43bb60
common/test: check we meet bolt04/onion-route-blinding-test.json
rustyrussell Oct 17, 2022
ddf1f3b
common: update to latest onion message spec.
rustyrussell Oct 17, 2022
476cf5e
common/onion_message_parse: generic routine for parsing onion messages.
rustyrussell Oct 17, 2022
0152ffe
common/blindedpath: create onion mesage test vectors.
rustyrussell Oct 17, 2022
4c25d7c
wire/Makefile: fix missing wire/bolt12_exp_wiregen.c in ALL_C_SOURCES.
rustyrussell Oct 17, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 0 additions & 34 deletions bitcoin/pubkey.c
Original file line number Diff line number Diff line change
Expand Up @@ -125,37 +125,3 @@ void towire_pubkey(u8 **pptr, const struct pubkey *pubkey)

towire(pptr, output, outputlen);
}

void fromwire_point32(const u8 **cursor, size_t *max, struct point32 *point32)
{
u8 raw[32];

if (!fromwire(cursor, max, raw, sizeof(raw)))
return;

if (secp256k1_xonly_pubkey_parse(secp256k1_ctx,
&point32->pubkey,
raw) != 1) {
SUPERVERBOSE("not a valid point");
fromwire_fail(cursor, max);
}
}

void towire_point32(u8 **pptr, const struct point32 *point32)
{
u8 output[32];

secp256k1_xonly_pubkey_serialize(secp256k1_ctx, output,
&point32->pubkey);
towire(pptr, output, sizeof(output));
}

static char *point32_to_hexstr(const tal_t *ctx, const struct point32 *point32)
{
u8 output[32];

secp256k1_xonly_pubkey_serialize(secp256k1_ctx, output,
&point32->pubkey);
return tal_hexstr(ctx, output, sizeof(output));
}
REGISTER_TYPE_TO_STRING(point32, point32_to_hexstr);
16 changes: 0 additions & 16 deletions bitcoin/pubkey.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,6 @@ struct pubkey {
/* Define pubkey_eq (no padding) */
STRUCTEQ_DEF(pubkey, 0, pubkey.data);

struct point32 {
/* Unpacked pubkey (as used by libsecp256k1 internally) */
secp256k1_xonly_pubkey pubkey;
};
/* Define pubkey_eq (no padding) */
STRUCTEQ_DEF(point32, 0, pubkey.data);

/* Convert from hex string of DER (scriptPubKey from validateaddress) */
bool pubkey_from_hexstr(const char *derstr, size_t derlen, struct pubkey *key);

Expand Down Expand Up @@ -63,13 +56,4 @@ void pubkey_to_hash160(const struct pubkey *pk, struct ripemd160 *hash);
void towire_pubkey(u8 **pptr, const struct pubkey *pubkey);
void fromwire_pubkey(const u8 **cursor, size_t *max, struct pubkey *pubkey);

/* FIXME: Old spec uses pubkey32 */
#define pubkey32 point32
#define towire_pubkey32 towire_point32
#define fromwire_pubkey32 fromwire_point32

/* marshal/unmarshal functions */
void towire_point32(u8 **pptr, const struct point32 *pubkey);
void fromwire_point32(const u8 **cursor, size_t *max, struct point32 *pubkey);

#endif /* LIGHTNING_BITCOIN_PUBKEY_H */
51 changes: 12 additions & 39 deletions channeld/channeld.c
Original file line number Diff line number Diff line change
Expand Up @@ -690,31 +690,20 @@ static void handle_peer_add_htlc(struct peer *peer, const u8 *msg)
u8 onion_routing_packet[TOTAL_PACKET_SIZE(ROUTING_INFO_SIZE)];
enum channel_add_err add_err;
struct htlc *htlc;
#if EXPERIMENTAL_FEATURES
struct tlv_update_add_tlvs *tlvs;
#endif
struct pubkey *blinding = NULL;

if (!fromwire_update_add_htlc
#if EXPERIMENTAL_FEATURES
(msg, msg, &channel_id, &id, &amount,
&payment_hash, &cltv_expiry,
onion_routing_packet, &tlvs)
#else
(msg, &channel_id, &id, &amount,
&payment_hash, &cltv_expiry,
onion_routing_packet)
#endif
)
if (!fromwire_update_add_htlc(msg, msg, &channel_id, &id, &amount,
&payment_hash, &cltv_expiry,
onion_routing_packet, &tlvs)
/* This is an *even* field: don't send if we didn't understand */
|| (tlvs->blinding && !feature_offered(peer->our_features->bits[INIT_FEATURE],
OPT_ROUTE_BLINDING))) {
peer_failed_warn(peer->pps, &peer->channel_id,
"Bad peer_add_htlc %s", tal_hex(msg, msg));

#if EXPERIMENTAL_FEATURES
blinding = tlvs->blinding;
#endif
}
add_err = channel_add_htlc(peer->channel, REMOTE, id, amount,
cltv_expiry, &payment_hash,
onion_routing_packet, blinding, &htlc, NULL,
onion_routing_packet, tlvs->blinding, &htlc, NULL,
/* We don't immediately fail incoming htlcs,
* instead we wait and fail them after
* they've been committed */
Expand Down Expand Up @@ -1491,11 +1480,7 @@ static void marshall_htlc_info(const tal_t *ctx,
memcpy(a.onion_routing_packet,
htlc->routing,
sizeof(a.onion_routing_packet));
if (htlc->blinding) {
a.blinding = htlc->blinding;
ecdh(a.blinding, &a.blinding_ss);
} else
a.blinding = NULL;
a.blinding = htlc->blinding;
a.fail_immediate = htlc->fail_immediate;
tal_arr_expand(added, a);
} else if (htlc->state == RCVD_REMOVE_COMMIT) {
Expand Down Expand Up @@ -2435,25 +2420,19 @@ static void resend_commitment(struct peer *peer, struct changed_htlc *last)
last[i].id);

if (h->state == SENT_ADD_COMMIT) {
#if EXPERIMENTAL_FEATURES
struct tlv_update_add_tlvs *tlvs;
if (h->blinding) {
tlvs = tlv_update_add_tlvs_new(tmpctx);
tlvs->blinding = tal_dup(tlvs, struct pubkey,
h->blinding);
} else
tlvs = NULL;
#endif
msg = towire_update_add_htlc(NULL, &peer->channel_id,
h->id, h->amount,
&h->rhash,
abs_locktime_to_blocks(
&h->expiry),
h->routing
#if EXPERIMENTAL_FEATURES
, tlvs
#endif
);
h->routing, tlvs);
peer_write(peer->pps, take(msg));
}
}
Expand Down Expand Up @@ -3319,6 +3298,7 @@ static void handle_offer_htlc(struct peer *peer, const u8 *inmsg)
const char *failstr;
struct amount_sat htlc_fee;
struct pubkey *blinding;
struct tlv_update_add_tlvs *tlvs;

if (!peer->channel_ready[LOCAL] || !peer->channel_ready[REMOTE])
status_failed(STATUS_FAIL_MASTER_IO,
Expand All @@ -3329,14 +3309,11 @@ static void handle_offer_htlc(struct peer *peer, const u8 *inmsg)
onion_routing_packet, &blinding))
master_badmsg(WIRE_CHANNELD_OFFER_HTLC, inmsg);

#if EXPERIMENTAL_FEATURES
struct tlv_update_add_tlvs *tlvs;
if (blinding) {
tlvs = tlv_update_add_tlvs_new(tmpctx);
tlvs->blinding = tal_dup(tlvs, struct pubkey, blinding);
} else
tlvs = NULL;
#endif

e = channel_add_htlc(peer->channel, LOCAL, peer->htlc_id,
amount, cltv_expiry, &payment_hash,
Expand All @@ -3354,11 +3331,7 @@ static void handle_offer_htlc(struct peer *peer, const u8 *inmsg)
msg = towire_update_add_htlc(NULL, &peer->channel_id,
peer->htlc_id, amount,
&payment_hash, cltv_expiry,
onion_routing_packet
#if EXPERIMENTAL_FEATURES
, tlvs
#endif
);
onion_routing_packet, tlvs);
peer_write(peer->pps, take(msg));
start_commit_timer(peer);
/* Tell the master. */
Expand Down
3 changes: 3 additions & 0 deletions common/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ COMMON_SRC_NOGEN := \
common/billboard.c \
common/bip32.c \
common/blindedpath.c \
common/blindedpay.c \
common/blinding.c \
common/blockheight_states.c \
common/bolt11.c \
Expand Down Expand Up @@ -58,6 +59,7 @@ COMMON_SRC_NOGEN := \
common/node_id.c \
common/onion.c \
common/onionreply.c \
common/onion_message_parse.c \
common/peer_billboard.c \
common/peer_failed.c \
common/peer_io.c \
Expand Down Expand Up @@ -98,6 +100,7 @@ COMMON_HEADERS_NOGEN := $(COMMON_SRC_NOGEN:.c=.h) \
common/ecdh.h \
common/errcode.h \
common/gossip_constants.h \
common/hsm_version.h \
common/htlc.h \
common/json_command.h \
common/jsonrpc_errors.h \
Expand Down
Loading