[#wallet-CreateTransaction] = xref:wallet.adoc[wallet]::CreateTransaction :relfileprefix: ../ :mrdocs: Create a new transaction paying the recipients with a set of coins selected by SelectCoins(); Also create the change output, when needed == Synopsis Declared in `<wallet/spend.h>` [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- xref:util/Result.adoc[util::Result<CreatedTransactionResult>] CreateTransaction( xref:wallet/CWallet.adoc[CWallet]& wallet, std::vector<CRecipient> const& vecSend, std::optional<unsigned int> change_pos, xref:wallet/CCoinControl.adoc[CCoinControl] const& coin_control, bool sign = true); ---- == Description [NOTE] ==== passing change_pos as std::nullopt will result in setting a random position ==== == Return Value If successful, the created transaction and its fee details, otherwise an error. == Parameters [cols="1,4"] |=== | Name| Description | *wallet* | The wallet funding and optionally signing the transaction. | *vecSend* | The recipients and amounts to pay. | *change_pos* | The position of the change output, or std::nullopt for a random position. | *coin_control* | Coin control settings governing input selection and fees. | *sign* | Whether to sign the created transaction. |=== [.small]#Created with https://www.mrdocs.com[MrDocs]#