| 1706 | } |
| 1707 | |
| 1708 | UniValue createpsbt(const JSONRPCRequest& request) |
| 1709 | { |
| 1710 | if (request.fHelp || request.params.size() < 2 || request.params.size() > 4) |
| 1711 | throw std::runtime_error( |
| 1712 | "createpsbt [{\"txid\":\"id\",\"vout\":n},...] [{\"address\":amount},{\"data\":\"hex\"},...] ( locktime ) ( replaceable )\n" |
| 1713 | "\nCreates a transaction in the Partially Signed Transaction format.\n" |
| 1714 | "Implements the Creator role.\n" |
| 1715 | "\nArguments:\n" |
| 1716 | "1. \"inputs\" (array, required) A json array of json objects\n" |
| 1717 | " [\n" |
| 1718 | " {\n" |
| 1719 | " \"txid\":\"id\", (string, required) The transaction id\n" |
| 1720 | " \"vout\":n, (numeric, required) The output number\n" |
| 1721 | " \"sequence\":n (numeric, optional) The sequence number\n" |
| 1722 | " } \n" |
| 1723 | " ,...\n" |
| 1724 | " ]\n" |
| 1725 | "2. \"outputs\" (array, required) a json array with outputs (key-value pairs)\n" |
| 1726 | " [\n" |
| 1727 | " {\n" |
| 1728 | " \"address\": x.xxx, (obj, optional) A key-value pair. The key (string) is the bitcoin address, the value (float or string) is the amount in " + CURRENCY_UNIT + "\n" |
| 1729 | " },\n" |
| 1730 | " {\n" |
| 1731 | " \"data\": \"hex\" (obj, optional) A key-value pair. The key must be \"data\", the value is hex encoded data\n" |
| 1732 | " }\n" |
| 1733 | " ,... More key-value pairs of the above form. For compatibility reasons, a dictionary, which holds the key-value pairs directly, is also\n" |
| 1734 | " accepted as second parameter.\n" |
| 1735 | " ]\n" |
| 1736 | "3. locktime (numeric, optional, default=0) Raw locktime. Non-0 value also locktime-activates inputs\n" |
| 1737 | "4. replaceable (boolean, optional, default=false) Marks this transaction as BIP125 replaceable.\n" |
| 1738 | " Allows this transaction to be replaced by a transaction with higher fees. If provided, it is an error if explicit sequence numbers are incompatible.\n" |
| 1739 | "\nResult:\n" |
| 1740 | " \"psbt\" (string) The resulting raw transaction (base64-encoded string)\n" |
| 1741 | "\nExamples:\n" |
| 1742 | + HelpExampleCli("createpsbt", "\"[{\\\"txid\\\":\\\"myid\\\",\\\"vout\\\":0}]\" \"[{\\\"data\\\":\\\"00010203\\\"}]\"") |
| 1743 | ); |
| 1744 | |
| 1745 | |
| 1746 | RPCTypeCheck(request.params, { |
| 1747 | UniValue::VARR, |
| 1748 | UniValueType(), // ARR or OBJ, checked later |
| 1749 | UniValue::VNUM, |
| 1750 | UniValue::VBOOL, |
| 1751 | }, true |
| 1752 | ); |
| 1753 | |
| 1754 | CMutableTransaction rawTx = ConstructTransaction(request.params[0], request.params[1], request.params[2], request.params[3]); |
| 1755 | |
| 1756 | // Make a blank psbt |
| 1757 | PartiallySignedTransaction psbtx; |
| 1758 | psbtx.tx = rawTx; |
| 1759 | for (unsigned int i = 0; i < rawTx.vin.size(); ++i) { |
| 1760 | psbtx.inputs.push_back(PSBTInput()); |
| 1761 | } |
| 1762 | for (unsigned int i = 0; i < rawTx.vout.size(); ++i) { |
| 1763 | psbtx.outputs.push_back(PSBTOutput()); |
| 1764 | } |
| 1765 |
nothing calls this directly
no test coverage detected