@@ -397,7 +397,7 @@ void ParseRecipients(const UniValue& address_amounts, const UniValue& subtract_f
397
397
}
398
398
}
399
399
400
- UniValue SendMoney (CWallet* const pwallet, const CCoinControl &coin_control, std::vector<CRecipient> &recipients, mapValue_t map_value)
400
+ UniValue SendMoney (CWallet* const pwallet, const CCoinControl &coin_control, std::vector<CRecipient> &recipients, mapValue_t map_value, bool verbose )
401
401
{
402
402
EnsureWalletIsUnlocked (pwallet);
403
403
@@ -409,11 +409,18 @@ UniValue SendMoney(CWallet* const pwallet, const CCoinControl &coin_control, std
409
409
int nChangePosRet = -1 ;
410
410
bilingual_str error;
411
411
CTransactionRef tx;
412
- bool fCreated = pwallet->CreateTransaction (recipients, tx, nFeeRequired, nChangePosRet, error, coin_control, !pwallet->IsWalletFlagSet (WALLET_FLAG_DISABLE_PRIVATE_KEYS));
412
+ FeeCalculation fee_calc_out;
413
+ bool fCreated = pwallet->CreateTransaction (recipients, tx, nFeeRequired, nChangePosRet, error, coin_control, fee_calc_out, !pwallet->IsWalletFlagSet (WALLET_FLAG_DISABLE_PRIVATE_KEYS));
413
414
if (!fCreated ) {
414
415
throw JSONRPCError (RPC_WALLET_INSUFFICIENT_FUNDS, error.original );
415
416
}
416
417
pwallet->CommitTransaction (tx, std::move (map_value), {} /* orderForm */ );
418
+ if (verbose) {
419
+ UniValue entry (UniValue::VOBJ);
420
+ entry.pushKV (" txid" , tx->GetHash ().GetHex ());
421
+ entry.pushKV (" fee_reason" , StringForFeeReason (fee_calc_out.reason ));
422
+ return entry;
423
+ }
417
424
return tx->GetHash ().GetHex ();
418
425
}
419
426
@@ -438,9 +445,19 @@ static RPCHelpMan sendtoaddress()
438
445
" \" " + FeeModes (" \"\n\" " ) + " \" " },
439
446
{" avoid_reuse" , RPCArg::Type::BOOL, /* default */ " true" , " (only available if avoid_reuse wallet flag is set) Avoid spending from dirty addresses; addresses are considered\n "
440
447
" dirty if they have previously been used in a transaction." },
448
+ {" verbose" , RPCArg::Type::BOOL, /* default */ " false" , " If true, return extra information about the transaction." },
441
449
},
442
- RPCResult{
443
- RPCResult::Type::STR_HEX, " txid" , " The transaction id."
450
+ {
451
+ RPCResult{" if verbose is not set or set to false" ,
452
+ RPCResult::Type::STR_HEX, " txid" , " The transaction id."
453
+ },
454
+ RPCResult{" if verbose is set to true" ,
455
+ RPCResult::Type::OBJ, " " , " " ,
456
+ {
457
+ {RPCResult::Type::STR_HEX, " txid" , " The transaction id." },
458
+ {RPCResult::Type::STR, " fee reason" , " The transaction fee reason." }
459
+ },
460
+ },
444
461
},
445
462
RPCExamples{
446
463
HelpExampleCli (" sendtoaddress" , " \" " + EXAMPLE_ADDRESS[0 ] + " \" 0.1" )
@@ -497,8 +514,9 @@ static RPCHelpMan sendtoaddress()
497
514
498
515
std::vector<CRecipient> recipients;
499
516
ParseRecipients (address_amounts, subtractFeeFromAmount, recipients);
517
+ bool verbose = request.params [9 ].isNull () ? false : request.params [9 ].get_bool ();
500
518
501
- return SendMoney (pwallet, coin_control, recipients, mapValue);
519
+ return SendMoney (pwallet, coin_control, recipients, mapValue, verbose );
502
520
},
503
521
};
504
522
}
@@ -853,11 +871,22 @@ static RPCHelpMan sendmany()
853
871
{" conf_target" , RPCArg::Type::NUM, /* default */ " wallet default" , " Confirmation target (in blocks), or fee rate (for " + CURRENCY_UNIT + " /kB or " + CURRENCY_ATOM + " /B estimate modes)" },
854
872
{" estimate_mode" , RPCArg::Type::STR, /* default */ " unset" , std::string () + " The fee estimate mode, must be one of (case insensitive):\n "
855
873
" \" " + FeeModes (" \"\n\" " ) + " \" " },
874
+ {" verbose" , RPCArg::Type::BOOL, /* default */ " false" , " If true, return extra infomration about the transaction." },
875
+ },
876
+ {
877
+ RPCResult{" if verbose is not set or set to false" ,
878
+ RPCResult::Type::STR_HEX, " txid" , " The transaction id for the send. Only 1 transaction is created regardless of\n "
879
+ " the number of addresses."
880
+ },
881
+ RPCResult{" if verbose is set to true" ,
882
+ RPCResult::Type::OBJ, " " , " " ,
883
+ {
884
+ {RPCResult::Type::STR_HEX, " txid" , " The transaction id for the send. Only 1 transaction is created regardless of\n "
885
+ " the number of addresses." },
886
+ {RPCResult::Type::STR, " fee reason" , " The transaction fee reason." }
887
+ },
888
+ },
856
889
},
857
- RPCResult{
858
- RPCResult::Type::STR_HEX, " txid" , " The transaction id for the send. Only 1 transaction is created regardless of\n "
859
- " the number of addresses."
860
- },
861
890
RPCExamples{
862
891
" \n Send two amounts to two different addresses:\n "
863
892
+ HelpExampleCli (" sendmany" , " \"\" \" {\\\" " + EXAMPLE_ADDRESS[0 ] + " \\\" :0.01,\\\" " + EXAMPLE_ADDRESS[1 ] + " \\\" :0.02}\" " ) +
@@ -902,12 +931,14 @@ static RPCHelpMan sendmany()
902
931
903
932
std::vector<CRecipient> recipients;
904
933
ParseRecipients (sendTo, subtractFeeFromAmount, recipients);
934
+ bool verbose = request.params [8 ].isNull () ? false : request.params [8 ].get_bool ();
905
935
906
- return SendMoney (pwallet, coin_control, recipients, std::move (mapValue));
936
+ return SendMoney (pwallet, coin_control, recipients, std::move (mapValue), verbose );
907
937
},
908
938
};
909
939
}
910
940
941
+
911
942
static RPCHelpMan addmultisigaddress ()
912
943
{
913
944
return RPCHelpMan{" addmultisigaddress" ,
@@ -4501,8 +4532,8 @@ static const CRPCCommand commands[] =
4501
4532
{ " wallet" , " removeprunedfunds" , &removeprunedfunds, {" txid" } },
4502
4533
{ " wallet" , " rescanblockchain" , &rescanblockchain, {" start_height" , " stop_height" } },
4503
4534
{ " wallet" , " send" , &send, {" outputs" ," conf_target" ," estimate_mode" ," options" } },
4504
- { " wallet" , " sendmany" , &sendmany, {" dummy" ," amounts" ," minconf" ," comment" ," subtractfeefrom" ," replaceable" ," conf_target" ," estimate_mode" } },
4505
- { " wallet" , " sendtoaddress" , &sendtoaddress, {" address" ," amount" ," comment" ," comment_to" ," subtractfeefromamount" ," replaceable" ," conf_target" ," estimate_mode" ," avoid_reuse" } },
4535
+ { " wallet" , " sendmany" , &sendmany, {" dummy" ," amounts" ," minconf" ," comment" ," subtractfeefrom" ," replaceable" ," conf_target" ," estimate_mode" , " verbose " } },
4536
+ { " wallet" , " sendtoaddress" , &sendtoaddress, {" address" ," amount" ," comment" ," comment_to" ," subtractfeefromamount" ," replaceable" ," conf_target" ," estimate_mode" ," avoid_reuse" , " verbose " } },
4506
4537
{ " wallet" , " sethdseed" , &sethdseed, {" newkeypool" ," seed" } },
4507
4538
{ " wallet" , " setlabel" , &setlabel, {" address" ," label" } },
4508
4539
{ " wallet" , " settxfee" , &settxfee, {" amount" } },
0 commit comments