Skip to content

Commit 679bb2a

Browse files
committed
Merge bitcoin/bitcoin#31958: rpc: add cli examples, update docs
32dcec2 rpc: update RPC help of `createpsbt` (rkrux) 931117a rpc: update the doc for `data` field in `outputs` argument (rkrux) 8134a6b rpc: add cli example for `walletcreatefundedpsbt` RPC (rkrux) Pull request description: ### add cli example for `walletcreatefundedpsbt` and `createpsbt` RPCs 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. ### rpc: update the doc for `data` field in `outputs` argument 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. This affects docs of the following RPCs: `bumpfee`, `psbtbumpfee`, `send`, `walletcreatefundedpsbt`, `createpsbt`, and `createrawtransaction` ACKs for top commit: sipa: utACK 32dcec2 1440000bytes: utACK bitcoin/bitcoin@32dcec2 achow101: ACK 32dcec2 ryanofsky: Concept ACK 32dcec2. These seem like helpful clarifications, but I did not look into the details Tree-SHA512: f994488ba7d52d00960fc52064bb419cf548e29822fe23d6ee0452fdf514dd93f089145eddb32b8086a7918cf8cf33a4c3f16bfcb7948f3c9d5afd95e8d3a1cb
2 parents dfa2813 + 32dcec2 commit 679bb2a

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

src/rpc/rawtransaction.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ static std::vector<RPCArg> CreateTxDoc()
150150
},
151151
{"", RPCArg::Type::OBJ, RPCArg::Optional::OMITTED, "",
152152
{
153-
{"data", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, "A key-value pair. The key must be \"data\", the value is hex-encoded data"},
153+
{"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"},
154154
},
155155
},
156156
},
@@ -1550,13 +1550,15 @@ static RPCHelpMan createpsbt()
15501550
{
15511551
return RPCHelpMan{"createpsbt",
15521552
"\nCreates a transaction in the Partially Signed Transaction format.\n"
1553-
"Implements the Creator role.\n",
1553+
"Implements the Creator role.\n"
1554+
"Note that the transaction's inputs are not signed, and\n"
1555+
"it is not stored in the wallet or transmitted to the network.\n",
15541556
CreateTxDoc(),
15551557
RPCResult{
15561558
RPCResult::Type::STR, "", "The resulting raw transaction (base64-encoded string)"
15571559
},
15581560
RPCExamples{
1559-
HelpExampleCli("createpsbt", "\"[{\\\"txid\\\":\\\"myid\\\",\\\"vout\\\":0}]\" \"[{\\\"data\\\":\\\"00010203\\\"}]\"")
1561+
HelpExampleCli("createpsbt", "\"[{\\\"txid\\\":\\\"myid\\\",\\\"vout\\\":0}]\" \"[{\\\"address\\\":0.01}]\"")
15601562
},
15611563
[&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
15621564
{

src/wallet/rpc/spend.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -983,7 +983,7 @@ static std::vector<RPCArg> OutputsDoc()
983983
},
984984
{"", RPCArg::Type::OBJ, RPCArg::Optional::OMITTED, "",
985985
{
986-
{"data", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, "A key-value pair. The key must be \"data\", the value is hex-encoded data"},
986+
{"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"},
987987
},
988988
},
989989
};
@@ -1734,8 +1734,10 @@ RPCHelpMan walletcreatefundedpsbt()
17341734
}
17351735
},
17361736
RPCExamples{
1737-
"\nCreate a transaction with no inputs\n"
1738-
+ HelpExampleCli("walletcreatefundedpsbt", "\"[{\\\"txid\\\":\\\"myid\\\",\\\"vout\\\":0}]\" \"[{\\\"data\\\":\\\"00010203\\\"}]\"")
1737+
"\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"
1738+
+ HelpExampleCli("walletcreatefundedpsbt", "\"[]\" \"[{\\\"" + EXAMPLE_ADDRESS[0] + "\\\":0.5}]\" 0 \"{\\\"add_inputs\\\":true,\\\"fee_rate\\\":2}\"")
1739+
+ "\nCreate the same PSBT as the above one instead using named arguments:\n"
1740+
+ HelpExampleCli("-named walletcreatefundedpsbt", "outputs=\"[{\\\"" + EXAMPLE_ADDRESS[0] + "\\\":0.5}]\" add_inputs=true fee_rate=2")
17391741
},
17401742
[&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
17411743
{

0 commit comments

Comments
 (0)