| 6499 | } |
| 6500 | |
| 6501 | static void handle_blockheight(struct peer *peer, const u8 *inmsg) |
| 6502 | { |
| 6503 | u32 blockheight; |
| 6504 | |
| 6505 | if (!fromwire_channeld_blockheight(inmsg, &blockheight)) |
| 6506 | master_badmsg(WIRE_CHANNELD_BLOCKHEIGHT, inmsg); |
| 6507 | |
| 6508 | /* Save it, so we know */ |
| 6509 | peer->our_blockheight = blockheight; |
| 6510 | if (peer->channel->opener == LOCAL) |
| 6511 | start_commit_timer(peer); |
| 6512 | else { |
| 6513 | u32 peer_height = get_blockheight(peer->channel->blockheight_states, |
| 6514 | peer->channel->opener, |
| 6515 | REMOTE); |
| 6516 | /* BOLT- #2: |
| 6517 | * The node _not responsible_ for initiating the channel: |
| 6518 | * ... |
| 6519 | * - if last received `blockheight` is > 1008 behind |
| 6520 | * currently known blockheight: |
| 6521 | * - SHOULD fail he channel |
| 6522 | */ |
| 6523 | assert(peer_height + 1008 > peer_height); |
| 6524 | if (peer_height + 1008 < blockheight) |
| 6525 | peer_failed_err(peer->pps, &peer->channel_id, |
| 6526 | "Peer is too far behind, terminating" |
| 6527 | " leased channel. Our current" |
| 6528 | " %u, theirs %u", |
| 6529 | blockheight, peer_height); |
| 6530 | /* We're behind them... what do. It's possible they're lying, |
| 6531 | * but if we're in a lease this is actually in our favor so |
| 6532 | * we log it but otherwise continue on unchanged */ |
| 6533 | if (peer_height > blockheight |
| 6534 | && peer_height > blockheight + 100) |
| 6535 | status_unusual("Peer reporting we've fallen %u" |
| 6536 | " blocks behind. Our height %u," |
| 6537 | " their height %u", |
| 6538 | peer_height - blockheight, |
| 6539 | blockheight, peer_height); |
| 6540 | |
| 6541 | } |
| 6542 | } |
| 6543 | |
| 6544 | static void handle_preimage(struct peer *peer, const u8 *inmsg) |
| 6545 | { |
no test coverage detected