From f522476cea06efe3b77d6389f170ed15f33a24a9 Mon Sep 17 00:00:00 2001 From: rkrux Date: Thu, 27 Feb 2025 17:35:34 +0530 Subject: [PATCH 1/2] rpc: add cli example for `walletcreatefundedpsbt` RPC The only example present earlier was one that creates an OP_RETURN output. This lack of examples has discouraged me earlier to use this RPC. Adding an example that creates PSBT sending bitcoin to address, a scenario that is much more common. Github-Pull: #31958 Rebased-From: 8134a6b5d40568dcf32fdb21163cb1792efddc27 --- src/wallet/rpc/spend.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/wallet/rpc/spend.cpp b/src/wallet/rpc/spend.cpp index 88ee6e96b0..cac4183055 100644 --- a/src/wallet/rpc/spend.cpp +++ b/src/wallet/rpc/spend.cpp @@ -1673,8 +1673,10 @@ RPCHelpMan walletcreatefundedpsbt() } }, RPCExamples{ - "\nCreate a transaction with no inputs\n" - + HelpExampleCli("walletcreatefundedpsbt", "\"[{\\\"txid\\\":\\\"myid\\\",\\\"vout\\\":0}]\" \"[{\\\"data\\\":\\\"00010203\\\"}]\"") + "\nCreate a PSBT with automatically picked inputs that sends 0.5 BTC to an address and has a fee rate of 2 sat/vB:\n" + + HelpExampleCli("walletcreatefundedpsbt", "\"[]\" \"[{\\\"" + EXAMPLE_ADDRESS[0] + "\\\":0.5}]\" 0 \"{\\\"add_inputs\\\":true,\\\"fee_rate\\\":2}\"") + + "\nCreate the same PSBT as the above one instead using named arguments:\n" + + HelpExampleCli("-named walletcreatefundedpsbt", "outputs=\"[{\\\"" + EXAMPLE_ADDRESS[0] + "\\\":0.5}]\" add_inputs=true fee_rate=2") }, [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue { From 9b8ff735a96ca4cd36368100e9b6935332a8e14d Mon Sep 17 00:00:00 2001 From: rkrux Date: Thu, 27 Feb 2025 17:42:28 +0530 Subject: [PATCH 2/2] rpc: update the doc for `data` field in `outputs` argument This affects docs of the following RPCs: `bumpfee`, `psbtbumpfee`, `send`, `walletcreatefundedpsbt` It was not evident to me that this field creates an `OP_RETURN` output until I read the code and tried it out. Thus, making the doc explicitly mention it. Github-Pull: #31958 Rebased-From: 0ad066c85a46208041f816d4edba36e8712763e9 --- src/wallet/rpc/spend.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wallet/rpc/spend.cpp b/src/wallet/rpc/spend.cpp index cac4183055..93e00d43fd 100644 --- a/src/wallet/rpc/spend.cpp +++ b/src/wallet/rpc/spend.cpp @@ -970,7 +970,7 @@ static std::vector OutputsDoc() }, {"", RPCArg::Type::OBJ, RPCArg::Optional::OMITTED, "", { - {"data", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, "A key-value pair. The key must be \"data\", the value is hex-encoded data"}, + {"data", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, "A key-value pair. The key must be \"data\", the value is hex-encoded data that becomes a part of an OP_RETURN output"}, }, }, };