1616#include < key_io.h>
1717#include < policy/mempool.h>
1818#include < policy/policy.h>
19- #include < primitives/block.h>
2019#include < primitives/transaction.h>
2120#include < random.h>
2221#include < script/descriptor.h>
@@ -2736,7 +2735,7 @@ bool CWallet::SignTransaction(CMutableTransaction &tx) {
27362735}
27372736
27382737bool CWallet::FundTransaction (CMutableTransaction &tx, Amount &nFeeRet,
2739- int &nChangePosInOut, std::string &strFailReason ,
2738+ int &nChangePosInOut, bilingual_str &error ,
27402739 bool lockUnspents,
27412740 const std::set<int > &setSubtractFeeFromOutputs,
27422741 CCoinControl coinControl) {
@@ -2763,8 +2762,7 @@ bool CWallet::FundTransaction(CMutableTransaction &tx, Amount &nFeeRet,
27632762
27642763 CTransactionRef tx_new;
27652764 if (!CreateTransaction (*locked_chain, vecSend, tx_new, nFeeRet,
2766- nChangePosInOut, strFailReason, coinControl,
2767- false )) {
2765+ nChangePosInOut, error, coinControl, false )) {
27682766 return false ;
27692767 }
27702768
@@ -2879,8 +2877,7 @@ CWallet::TransactionChangeType(OutputType change_type,
28792877bool CWallet::CreateTransaction (interfaces::Chain::Lock &locked_chainIn,
28802878 const std::vector<CRecipient> &vecSend,
28812879 CTransactionRef &tx, Amount &nFeeRet,
2882- int &nChangePosInOut,
2883- std::string &strFailReason,
2880+ int &nChangePosInOut, bilingual_str &error,
28842881 const CCoinControl &coinControl, bool sign) {
28852882 Amount nValue = Amount::zero ();
28862883 const OutputType change_type = TransactionChangeType (
@@ -2892,8 +2889,7 @@ bool CWallet::CreateTransaction(interfaces::Chain::Lock &locked_chainIn,
28922889 unsigned int nSubtractFeeFromAmount = 0 ;
28932890 for (const auto &recipient : vecSend) {
28942891 if (nValue < Amount::zero () || recipient.nAmount < Amount::zero ()) {
2895- strFailReason =
2896- _ (" Transaction amounts must not be negative" ).translated ;
2892+ error = _ (" Transaction amounts must not be negative" );
28972893 return false ;
28982894 }
28992895
@@ -2905,8 +2901,7 @@ bool CWallet::CreateTransaction(interfaces::Chain::Lock &locked_chainIn,
29052901 }
29062902
29072903 if (vecSend.empty ()) {
2908- strFailReason =
2909- _ (" Transaction must have at least one recipient" ).translated ;
2904+ error = _ (" Transaction must have at least one recipient" );
29102905 return false ;
29112906 }
29122907
@@ -2946,18 +2941,14 @@ bool CWallet::CreateTransaction(interfaces::Chain::Lock &locked_chainIn,
29462941
29472942 // Reserve a new key pair from key pool
29482943 if (!CanGetAddresses (true )) {
2949- strFailReason =
2950- _ (" Can't generate a change-address key. No keys in the "
2951- " internal keypool and can't generate any keys." )
2952- .translated ;
2944+ error = _ (" Can't generate a change-address key. No keys in the "
2945+ " internal keypool and can't generate any keys." );
29532946 return false ;
29542947 }
29552948 CTxDestination dest;
29562949 bool ret = reservedest.GetReservedDestination (dest, true );
29572950 if (!ret) {
2958- strFailReason =
2959- _ (" Keypool ran out, please call keypoolrefill first" )
2960- .translated ;
2951+ error = _ (" Keypool ran out, please call keypoolrefill first" );
29612952 return false ;
29622953 }
29632954
@@ -3027,18 +3018,14 @@ bool CWallet::CreateTransaction(interfaces::Chain::Lock &locked_chainIn,
30273018 if (recipient.fSubtractFeeFromAmount &&
30283019 nFeeRet > Amount::zero ()) {
30293020 if (txout.nValue < Amount::zero ()) {
3030- strFailReason = _ (" The transaction amount is too "
3031- " small to pay the fee" )
3032- .translated ;
3021+ error = _ (" The transaction amount is too small to "
3022+ " pay the fee" );
30333023 } else {
3034- strFailReason =
3035- _ (" The transaction amount is too small to "
3036- " send after the fee has been deducted" )
3037- .translated ;
3024+ error = _ (" The transaction amount is too small to "
3025+ " send after the fee has been deducted" );
30383026 }
30393027 } else {
3040- strFailReason =
3041- _ (" Transaction amount too small" ).translated ;
3028+ error = _ (" Transaction amount too small" );
30423029 }
30433030
30443031 return false ;
@@ -3065,7 +3052,7 @@ bool CWallet::CreateTransaction(interfaces::Chain::Lock &locked_chainIn,
30653052 coin_selection_params.use_bnb = false ;
30663053 continue ;
30673054 } else {
3068- strFailReason = _ (" Insufficient funds" ). translated ;
3055+ error = _ (" Insufficient funds" );
30693056 return false ;
30703057 }
30713058 }
@@ -3090,8 +3077,7 @@ bool CWallet::CreateTransaction(interfaces::Chain::Lock &locked_chainIn,
30903077 nChangePosInOut = GetRandInt (txNew.vout .size () + 1 );
30913078 } else if ((unsigned int )nChangePosInOut >
30923079 txNew.vout .size ()) {
3093- strFailReason =
3094- _ (" Change index out of range" ).translated ;
3080+ error = _ (" Change index out of range" );
30953081 return false ;
30963082 }
30973083
@@ -3113,7 +3099,7 @@ bool CWallet::CreateTransaction(interfaces::Chain::Lock &locked_chainIn,
31133099 int nBytes = CalculateMaximumSignedTxSize (
31143100 txNewConst, this , coinControl.fAllowWatchOnly );
31153101 if (nBytes < 0 ) {
3116- strFailReason = _ (" Signing transaction failed" ). translated ;
3102+ error = _ (" Signing transaction failed" );
31173103 return false ;
31183104 }
31193105
@@ -3165,9 +3151,7 @@ bool CWallet::CreateTransaction(interfaces::Chain::Lock &locked_chainIn,
31653151 // to pay for the new output and still meet nFeeNeeded.
31663152 // Or we should have just subtracted fee from recipients and
31673153 // nFeeNeeded should not have changed.
3168- strFailReason =
3169- _ (" Transaction fee and change calculation failed" )
3170- .translated ;
3154+ error = _ (" Transaction fee and change calculation failed" );
31713155 return false ;
31723156 }
31733157
@@ -3230,7 +3214,7 @@ bool CWallet::CreateTransaction(interfaces::Chain::Lock &locked_chainIn,
32303214 MutableTransactionSignatureCreator (
32313215 &txNew, nIn, coin.txout .nValue , sigHashType),
32323216 scriptPubKey, sigdata)) {
3233- strFailReason = _ (" Signing transaction failed" ). translated ;
3217+ error = _ (" Signing transaction failed" );
32343218 return false ;
32353219 }
32363220
@@ -3244,23 +3228,22 @@ bool CWallet::CreateTransaction(interfaces::Chain::Lock &locked_chainIn,
32443228
32453229 // Limit size.
32463230 if (tx->GetTotalSize () > MAX_STANDARD_TX_SIZE) {
3247- strFailReason = _ (" Transaction too large" ). translated ;
3231+ error = _ (" Transaction too large" );
32483232 return false ;
32493233 }
32503234 }
32513235
32523236 if (nFeeRet > m_default_max_tx_fee) {
3253- strFailReason =
3254- TransactionErrorString (TransactionError::MAX_FEE_EXCEEDED);
3237+ error = Untranslated (
3238+ TransactionErrorString (TransactionError::MAX_FEE_EXCEEDED)) ;
32553239 return false ;
32563240 }
32573241
32583242 if (gArgs .GetBoolArg (" -walletrejectlongchains" ,
32593243 DEFAULT_WALLET_REJECT_LONG_CHAINS)) {
32603244 // Lastly, ensure this tx will pass the mempool's chain limits
32613245 if (!chain ().checkChainLimits (tx)) {
3262- strFailReason =
3263- _ (" Transaction has too long of a mempool chain" ).translated ;
3246+ error = _ (" Transaction has too long of a mempool chain" );
32643247 return false ;
32653248 }
32663249 }
0 commit comments