| 1584 | } |
| 1585 | |
| 1586 | RPCHelpMan listissuances() |
| 1587 | { |
| 1588 | return RPCHelpMan{"listissuances", |
| 1589 | "\nList all issuances known to the wallet for the given asset, or for all issued assets if none provided.\n", |
| 1590 | { |
| 1591 | {"asset", RPCArg::Type::STR, RPCArg::Optional::OMITTED, "The asset whose issaunces you wish to list. Accepts either the asset hex or the locally assigned asset label."}, |
| 1592 | }, |
| 1593 | RPCResult{ |
| 1594 | RPCResult::Type::ARR, "", "List of transaction issuances and information in wallet", |
| 1595 | { |
| 1596 | {RPCResult::Type::OBJ, "", "", |
| 1597 | { |
| 1598 | {RPCResult::Type::STR_HEX, "txid", "Transaction id for issuance"}, |
| 1599 | {RPCResult::Type::STR_HEX, "entropy", "Entropy of the asset type"}, |
| 1600 | {RPCResult::Type::STR_HEX, "asset", "Asset type for issuance if known"}, |
| 1601 | {RPCResult::Type::STR, "assetlabel", "Asset label for issuance if set"}, |
| 1602 | {RPCResult::Type::STR_HEX, "token", "Token type for issuancen"}, |
| 1603 | {RPCResult::Type::NUM, "vin", "The input position of the issuance in the transaction"}, |
| 1604 | {RPCResult::Type::STR_AMOUNT, "assetamount", "The amount of asset issued. Is -1 if blinded and unknown to wallet"}, |
| 1605 | {RPCResult::Type::STR_AMOUNT, "tokenamount", "The reissuance token amount issued. Is -1 if blinded and unknown to wallet"}, |
| 1606 | {RPCResult::Type::BOOL, "isreissuance", "Whether this is a reissuance"}, |
| 1607 | {RPCResult::Type::STR_HEX, "assetblinds", "Blinding factor for asset amounts"}, |
| 1608 | {RPCResult::Type::STR_HEX, "tokenblinds", "Blinding factor for token amounts"}, |
| 1609 | }}, |
| 1610 | } |
| 1611 | }, |
| 1612 | RPCExamples{ |
| 1613 | HelpExampleCli("listissuances", "<asset>") |
| 1614 | + HelpExampleRpc("listissuances", "<asset>") |
| 1615 | }, |
| 1616 | [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue |
| 1617 | { |
| 1618 | std::shared_ptr<CWallet> const wallet = GetWalletForJSONRPCRequest(request); |
| 1619 | if (!wallet) return NullUniValue; |
| 1620 | CWallet* const pwallet = wallet.get(); |
| 1621 | |
| 1622 | LOCK(pwallet->cs_wallet); |
| 1623 | |
| 1624 | std::string assetstr; |
| 1625 | CAsset asset_filter; |
| 1626 | if (request.params.size() > 0) { |
| 1627 | assetstr = request.params[0].get_str(); |
| 1628 | asset_filter = GetAssetFromString(assetstr); |
| 1629 | } |
| 1630 | |
| 1631 | UniValue issuancelist(UniValue::VARR); |
| 1632 | for (const auto& it : pwallet->mapWallet) { |
| 1633 | const CWalletTx* pcoin = &it.second; |
| 1634 | CAsset asset; |
| 1635 | CAsset token; |
| 1636 | uint256 entropy; |
| 1637 | for (uint64_t vinIndex = 0; vinIndex < pcoin->tx->vin.size(); vinIndex++) { |
| 1638 | UniValue item(UniValue::VOBJ); |
| 1639 | const CAssetIssuance& issuance = pcoin->tx->vin[vinIndex].assetIssuance; |
| 1640 | if (issuance.IsNull()) { |
| 1641 | continue; |
| 1642 | } |
| 1643 | if (issuance.assetBlindingNonce.IsNull()) { |
nothing calls this directly
no test coverage detected