MCPcopy Create free account
hub / github.com/ElementsProject/elements / createrawtransaction

Function createrawtransaction

src/rpc/rawtransaction.cpp:460–499  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

458}
459
460static RPCHelpMan createrawtransaction()
461{
462 return RPCHelpMan{"createrawtransaction",
463 "\nCreate a transaction spending the given inputs and creating new outputs.\n"
464 "Outputs can be addresses or data.\n"
465 "Returns hex-encoded raw transaction.\n"
466 "Note that the transaction's inputs are not signed, and\n"
467 "it is not stored in the wallet or transmitted to the network.\n",
468 CreateTxDoc(),
469 RPCResult{
470 RPCResult::Type::STR_HEX, "transaction", "hex string of the transaction"
471 },
472 RPCExamples{
473 HelpExampleCli("createrawtransaction", "\"[{\\\"txid\\\":\\\"myid\\\",\\\"vout\\\":0}]\" \"[{\\\"address\\\":0.01}]\"")
474 + HelpExampleCli("createrawtransaction", "\"[{\\\"txid\\\":\\\"myid\\\",\\\"vout\\\":0}]\" \"[{\\\"data\\\":\\\"00010203\\\"}]\"")
475 + HelpExampleRpc("createrawtransaction", "\"[{\\\"txid\\\":\\\"myid\\\",\\\"vout\\\":0}]\", \"[{\\\"address\\\":0.01}]\"")
476 + HelpExampleRpc("createrawtransaction", "\"[{\\\"txid\\\":\\\"myid\\\",\\\"vout\\\":0}]\", \"[{\\\"data\\\":\\\"00010203\\\"}]\"")
477 },
478 [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
479{
480 ChainstateManager& chainman = EnsureAnyChainman(request.context);
481
482 RPCTypeCheck(request.params, {
483 UniValue::VARR,
484 UniValue::VARR,
485 UniValue::VNUM,
486 UniValue::VBOOL,
487 }, true
488 );
489
490 bool rbf = false;
491 if (!request.params[3].isNull()) {
492 rbf = request.params[3].isTrue();
493 }
494 CMutableTransaction rawTx = ConstructTransaction(request.params[0], request.params[1], request.params[2], rbf, chainman.ActiveChain().Tip());
495
496 return EncodeHexTx(CTransaction(rawTx));
497},
498 };
499}
500
501static RPCHelpMan decoderawtransaction()
502{

Callers

nothing calls this directly

Calls 10

CreateTxDocFunction · 0.85
HelpExampleCliFunction · 0.85
HelpExampleRpcFunction · 0.85
RPCTypeCheckFunction · 0.85
ConstructTransactionFunction · 0.85
EncodeHexTxFunction · 0.85
isTrueMethod · 0.80
CTransactionClass · 0.50
isNullMethod · 0.45
TipMethod · 0.45

Tested by

no test coverage detected