+ // (very) manually create a funding transaction
+ const witness_pos = events[0].output_script.length + 58;
+ const funding_tx = new Uint8Array(witness_pos + 7);
+ funding_tx[0] = 2; // 4-byte tx version 2
+ funding_tx[4] = 0; funding_tx[5] = 1; // segwit magic bytes
+ funding_tx[6] = 1; // 1-byte input count 1
+ // 36 bytes previous outpoint all-0s
+ funding_tx[43] = 0; // 1-byte input script length 0
+ funding_tx[44] = 0xff; funding_tx[45] = 0xff; funding_tx[46] = 0xff; funding_tx[47] = 0xff; // 4-byte nSequence
+ funding_tx[48] = 1; // one output
+ assign_u64(funding_tx, 49, events[0].channel_value_satoshis);
+ funding_tx[57] = events[0].output_script.length; // 1-byte output script length
+ funding_tx.set(events[0].output_script, 58);
+ funding_tx[witness_pos] = 1; funding_tx[witness_pos + 1] = 1; funding_tx[witness_pos + 2] = 0xff; // one witness element of size 1 with contents 0xff
+ funding_tx[witness_pos + 3] = 0; funding_tx[witness_pos + 4] = 0; funding_tx[witness_pos + 5] = 0; funding_tx[witness_pos + 6] = 0; // lock time 0
+
+ const funding_res = chan_man_a.funding_transaction_generated(events[0].temporary_channel_id, funding_tx);
+ if (!(funding_res instanceof ldk.Result_NoneAPIErrorZ_OK)) return false;
+
+ if (!exchange_messages(chan_man_a, chan_man_b)) return false;
+
+ const tx_broadcasted: Uint8Array = (await peer_a[1]) as Uint8Array;
+ if (!array_eq(tx_broadcasted, funding_tx)) return false;
+