From 3e69939b78d0143d514c5d9b6c6a9844c9bb901c Mon Sep 17 00:00:00 2001 From: Andrew Chow Date: Mon, 30 Nov 2020 16:13:36 -0500 Subject: Fail if maximum weight is too large Our max weight check in CreateTransaction only worked if the transaction was fully signed. However if we are funding a transaction, it is possible that the tx weight will be too large for a standard tx. In that case, we should also fail. So we use the tx weight returned by CalculateMaximumSignedTxSize and check against the limit for those transactions. --- src/wallet/wallet.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/wallet/wallet.cpp') diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index 141842d921..3faa038df4 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -3068,7 +3068,8 @@ bool CWallet::CreateTransactionInternal( tx = MakeTransactionRef(std::move(txNew)); // Limit size - if (GetTransactionWeight(*tx) > MAX_STANDARD_TX_WEIGHT) + if ((sign && GetTransactionWeight(*tx) > MAX_STANDARD_TX_WEIGHT) || + (!sign && tx_sizes.second > MAX_STANDARD_TX_WEIGHT)) { error = _("Transaction too large"); return false; -- cgit v1.2.3