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

Function issueasset

src/wallet/rpc/elements.cpp:1392–1490  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1390}
1391
1392RPCHelpMan issueasset()
1393{
1394 return RPCHelpMan{"issueasset",
1395 "\nCreate an asset. Must have funds in wallet to do so. Returns asset hex id.\n"
1396 "For more fine-grained control such as multiple issuances, see `rawissueasset` RPC call.\n",
1397 {
1398 {"assetamount", RPCArg::Type::AMOUNT, RPCArg::Optional::NO, "Amount of asset to generate. Note that the amount is BTC-like, with 8 decimal places."},
1399 {"tokenamount", RPCArg::Type::AMOUNT, RPCArg::Optional::NO, "Amount of reissuance tokens to generate. Note that the amount is BTC-like, with 8 decimal places. These will allow you to reissue the asset if in wallet using `reissueasset`. These tokens are not consumed during reissuance."},
1400 {"blind", RPCArg::Type::BOOL, RPCArg::Default{true}, "Whether to blind the issuances."},
1401 {"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."},
1402 },
1403 RPCResult{
1404 RPCResult::Type::OBJ, "", "",
1405 {
1406 {RPCResult::Type::STR_HEX, "txid", "Transaction id for issuance"},
1407 {RPCResult::Type::NUM, "vin", "The input position of the issuance in the transaction"},
1408 {RPCResult::Type::STR_HEX, "entropy", "Entropy of the asset type"},
1409 {RPCResult::Type::STR_HEX, "asset", "Asset type for issuance"},
1410 {RPCResult::Type::STR_HEX, "token", "Token type for issuance"},
1411 }
1412 },
1413 RPCExamples{
1414 HelpExampleCli("issueasset", "10 0")
1415 + HelpExampleRpc("issueasset", "10, 0")
1416 },
1417 [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
1418{
1419 std::shared_ptr<CWallet> const wallet = GetWalletForJSONRPCRequest(request);
1420 if (!wallet) return NullUniValue;
1421 CWallet* const pwallet = wallet.get();
1422
1423 LOCK(pwallet->cs_wallet);
1424
1425 if (!g_con_elementsmode) {
1426 throw JSONRPCError(RPC_TYPE_ERROR, "Issuance can only be done on elements-style chains. Note: `-regtest` is Bitcoin's regtest mode, instead try `-chain=<custom chain name>`");
1427 }
1428
1429 CAmount nAmount = AmountFromValue(request.params[0], false);
1430 CAmount nTokens = AmountFromValue(request.params[1], false);
1431 if (nAmount == 0 && nTokens == 0) {
1432 throw JSONRPCError(RPC_TYPE_ERROR, "Issuance must have one non-zero component");
1433 }
1434
1435 bool blind_issuances = request.params.size() < 3 || request.params[2].get_bool();
1436
1437 // Check for optional contract to hash into definition
1438 uint256 contract_hash;
1439 if (request.params.size() >= 4) {
1440 contract_hash = ParseHashV(request.params[3], "contract_hash");
1441 }
1442
1443 if (!pwallet->IsLocked())
1444 pwallet->TopUpKeyPool();
1445
1446 // Generate a new key that is added to wallet
1447 bilingual_str error;
1448 CPubKey newKey;
1449 CTxDestination asset_dest;

Callers

nothing calls this directly

Calls 15

HelpExampleCliFunction · 0.85
HelpExampleRpcFunction · 0.85
JSONRPCErrorFunction · 0.85
ParseHashVFunction · 0.85
GetScriptForDestinationFunction · 0.85
GenerateAssetEntropyFunction · 0.85
CalculateAssetFunction · 0.85
CalculateReissuanceTokenFunction · 0.85
get_boolMethod · 0.80
IsLockedMethod · 0.80

Tested by

no test coverage detected