Create a node_announcement with the given signature. It may be NULL in the * case we need to create a provisional announcement for the HSM to sign. * This is called twice: once with the dummy signature to get it signed and a * second time to build the full packet with the signature. The timestamp is * handed in rather than using time_now() internally, since that could change * between the dum
| 27 | * handed in rather than using time_now() internally, since that could change |
| 28 | * between the dummy creation and the call with a signature. */ |
| 29 | static u8 *create_node_announcement(const tal_t *ctx, struct daemon *daemon, |
| 30 | const secp256k1_ecdsa_signature *sig, |
| 31 | u32 timestamp, |
| 32 | const struct lease_rates *rates) |
| 33 | { |
| 34 | struct wireaddr *was; |
| 35 | u8 *addresses = tal_arr(tmpctx, u8, 0); |
| 36 | u8 *announcement; |
| 37 | struct tlv_node_ann_tlvs *na_tlv; |
| 38 | size_t i, count_announceable; |
| 39 | |
| 40 | /* add all announceable addresses */ |
| 41 | count_announceable = tal_count(daemon->announceable); |
| 42 | was = tal_arr(tmpctx, struct wireaddr, 0); |
| 43 | for (i = 0; i < count_announceable; i++) |
| 44 | tal_arr_expand(&was, daemon->announceable[i]); |
| 45 | |
| 46 | /* Add discovered IPs v4/v6 verified by peer `remote_addr` feature. */ |
| 47 | /* Only do that if we don't have addresses announced. */ |
| 48 | if (count_announceable == 0) { |
| 49 | if (daemon->discovered_ip_v4 != NULL && |
| 50 | !wireaddr_arr_contains(was, daemon->discovered_ip_v4)) |
| 51 | tal_arr_expand(&was, *daemon->discovered_ip_v4); |
| 52 | if (daemon->discovered_ip_v6 != NULL && |
| 53 | !wireaddr_arr_contains(was, daemon->discovered_ip_v6)) |
| 54 | tal_arr_expand(&was, *daemon->discovered_ip_v6); |
| 55 | } |
| 56 | |
| 57 | /* Sort by address type again, as we added dynamic discovered_ip v4/v6. */ |
| 58 | /* BOLT #7: |
| 59 | * |
| 60 | * The origin node: |
| 61 | *... |
| 62 | * - MUST place address descriptors in ascending order. |
| 63 | */ |
| 64 | asort(was, tal_count(was), wireaddr_cmp_type, NULL); |
| 65 | |
| 66 | if (!sig) |
| 67 | sig = talz(tmpctx, secp256k1_ecdsa_signature); |
| 68 | |
| 69 | for (i = 0; i < tal_count(was); i++) |
| 70 | towire_wireaddr(&addresses, &was[i]); |
| 71 | |
| 72 | na_tlv = tlv_node_ann_tlvs_new(tmpctx); |
| 73 | na_tlv->option_will_fund = cast_const(struct lease_rates *, rates); |
| 74 | |
| 75 | announcement = |
| 76 | towire_node_announcement(ctx, sig, |
| 77 | daemon->our_features->bits[NODE_ANNOUNCE_FEATURE], |
| 78 | timestamp, |
| 79 | &daemon->id, daemon->rgb, daemon->alias, |
| 80 | addresses, |
| 81 | na_tlv); |
| 82 | return announcement; |
| 83 | } |
| 84 | |
| 85 | /* Helper to get non-signature, non-timestamp parts of (valid!) channel_update */ |
| 86 | void get_cupdate_parts(const u8 *channel_update, |
no test coverage detected