| 30 | } |
| 31 | |
| 32 | void run(const uint8_t *data, size_t size) |
| 33 | { |
| 34 | struct channel_id cid; |
| 35 | struct bitcoin_outpoint funding; |
| 36 | u32 minimum_depth; |
| 37 | struct amount_sat funding_sats, max; |
| 38 | struct amount_msat local_msatoshi; |
| 39 | u32 feerate_per_kw, blockheight, lease_expiry; |
| 40 | struct channel_config local, remote; |
| 41 | struct basepoints local_basepoints, remote_basepoints; |
| 42 | struct pubkey local_funding_pubkey, remote_funding_pubkey; |
| 43 | bool option_static_remotekey, option_anchor_outputs, wumbo; |
| 44 | struct channel_type *channel_type; |
| 45 | struct channel *channel; |
| 46 | |
| 47 | fromwire_channel_id(&data, &size, &cid); |
| 48 | fromwire_bitcoin_outpoint(&data, &size, &funding); |
| 49 | minimum_depth = fromwire_u32(&data, &size); |
| 50 | funding_sats = fromwire_amount_sat(&data, &size); |
| 51 | local_msatoshi = fromwire_amount_msat(&data, &size); |
| 52 | max = AMOUNT_SAT((u32)WALLY_SATOSHI_PER_BTC * WALLY_BTC_MAX); |
| 53 | if (amount_sat_greater(funding_sats, max)) |
| 54 | funding_sats = max; |
| 55 | feerate_per_kw = fromwire_u32(&data, &size); |
| 56 | blockheight = fromwire_u32(&data, &size); |
| 57 | lease_expiry = fromwire_u32(&data, &size); |
| 58 | fromwire_channel_config(&data, &size, &local); |
| 59 | fromwire_channel_config(&data, &size, &remote); |
| 60 | fromwire_basepoints(&data, &size, &local_basepoints); |
| 61 | fromwire_basepoints(&data, &size, &remote_basepoints); |
| 62 | fromwire_pubkey(&data, &size, &local_funding_pubkey); |
| 63 | fromwire_pubkey(&data, &size, &remote_funding_pubkey); |
| 64 | wumbo = fromwire_bool(&data, &size); |
| 65 | option_anchor_outputs = fromwire_bool(&data, &size); |
| 66 | option_static_remotekey = option_anchor_outputs || fromwire_bool(&data, &size); |
| 67 | |
| 68 | if (option_anchor_outputs) |
| 69 | channel_type = channel_type_anchor_outputs(tmpctx); |
| 70 | else if (option_static_remotekey) |
| 71 | channel_type = channel_type_static_remotekey(tmpctx); |
| 72 | else |
| 73 | channel_type = channel_type_none(tmpctx); |
| 74 | |
| 75 | /* TODO: determine if it makes sense to check at each step for libfuzzer |
| 76 | * to deduce pertinent inputs */ |
| 77 | if (!data || !size) |
| 78 | return; |
| 79 | |
| 80 | for (enum side opener = 0; opener < NUM_SIDES; opener++) { |
| 81 | channel = new_initial_channel(tmpctx, &cid, &funding, |
| 82 | minimum_depth, |
| 83 | take(new_height_states(NULL, opener, |
| 84 | &blockheight)), |
| 85 | lease_expiry, |
| 86 | funding_sats, local_msatoshi, |
| 87 | take(new_fee_states(NULL, opener, |
| 88 | &feerate_per_kw)), |
| 89 | &local, &remote, |
nothing calls this directly
no test coverage detected