BOLT #7: * 1. type: 258 (`channel_update`) * 2. data: * * [`signature`:`signature`] * * [`chain_hash`:`chain_hash`] * * [`short_channel_id`:`short_channel_id`] * * [`u32`:`timestamp`] * * [`byte`:`message_flags`] * * [`byte`:`channel_flags`] * * [`u16`:`cltv_expiry_delta`] * * [`u64`:`htlc_minimum_msat`] * * [`u32`:`fee_base_msat`] * * [`u32`:`fe
| 381 | * * [`u64`:`htlc_maximum_msat`] |
| 382 | */ |
| 383 | static void write_update(int outfd, |
| 384 | size_t node1, |
| 385 | size_t node2, |
| 386 | size_t i, |
| 387 | int dir, |
| 388 | bool disabled, |
| 389 | u64 htlc_min, u64 htlc_max, |
| 390 | u64 basefee, |
| 391 | u32 propfee, |
| 392 | u16 delay, |
| 393 | const struct pubkey **node_ids) |
| 394 | { |
| 395 | struct vals { |
| 396 | secp256k1_ecdsa_signature sig; |
| 397 | struct bitcoin_blkid chain_hash; |
| 398 | u32 timestamp; |
| 399 | } vals; |
| 400 | u8 *msg; |
| 401 | u8 message_flags, channel_flags; |
| 402 | struct pubkey id1, id2; |
| 403 | struct short_channel_id scid; |
| 404 | |
| 405 | memset(&vals, 0, sizeof(vals)); |
| 406 | |
| 407 | /* Use i to avoid clashing scids even if two nodes have > 1 channel */ |
| 408 | if (!mk_short_channel_id(&scid, i + node1, node2, i & 0xFFFF)) |
| 409 | abort(); |
| 410 | |
| 411 | /* If node ids are backward, dir is reversed */ |
| 412 | pubkey_for_node(node1, &id1, node_ids); |
| 413 | pubkey_for_node(node2, &id2, node_ids); |
| 414 | if (pubkey_cmp(&id1, &id2) > 0) |
| 415 | dir = !dir; |
| 416 | |
| 417 | /* BOLT #7: |
| 418 | * The `channel_flags` bitfield is used to indicate the direction of |
| 419 | * the channel: it identifies the node that this update originated |
| 420 | * from and signals various options concerning the channel. The |
| 421 | * following table specifies the meaning of its individual bits: |
| 422 | * |
| 423 | * | Bit Position | Name | Meaning | |
| 424 | * | ------------- | ----------- | -------------------------------- | |
| 425 | * | 0 | `direction` | Direction this update refers to. | |
| 426 | * | 1 | `disable` | Disable the channel. | |
| 427 | * |
| 428 | * The `message_flags` bitfield is used to provide additional details about the message: |
| 429 | * |
| 430 | * | Bit Position | Name | |
| 431 | * | ------------- | ---------------| |
| 432 | * | 0 | `must_be_one` | |
| 433 | * | 1 | `dont_forward` | |
| 434 | */ |
| 435 | channel_flags = dir ? 1 : 0; |
| 436 | if (disabled) |
| 437 | channel_flags |= 2; |
| 438 | message_flags = 1; |
| 439 | msg = towire_channel_update(NULL, &vals.sig, &vals.chain_hash, scid, |
| 440 | 0, message_flags, channel_flags, |
no test coverage detected