public static List <CTKey> GetKeyFromBlockchain(uint start, int count, UInt256 assetID, out List <MixRingCTKey> mixRingIndex) { List <CTKey> ret = new List <CTKey>(); mixRingIndex = new List <MixRingCTKey>(); uint endNumber = 0; if ((int)Blockchain.Default.Height - 1 < 0) { endNumber = 0; } else { endNumber = Blockchain.Default.Height - 1; } while (ret.Count < count) { if (Blockchain.Default != null) { for (uint i = endNumber; i >= start; i--) { try { Block block = Blockchain.Default.GetBlock(i); foreach (Transaction tx in block.Transactions) { if (tx is RingConfidentialTransaction rtx) { for (byte j = 0; j < rtx.RingCTSig.Count; j++) { if (assetID == Blockchain.GoverningToken.Hash || assetID == Blockchain.UtilityToken.Hash) { if (rtx.RingCTSig[j].AssetID == assetID) { for (byte k = 0; k < rtx.RingCTSig[j].outPK.Count; k++) { CTKey key = rtx.RingCTSig[j].outPK[k]; MixRingCTKey keyIndex = new MixRingCTKey(rtx.Hash, j, k); ret.Add(key); mixRingIndex.Add(keyIndex); } } } else if (rtx.RingCTSig[j].AssetID == Blockchain.StealthNormalHash) { AssetState asset = Blockchain.Default.GetAssetState(assetID); if (asset.AssetType == AssetType.StealthToken) { for (byte k = 0; k < rtx.RingCTSig[j].outPK.Count; k++) { CTKey key = rtx.RingCTSig[j].outPK[k]; MixRingCTKey keyIndex = new MixRingCTKey(rtx.Hash, j, k); ret.Add(key); mixRingIndex.Add(keyIndex); } } } } } } } catch (Exception ex) { if ((int)Blockchain.Default.Height - 1 < 0) { endNumber = 0; } else { endNumber = Blockchain.Default.Height - 1; } break; } if (ret.Count >= count) { if ((int)Blockchain.Default.Height - 1 < 0) { endNumber = 0; } else { endNumber = Blockchain.Default.Height - 1; } break; } } } else { CTKey key = new CTKey(new ECPoint(), new ECPoint()); MixRingCTKey keyIndex = new MixRingCTKey(new UInt256(new byte[32]), 0xff, 0xff); ret.Add(key); mixRingIndex.Add(keyIndex); } } return(ret); }