| 874 | } |
| 875 | |
| 876 | bool routing_add_channel_announcement(struct routing_state *rstate, |
| 877 | const u8 *msg TAKES, |
| 878 | struct amount_sat sat, |
| 879 | u32 index, |
| 880 | struct peer *peer) |
| 881 | { |
| 882 | struct chan *oldchan; |
| 883 | secp256k1_ecdsa_signature node_signature_1, node_signature_2; |
| 884 | secp256k1_ecdsa_signature bitcoin_signature_1, bitcoin_signature_2; |
| 885 | u8 *features; |
| 886 | struct bitcoin_blkid chain_hash; |
| 887 | struct short_channel_id scid; |
| 888 | struct node_id node_id_1; |
| 889 | struct node_id node_id_2; |
| 890 | struct pubkey bitcoin_key_1; |
| 891 | struct pubkey bitcoin_key_2; |
| 892 | struct unupdated_channel *uc; |
| 893 | const u8 *private_updates[2] = { NULL, NULL }; |
| 894 | |
| 895 | /* Make sure we own msg, even if we don't save it. */ |
| 896 | if (taken(msg)) |
| 897 | tal_steal(tmpctx, msg); |
| 898 | |
| 899 | if (!fromwire_channel_announcement( |
| 900 | tmpctx, msg, &node_signature_1, &node_signature_2, |
| 901 | &bitcoin_signature_1, &bitcoin_signature_2, &features, &chain_hash, |
| 902 | &scid, &node_id_1, &node_id_2, &bitcoin_key_1, &bitcoin_key_2)) |
| 903 | return false; |
| 904 | |
| 905 | /* The channel may already exist if it was non-public from |
| 906 | * local_add_channel(); normally we don't accept new |
| 907 | * channel_announcements. See handle_channel_announcement. */ |
| 908 | oldchan = get_channel(rstate, &scid); |
| 909 | |
| 910 | /* private updates will exist in the store before the announce: we |
| 911 | * can't index those for broadcast since they would predate it, so we |
| 912 | * add fresh ones. */ |
| 913 | if (oldchan) { |
| 914 | /* If this was in the gossip_store, gossip_store is bad! */ |
| 915 | if (index) { |
| 916 | status_broken("gossip_store channel_announce" |
| 917 | " %u replaces %u!", |
| 918 | index, oldchan->bcast.index); |
| 919 | return false; |
| 920 | } |
| 921 | |
| 922 | /* Reload any private updates */ |
| 923 | if (oldchan->half[0].bcast.index) |
| 924 | private_updates[0] |
| 925 | = gossip_store_get_private_update(NULL, |
| 926 | rstate->gs, |
| 927 | oldchan->half[0].bcast.index); |
| 928 | if (oldchan->half[1].bcast.index) |
| 929 | private_updates[1] |
| 930 | = gossip_store_get_private_update(NULL, |
| 931 | rstate->gs, |
| 932 | oldchan->half[1].bcast.index); |
| 933 |
no test coverage detected