| 1490 | } |
| 1491 | |
| 1492 | RPCHelpMan reissueasset() |
| 1493 | { |
| 1494 | return RPCHelpMan{"reissueasset", |
| 1495 | "\nCreate more of an already issued asset. Must have reissuance token in wallet to do so. Reissuing does not affect your reissuance token balance, only asset.\n" |
| 1496 | "For more fine-grained control such as reissuing from a multi-signature address cold wallet, see `rawreissueasset` RPC call.\n", |
| 1497 | { |
| 1498 | {"asset", RPCArg::Type::STR, RPCArg::Optional::NO, "The asset you want to re-issue. The corresponding token must be in your wallet."}, |
| 1499 | {"assetamount", RPCArg::Type::AMOUNT, RPCArg::Optional::NO, "Amount of additional asset to generate. Note that the amount is BTC-like, with 8 decimal places."}, |
| 1500 | }, |
| 1501 | RPCResult{ |
| 1502 | RPCResult::Type::OBJ, "", "", |
| 1503 | { |
| 1504 | {RPCResult::Type::STR_HEX, "txid", "transaction id for issuance"}, |
| 1505 | {RPCResult::Type::NUM, "vin", "input position of the issuance in the transaction"}, |
| 1506 | }, |
| 1507 | }, |
| 1508 | RPCExamples{ |
| 1509 | HelpExampleCli("reissueasset", "<asset> 0") |
| 1510 | + HelpExampleRpc("reissueasset", "<asset>, 0") |
| 1511 | }, |
| 1512 | [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue |
| 1513 | { |
| 1514 | std::shared_ptr<CWallet> const wallet = GetWalletForJSONRPCRequest(request); |
| 1515 | if (!wallet) return NullUniValue; |
| 1516 | CWallet* const pwallet = wallet.get(); |
| 1517 | |
| 1518 | LOCK(pwallet->cs_wallet); |
| 1519 | |
| 1520 | if (!g_con_elementsmode) { |
| 1521 | 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>`"); |
| 1522 | } |
| 1523 | |
| 1524 | std::string assetstr = request.params[0].get_str(); |
| 1525 | CAsset asset = GetAssetFromString(assetstr); |
| 1526 | |
| 1527 | CAmount nAmount = AmountFromValue(request.params[1], false); |
| 1528 | if (nAmount <= 0) { |
| 1529 | throw JSONRPCError(RPC_TYPE_ERROR, "Reissuance must create a non-zero amount."); |
| 1530 | } |
| 1531 | |
| 1532 | if (!pwallet->IsLocked()) { |
| 1533 | pwallet->TopUpKeyPool(); |
| 1534 | } |
| 1535 | |
| 1536 | // Find the entropy and reissuance token in wallet |
| 1537 | IssuanceDetails issuance_details; |
| 1538 | issuance_details.reissuance_asset = asset; |
| 1539 | std::map<uint256, std::pair<CAsset, CAsset> > tokenMap = pwallet->GetReissuanceTokenTypes(); |
| 1540 | for (const auto& it : tokenMap) { |
| 1541 | if (it.second.second == asset) { |
| 1542 | issuance_details.entropy = it.first; |
| 1543 | issuance_details.reissuance_token = it.second.first; |
| 1544 | } |
| 1545 | if (it.second.first == asset) { |
| 1546 | throw JSONRPCError(RPC_WALLET_ERROR, "Asset given is a reissuance token type and can not be reissued."); |
| 1547 | } |
| 1548 | } |
| 1549 | if (issuance_details.reissuance_token.IsNull()) { |
nothing calls this directly
no test coverage detected