Panic on txn with value > 21mill in ChannelMonitor::block_connected
[rust-lightning] / fuzz / src / full_stack.rs
index 4d1bf5e0bcdedac3e2439b62d42dd3e0f0a89695..e29e24ca4660456dfe430ce81e698509b6d0ec25 100644 (file)
@@ -487,6 +487,12 @@ pub fn do_test(data: &[u8], logger: &Arc<dyn Logger>) {
                                } else {
                                        let txres: Result<Transaction, _> = deserialize(get_slice!(txlen));
                                        if let Ok(tx) = txres {
+                                               let mut output_val = 0;
+                                               for out in tx.output.iter() {
+                                                       if out.value > 21_000_000_0000_0000 { return; }
+                                                       output_val += out.value;
+                                                       if output_val > 21_000_000_0000_0000 { return; }
+                                               }
                                                loss_detector.connect_block(&[tx]);
                                        } else {
                                                return;