MCPcopy Create free account
hub / github.com/bitcoin/bitcoin / createpsbt

Function createpsbt

src/rpc/rawtransaction.cpp:1691–1736  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1689}
1690
1691static RPCMethod createpsbt()
1692{
1693 return RPCMethod{
1694 "createpsbt",
1695 "Creates a transaction in the Partially Signed Transaction format.\n"
1696 "Implements the Creator role.\n"
1697 "Note that the transaction's inputs are not signed, and\n"
1698 "it is not stored in the wallet or transmitted to the network.\n",
1699 Cat<std::vector<RPCArg>>(
1700 CreateTxDoc(),
1701 {
1702 {"psbt_version", RPCArg::Type::NUM, RPCArg::Default{2}, "The PSBT version number to use."},
1703 }
1704 ),
1705 RPCResult{
1706 RPCResult::Type::STR, "", "The resulting raw transaction (base64-encoded string)"
1707 },
1708 RPCExamples{
1709 HelpExampleCli("createpsbt", "\"[{\\\"txid\\\":\\\"myid\\\",\\\"vout\\\":0}]\" \"[{\\\"address\\\":0.01}]\"")
1710 },
1711 [](const RPCMethod& self, const JSONRPCRequest& request) -> UniValue
1712{
1713 std::optional<bool> rbf;
1714 if (!request.params[3].isNull()) {
1715 rbf = request.params[3].get_bool();
1716 }
1717 CMutableTransaction rawTx = ConstructTransaction(request.params[0], request.params[1], request.params[2], rbf, self.Arg<uint32_t>("version"));
1718
1719 // Make a blank psbt
1720 uint32_t psbt_version = 2;
1721 if (!request.params[5].isNull()) {
1722 psbt_version = request.params[5].getInt<uint32_t>();
1723 }
1724 if (psbt_version != 2 && psbt_version != 0) {
1725 throw JSONRPCError(RPC_INVALID_PARAMETER, "The PSBT version can only be 2 or 0");
1726 }
1727 PartiallySignedTransaction psbtx(rawTx, psbt_version);
1728
1729 // Serialize the PSBT
1730 DataStream ssTx{};
1731 ssTx << psbtx;
1732
1733 return EncodeBase64(ssTx);
1734},
1735 };
1736}
1737
1738static RPCMethod converttopsbt()
1739{

Callers

nothing calls this directly

Calls 7

CreateTxDocFunction · 0.85
HelpExampleCliFunction · 0.85
ConstructTransactionFunction · 0.85
JSONRPCErrorFunction · 0.85
isNullMethod · 0.80
get_boolMethod · 0.80
EncodeBase64Function · 0.50

Tested by

no test coverage detected