| 2984 | } |
| 2985 | |
| 2986 | static RPCHelpMan rawissueasset() |
| 2987 | { |
| 2988 | return RPCHelpMan{"rawissueasset", |
| 2989 | "\nCreate an asset by attaching issuances to transaction inputs. Returns the transaction hex. There must be as many inputs as issuances requested. The final transaction hex is the final version of the transaction appended to the last object in the array.\n", |
| 2990 | { |
| 2991 | {"transaction", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, "Transaction in hex in which to include an issuance input."}, |
| 2992 | {"issuances", RPCArg::Type::ARR, RPCArg::Optional::NO, "List of issuances to create. Each issuance must have one non-zero amount.", |
| 2993 | { |
| 2994 | {"", RPCArg::Type::OBJ, RPCArg::Optional::NO, "", |
| 2995 | { |
| 2996 | {"asset_amount", RPCArg::Type::AMOUNT, RPCArg::Optional::OMITTED_NAMED_ARG, "Amount of asset to generate, if any."}, |
| 2997 | {"asset_address", RPCArg::Type::STR, RPCArg::Optional::OMITTED_NAMED_ARG, "Destination address of generated asset. Required if `asset_amount` given."}, |
| 2998 | {"token_amount", RPCArg::Type::AMOUNT, RPCArg::Optional::OMITTED_NAMED_ARG, "Amount of reissuance token to generate, if any."}, |
| 2999 | {"token_address", RPCArg::Type::STR, RPCArg::Optional::OMITTED_NAMED_ARG, "Destination address of generated reissuance tokens. Required if `token_amount` given."}, |
| 3000 | {"blind", RPCArg::Type::BOOL, RPCArg::Default{true}, "Whether to mark the issuance input for blinding or not. Only affects issuances with re-issuance tokens."}, |
| 3001 | {"contract_hash", RPCArg::Type::STR_HEX, RPCArg::Default{"0000...0000"}, "Contract hash that is put into issuance definition. Must be 32 bytes worth in hex string form. This will affect the asset id."}, |
| 3002 | } |
| 3003 | } |
| 3004 | } |
| 3005 | }, |
| 3006 | }, |
| 3007 | RPCResult{ |
| 3008 | RPCResult::Type::ARR, "", "Results of issuances, in the order of `issuances` arguments", |
| 3009 | { |
| 3010 | {RPCResult::Type::OBJ, "", "", |
| 3011 | { |
| 3012 | {RPCResult::Type::STR_HEX, "hex", "The transaction with issuances appended. Only appended to final index in returned array"}, |
| 3013 | {RPCResult::Type::NUM, "vin", "The input position of the issuance in the transaction"}, |
| 3014 | {RPCResult::Type::STR_HEX, "entropy", "Entropy of the asset type"}, |
| 3015 | {RPCResult::Type::STR_HEX, "asset", "Asset type for issuance if known"}, |
| 3016 | {RPCResult::Type::STR_HEX, "token", "Token type for issuance"}, |
| 3017 | }}, |
| 3018 | }, |
| 3019 | }, |
| 3020 | RPCExamples{""}, |
| 3021 | [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue |
| 3022 | { |
| 3023 | CMutableTransaction mtx; |
| 3024 | |
| 3025 | if (!DecodeHexTx(mtx, request.params[0].get_str())) |
| 3026 | throw JSONRPCError(RPC_DESERIALIZATION_ERROR, "TX decode failed"); |
| 3027 | |
| 3028 | UniValue issuances = request.params[1].get_array(); |
| 3029 | |
| 3030 | UniValue ret(UniValue::VARR); |
| 3031 | |
| 3032 | // Count issuances, only append hex to final one |
| 3033 | unsigned int issuances_til_now = 0; |
| 3034 | |
| 3035 | // Validate fee output location, required by the implementation of issueasset_base |
| 3036 | if (mtx.vout.size() == 0){ |
| 3037 | throw JSONRPCError(RPC_INVALID_PARAMETER, "Transaction must have at least one output."); |
| 3038 | } |
| 3039 | if (!mtx.vout[mtx.vout.size() - 1].IsFee()) { |
| 3040 | throw JSONRPCError(RPC_INVALID_PARAMETER, "Last transaction output must be fee."); |
| 3041 | } |
| 3042 | for (size_t i = 0; i < mtx.vout.size() - 1; i++) { |
| 3043 | if (mtx.vout[i].IsFee()) { |
nothing calls this directly
no test coverage detected