From 9c05471979082753c7dd047d8be7ec5f43bb6f44 Mon Sep 17 00:00:00 2001 From: Antioch Peverell <30642645+antiochp@users.noreply.github.com> Date: Fri, 10 Aug 2018 00:37:31 +0100 Subject: [PATCH] Validate resulting tx after aggregation (and deaggregation) (#1331) --- core/src/core/transaction.rs | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/core/src/core/transaction.rs b/core/src/core/transaction.rs index fafb77492..a4cc978cc 100644 --- a/core/src/core/transaction.rs +++ b/core/src/core/transaction.rs @@ -573,11 +573,18 @@ pub fn aggregate(transactions: Vec) -> Result { new_outputs.sort(); kernels.sort(); + // build a new aggregate tx from the following - + // * cut-through inputs + // * cut-through outputs + // * full set of tx kernels + // * sum of all kernel offsets let tx = Transaction::new(new_inputs, new_outputs, kernels).with_offset(total_kernel_offset); - // We need to check sums here as aggregation/cut-through - // may have created an invalid tx. - tx.verify_kernel_sums(tx.overage(), tx.offset)?; + // Now validate the aggregate tx to ensure we have not built something invalid. + // The resulting tx could be invalid for a variety of reasons - + // * tx too large (too many inputs|outputs|kernels) + // * cut-through may have invalidated the sums + tx.validate()?; Ok(tx) } @@ -641,8 +648,11 @@ pub fn deaggregate(mk_tx: Transaction, txs: Vec) -> Result