| 1639 | } |
| 1640 | |
| 1641 | bool routing_add_node_announcement(struct routing_state *rstate, |
| 1642 | const u8 *msg TAKES, |
| 1643 | u32 index, |
| 1644 | struct peer *peer, |
| 1645 | bool *was_unknown, |
| 1646 | bool force_spam_flag) |
| 1647 | { |
| 1648 | struct node *node; |
| 1649 | secp256k1_ecdsa_signature signature; |
| 1650 | u32 timestamp; |
| 1651 | struct node_id node_id; |
| 1652 | u8 rgb_color[3]; |
| 1653 | u8 alias[32]; |
| 1654 | u8 *features, *addresses; |
| 1655 | struct tlv_node_ann_tlvs *na_tlv; |
| 1656 | bool spam; |
| 1657 | |
| 1658 | if (was_unknown) |
| 1659 | *was_unknown = false; |
| 1660 | |
| 1661 | /* Make sure we own msg, even if we don't save it. */ |
| 1662 | if (taken(msg)) |
| 1663 | tal_steal(tmpctx, msg); |
| 1664 | |
| 1665 | /* Note: validity of node_id is already checked. */ |
| 1666 | if (!fromwire_node_announcement(tmpctx, msg, |
| 1667 | &signature, &features, ×tamp, |
| 1668 | &node_id, rgb_color, alias, |
| 1669 | &addresses, |
| 1670 | &na_tlv)) { |
| 1671 | return false; |
| 1672 | } |
| 1673 | |
| 1674 | node = get_node(rstate, &node_id); |
| 1675 | |
| 1676 | if (node == NULL || !node_has_broadcastable_channels(node)) { |
| 1677 | struct pending_node_announce *pna; |
| 1678 | /* BOLT #7: |
| 1679 | * |
| 1680 | * - if `node_id` is NOT previously known from a |
| 1681 | * `channel_announcement` message, OR if `timestamp` is NOT |
| 1682 | * greater than the last-received `node_announcement` from |
| 1683 | * this `node_id`: |
| 1684 | * - SHOULD ignore the message. |
| 1685 | */ |
| 1686 | /* Check if we are currently verifying the txout for a |
| 1687 | * matching channel */ |
| 1688 | pna = pending_node_map_get(rstate->pending_node_map, |
| 1689 | &node_id); |
| 1690 | if (!pna) { |
| 1691 | if (was_unknown) |
| 1692 | *was_unknown = true; |
| 1693 | bad_gossip_order(msg, peer, |
| 1694 | type_to_string(tmpctx, struct node_id, |
| 1695 | &node_id)); |
| 1696 | return false; |
| 1697 | } else if (timestamp <= pna->timestamp) |
| 1698 | /* Ignore old ones: they're OK (unless from store). */ |
no test coverage detected