From 6be014587f1c147014102e8c385f9a86126aeb8c Mon Sep 17 00:00:00 2001 From: satyakoneru <15652887+satyakoneru@users.noreply.github.com> Date: Fri, 17 Apr 2020 14:15:52 +0000 Subject: [PATCH] Add proper checks for withdraw fee --- .../peerplays_sidechain/sidechain_net_handler_bitcoin.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libraries/plugins/peerplays_sidechain/sidechain_net_handler_bitcoin.cpp b/libraries/plugins/peerplays_sidechain/sidechain_net_handler_bitcoin.cpp index 0f5f613d..53e26f8d 100644 --- a/libraries/plugins/peerplays_sidechain/sidechain_net_handler_bitcoin.cpp +++ b/libraries/plugins/peerplays_sidechain/sidechain_net_handler_bitcoin.cpp @@ -1391,7 +1391,7 @@ std::string sidechain_net_handler_bitcoin::create_withdrawal_transaction(const s total_amount += utx.amount_; } - if (fee_rate > total_amount) { + if ((swwo.withdraw_amount.value > total_amount) || (fee_rate >= swwo.withdraw_amount.value)) { elog("Failed not enough BTC to spend for ${pw}", ("pw", pw_address)); return ""; } @@ -1399,7 +1399,7 @@ std::string sidechain_net_handler_bitcoin::create_withdrawal_transaction(const s fc::flat_map outputs; outputs[swwo.withdraw_address] = (swwo.withdraw_amount.value - fee_rate) / 100000000.0; - if ((total_amount - fee_rate) > 0.0) { + if ((total_amount - swwo.withdraw_amount.value) > 0.0) { outputs[pw_address] = double(total_amount - swwo.withdraw_amount.value) / 100000000.0; }