|
18 | 18 | #include <key_io.h> |
19 | 19 | #include <policy/policy.h> |
20 | 20 | #include <primitives/transaction.h> |
| 21 | +#include <rpc/util.h> |
21 | 22 | #include <script/script.h> |
22 | 23 | #include <script/sign.h> |
23 | 24 | #include <script/signingprovider.h> |
@@ -550,18 +551,6 @@ static bool findSighashFlags(int& flags, const std::string& flagStr) |
550 | 551 | return false; |
551 | 552 | } |
552 | 553 |
|
553 | | -static CAmount AmountFromValue(const UniValue& value) |
554 | | -{ |
555 | | - if (!value.isNum() && !value.isStr()) |
556 | | - throw std::runtime_error("Amount is not a number or string"); |
557 | | - CAmount amount; |
558 | | - if (!ParseFixedPoint(value.getValStr(), 8, &amount)) |
559 | | - throw std::runtime_error("Invalid amount"); |
560 | | - if (!MoneyRange(amount)) |
561 | | - throw std::runtime_error("Amount out of range"); |
562 | | - return amount; |
563 | | -} |
564 | | - |
565 | 554 | static std::vector<unsigned char> ParseHexUV(const UniValue& v, const std::string& strName) |
566 | 555 | { |
567 | 556 | std::string strHex; |
@@ -645,7 +634,11 @@ static void MutateTxSign(CMutableTransaction& tx, const std::string& flagStr) |
645 | 634 | newcoin.out.scriptPubKey = scriptPubKey; |
646 | 635 | newcoin.out.nValue = MAX_MONEY; |
647 | 636 | if (prevOut.exists("amount")) { |
648 | | - newcoin.out.nValue = AmountFromValue(prevOut["amount"]); |
| 637 | + try { |
| 638 | + newcoin.out.nValue = AmountFromValue(prevOut["amount"]); |
| 639 | + } catch (const UniValue& error) { |
| 640 | + throw std::runtime_error(error.find_value("message").get_str()); |
| 641 | + } |
649 | 642 | } |
650 | 643 | newcoin.nHeight = 1; |
651 | 644 | view.AddCoin(out, std::move(newcoin), true); |
|
0 commit comments