| 169 | } |
| 170 | |
| 171 | static void print_nannounce(const struct node_id *nodeid, |
| 172 | const struct update_opts *opts, |
| 173 | const struct privkey *privkey) |
| 174 | { |
| 175 | /* 2 bytes msg type + 64 bytes of signature */ |
| 176 | const size_t node_announcement_offset = 2 + 64; |
| 177 | struct sha256_double hash; |
| 178 | secp256k1_ecdsa_signature sig; |
| 179 | char alias[33]; |
| 180 | struct tlv_node_ann_tlvs *tlvs; |
| 181 | u8 *nannounce; |
| 182 | |
| 183 | memset(&sig, 0, sizeof(sig)); |
| 184 | assert(hex_str_size(sizeof(*nodeid)) >= sizeof(alias)); |
| 185 | hex_encode(nodeid, hex_data_size(sizeof(alias)), alias, sizeof(alias)); |
| 186 | tlvs = tlv_node_ann_tlvs_new(NULL); |
| 187 | nannounce = towire_node_announcement(NULL, &sig, NULL, opts->timestamp, |
| 188 | nodeid, nodeid->k, (u8 *)alias, |
| 189 | opts->addresses, |
| 190 | tlvs); |
| 191 | sha256_double(&hash, nannounce + node_announcement_offset, |
| 192 | tal_count(nannounce) - node_announcement_offset); |
| 193 | sign_hash(privkey, &hash, &sig); |
| 194 | |
| 195 | printf("type=node_announcement\n"); |
| 196 | printf(" signature=%s\n", sig_notation(privkey, &hash, &sig)); |
| 197 | printf(" features=%s\n", tal_hex(NULL, NULL)); |
| 198 | printf(" timestamp=%u\n", opts->timestamp); |
| 199 | printf(" node_id=%s\n", node_id_to_hexstr(NULL, nodeid)); |
| 200 | printf(" rgb_color=%s\n", tal_hexstr(NULL, nodeid->k, 3)); |
| 201 | printf(" alias=%s\n", tal_hexstr(NULL, alias, 32)); |
| 202 | printf(" addresses=%s\n", tal_hex(NULL, opts->addresses)); |
| 203 | |
| 204 | if (tlvs->option_will_fund) { |
| 205 | struct lease_rates *rates = tlvs->option_will_fund; |
| 206 | printf(" TLV option_will_fund\n"); |
| 207 | printf(" lease_fee_basis=%d\n", |
| 208 | rates->lease_fee_basis); |
| 209 | printf(" lease_fee_base_sat=%d\n", |
| 210 | rates->lease_fee_base_sat); |
| 211 | printf(" funding_weight=%d\n", |
| 212 | rates->funding_weight); |
| 213 | printf(" channel_fee_max_proportional_thousandths=%d\n", |
| 214 | rates->channel_fee_max_proportional_thousandths); |
| 215 | printf(" channel_fee_max_base_msat=%d\n", |
| 216 | rates->channel_fee_max_base_msat); |
| 217 | } |
| 218 | tal_free(tlvs); |
| 219 | } |
| 220 | |
| 221 | int main(int argc, char *argv[]) |
| 222 | { |
no test coverage detected