| 50 | } |
| 51 | |
| 52 | void run(const uint8_t *data, size_t size) |
| 53 | { |
| 54 | struct channel_id cid; |
| 55 | struct bitcoin_outpoint funding; |
| 56 | u32 minimum_depth; |
| 57 | struct amount_sat funding_sats, max; |
| 58 | struct amount_msat local_msatoshi; |
| 59 | u32 feerate_per_kw, blockheight, lease_expiry; |
| 60 | struct channel_config local, remote; |
| 61 | struct basepoints local_basepoints, remote_basepoints; |
| 62 | struct pubkey local_funding_pubkey, remote_funding_pubkey; |
| 63 | bool option_anchor_outputs, wumbo; |
| 64 | struct channel_type *channel_type; |
| 65 | struct channel *channel; |
| 66 | |
| 67 | fromwire_channel_id(&data, &size, &cid); |
| 68 | fromwire_bitcoin_outpoint(&data, &size, &funding); |
| 69 | minimum_depth = fromwire_u32(&data, &size); |
| 70 | funding_sats = fromwire_amount_sat(&data, &size); |
| 71 | local_msatoshi = fromwire_amount_msat(&data, &size); |
| 72 | max = AMOUNT_SAT(MAX_SATS); |
| 73 | if (amount_sat_greater(funding_sats, max)) |
| 74 | funding_sats = max; |
| 75 | feerate_per_kw = fromwire_u32(&data, &size); |
| 76 | blockheight = fromwire_u32(&data, &size); |
| 77 | lease_expiry = fromwire_u32(&data, &size); |
| 78 | fromwire_channel_config(&data, &size, &local); |
| 79 | fromwire_channel_config(&data, &size, &remote); |
| 80 | fromwire_basepoints(&data, &size, &local_basepoints); |
| 81 | fromwire_basepoints(&data, &size, &remote_basepoints); |
| 82 | fromwire_pubkey(&data, &size, &local_funding_pubkey); |
| 83 | fromwire_pubkey(&data, &size, &remote_funding_pubkey); |
| 84 | wumbo = fromwire_bool(&data, &size); |
| 85 | option_anchor_outputs = fromwire_bool(&data, &size); |
| 86 | |
| 87 | if (option_anchor_outputs) |
| 88 | channel_type = channel_type_anchors_zero_fee_htlc(tmpctx); |
| 89 | else |
| 90 | channel_type = channel_type_static_remotekey(tmpctx); |
| 91 | |
| 92 | /* TODO: determine if it makes sense to check at each step for libfuzzer |
| 93 | * to deduce pertinent inputs */ |
| 94 | if (!data || !size) { |
| 95 | clean_tmpctx(); |
| 96 | return; |
| 97 | } |
| 98 | |
| 99 | for (enum side opener = 0; opener < NUM_SIDES; opener++) { |
| 100 | channel = new_initial_channel(tmpctx, &cid, &funding, |
| 101 | minimum_depth, |
| 102 | take(new_height_states(NULL, opener, |
| 103 | &blockheight)), |
| 104 | lease_expiry, |
| 105 | funding_sats, local_msatoshi, |
| 106 | take(new_fee_states(NULL, opener, |
| 107 | &feerate_per_kw)), |
| 108 | &local, &remote, |
| 109 | &local_basepoints, |
nothing calls this directly
no test coverage detected