| 75 | } |
| 76 | |
| 77 | u8 *unsigned_channel_update(const tal_t *ctx, |
| 78 | const struct channel *channel, |
| 79 | struct short_channel_id scid, |
| 80 | const u32 *old_timestamp, |
| 81 | bool forwardable, |
| 82 | bool enabled) |
| 83 | { |
| 84 | struct lightningd *ld = channel->peer->ld; |
| 85 | secp256k1_ecdsa_signature dummy_sig; |
| 86 | u8 message_flags, channel_flags; |
| 87 | u32 timestamp; |
| 88 | |
| 89 | /* hsmd fills this in */ |
| 90 | memset(&dummy_sig, 0, sizeof(dummy_sig)); |
| 91 | /* BOLT #7: |
| 92 | * |
| 93 | * The `channel_flags` bitfield is used to indicate the direction of |
| 94 | * the channel: it identifies the node that this update originated |
| 95 | * from and signals various options concerning the channel. The |
| 96 | * following table specifies the meaning of its individual bits: |
| 97 | * |
| 98 | * | Bit Position | Name | Meaning | |
| 99 | * | ------------- | ----------- | -------------------------------- | |
| 100 | * | 0 | `direction` | Direction this update refers to. | |
| 101 | * | 1 | `disable` | Disable the channel. | |
| 102 | */ |
| 103 | channel_flags = node_id_idx(&channel->peer->ld->our_nodeid, |
| 104 | &channel->peer->id); |
| 105 | if (!enabled) |
| 106 | channel_flags |= ROUTING_FLAGS_DISABLED; |
| 107 | |
| 108 | /* BOLT #7: |
| 109 | * |
| 110 | * The `message_flags` bitfield is used to provide additional details |
| 111 | * about the message: |
| 112 | * |
| 113 | * | Bit Position | Name | |
| 114 | * | ------------- | ---------------| |
| 115 | * | 0 | `must_be_one` | |
| 116 | * | 1 | `dont_forward` | |
| 117 | */ |
| 118 | message_flags = 1; |
| 119 | if (!forwardable) |
| 120 | message_flags |= ROUTING_OPT_DONT_FORWARD; |
| 121 | |
| 122 | /* Make sure timestamp changes! */ |
| 123 | timestamp = clock_time().ts.tv_sec; |
| 124 | /* FIXME: @endothermicdev points out that our clock could be |
| 125 | * wrong once, and now we'll keep producing future timestamps. |
| 126 | * We could sanity check that old_timestamp is within 2 weeks and |
| 127 | * discard? */ |
| 128 | if (old_timestamp && timestamp <= *old_timestamp) |
| 129 | timestamp = *old_timestamp + 1; |
| 130 | |
| 131 | return towire_channel_update(ctx, |
| 132 | &dummy_sig, |
| 133 | &chainparams->genesis_blockhash, |
| 134 | scid, |
no test coverage detected