This is a refresh of a local channel (after 13 days). */
| 715 | |
| 716 | /* This is a refresh of a local channel (after 13 days). */ |
| 717 | void refresh_local_channel(struct daemon *daemon, |
| 718 | struct chan *chan, int direction) |
| 719 | { |
| 720 | u16 cltv_expiry_delta; |
| 721 | struct amount_msat htlc_minimum, htlc_maximum; |
| 722 | u32 fee_base_msat, fee_proportional_millionths, timestamp; |
| 723 | u8 *prev, *update; |
| 724 | u8 message_flags, channel_flags; |
| 725 | secp256k1_ecdsa_signature signature; |
| 726 | struct bitcoin_blkid chain_hash; |
| 727 | struct short_channel_id short_channel_id; |
| 728 | |
| 729 | /* If there's a pending update, apply it and we're done. */ |
| 730 | if (local_channel_update_latest(daemon, chan)) |
| 731 | return; |
| 732 | |
| 733 | prev = prev_update(tmpctx, daemon, chan, direction); |
| 734 | if (!prev) |
| 735 | return; |
| 736 | |
| 737 | if (!fromwire_channel_update(prev, |
| 738 | &signature, &chain_hash, |
| 739 | &short_channel_id, ×tamp, |
| 740 | &message_flags, &channel_flags, |
| 741 | &cltv_expiry_delta, |
| 742 | &htlc_minimum, |
| 743 | &fee_base_msat, |
| 744 | &fee_proportional_millionths, |
| 745 | &htlc_maximum)) { |
| 746 | status_broken("Could not decode local channel_update %s!", |
| 747 | tal_hex(tmpctx, prev)); |
| 748 | return; |
| 749 | } |
| 750 | |
| 751 | /* BOLT #7: |
| 752 | * |
| 753 | * The `channel_flags` bitfield is used to indicate the direction of |
| 754 | * the channel: it identifies the node that this update originated |
| 755 | * from and signals various options concerning the channel. The |
| 756 | * following table specifies the meaning of its individual bits: |
| 757 | * |
| 758 | * | Bit Position | Name | Meaning | |
| 759 | * | ------------- | ----------- | -------------------------------- | |
| 760 | * | 0 | `direction` | Direction this update refers to. | |
| 761 | * | 1 | `disable` | Disable the channel. | |
| 762 | */ |
| 763 | if (direction != (channel_flags & ROUTING_FLAGS_DIRECTION)) { |
| 764 | status_broken("Wrong channel direction %s!", |
| 765 | tal_hex(tmpctx, prev)); |
| 766 | return; |
| 767 | } |
| 768 | |
| 769 | /* Don't refresh disabled channels. */ |
| 770 | if (channel_flags & ROUTING_FLAGS_DISABLED) |
| 771 | return; |
| 772 | |
| 773 | update = create_unsigned_update(NULL, &short_channel_id, direction, |
| 774 | false, cltv_expiry_delta, |
no test coverage detected