private string Sign(string address, string message) { // TODO: implement message signing //var addressUint160 = address.HexToUInt160(); return(Web3DataFormatUtils.Web3Data("".HexToBytes())); //throw new ApplicationException("Not implemented yet"); }
public JObject GetChildrenByHash(string nodeHash) { IHashTrieNode?node = _nodeRetrieval.TryGetNode(HexUtils.HexToBytes(nodeHash), out var childrenHash); if (node == null) { return new JObject { } } ; JArray children = new JArray { }; foreach (var childHash in childrenHash) { JObject child = GetNodeByHash(Web3DataFormatUtils.Web3Data(childHash)); if (child.Count == 0) { return new JObject { } } ; children.Add(child); } JObject nodeHashWithChildren = new JObject { }; nodeHashWithChildren[Web3DataFormatUtils.Web3Data(node.Hash)] = children; return(nodeHashWithChildren); }
private JArray GetWork() { return(new JArray( Web3DataFormatUtils.Web3Data(new UInt256()), Web3DataFormatUtils.Web3Data(new UInt256()), Web3DataFormatUtils.Web3Data(new UInt256()) )); }
public string GetStorageAt(string address, string position, string blockTag) { var blockNumber = GetBlockNumberByTag(blockTag); var blockchainSnapshot = _snapshotIndexer.GetSnapshotForBlock((ulong)blockNumber !); var value = blockchainSnapshot.Storage.GetValue(address.HexToUInt160(), position.HexToUInt256()); return(Web3DataFormatUtils.Web3Data(value.ToHex().HexToBytes())); }
private JArray GetCurrentValidators() { var allValidators = _stateManager.CurrentSnapshot.Validators.GetValidatorsPublicKeys().ToArray(); JArray validators = new JArray { }; foreach (var validator in allValidators) { validators.Add(Web3DataFormatUtils.Web3Data(validator.Buffer.ToByteArray())); } return(validators); }
public JObject?GetStateHashFromTrieRootsRange(string startBlockTag, string endBlockTag) { ulong startBlock = startBlockTag.HexToUlong(), endBlock = endBlockTag.HexToUlong(); var stateHash = new JObject { }; for (ulong curBlock = startBlock; curBlock <= endBlock; curBlock++) { stateHash[curBlock.ToHex(false)] = Web3DataFormatUtils.Web3Data(SingleNodeHashFromRoot(curBlock.ToHex(false))); } return(stateHash); }
public JObject?GetAllTrieRootsHash(string blockTag) { var blockNumber = GetBlockNumberByTag(blockTag); IBlockchainSnapshot blockchainSnapshot = _snapshotIndexer.GetSnapshotForBlock((ulong)blockNumber); var trieRootsHash = new JObject { }; ISnapshot[] snapshots = blockchainSnapshot.GetAllSnapshot(); string[] snapshotNames = new string[] { "Balances", "Contracts", "Storage", "Transactions", "Blocks", "Events", "Validators" }; for (int i = 0; i < snapshots.Length; i++) { trieRootsHash[snapshots[i] + "Hash"] = Web3DataFormatUtils.Web3Data(snapshots[i].Hash); } return(trieRootsHash); }
public string GetRootHashByTrieName(string trieName, string blockTag) { var blockNumber = GetBlockNumberByTag(blockTag); if (blockNumber == null) { return("0x"); } IBlockchainSnapshot blockchainSnapshot = _snapshotIndexer.GetSnapshotForBlock((ulong)blockNumber); var snapshot = blockchainSnapshot.GetSnapshot(trieName); if (snapshot == null) { return("0x"); } return(Web3DataFormatUtils.Web3Data(snapshot.Hash)); }
public JObject?GetBlockByNumber(string blockTag, bool fullTx) { var blockNumber = GetBlockNumberByTag(blockTag); if (blockNumber == null) { return(null); } var block = _blockManager.GetByHeight((ulong)blockNumber); if (block == null) { return(null); } ulong gasUsed = 0; var txArray = new JArray(); if (block.TransactionHashes.Count <= 0) { return(Web3DataFormatUtils.Web3Block(block !, gasUsed, txArray)); } List <TransactionReceipt> txs = new List <TransactionReceipt>(); try { foreach (var txHash in block.TransactionHashes) { Logger.LogInformation($"Transaction hash {txHash.ToHex()} in block {blockNumber}"); TransactionReceipt?tx = _transactionManager.GetByHash(txHash); if (tx is null) { Logger.LogWarning($"Transaction not found in DB {txHash.ToHex()}"); } else { txs.Add(tx); } } } catch (Exception e) { Logger.LogWarning($"Exception {e}"); Logger.LogWarning($"block {block!.Hash}, {block.Header.Index}, {block.TransactionHashes.Count}"); foreach (var txhash in block.TransactionHashes) { Logger.LogWarning($"txhash {txhash.ToHex()}"); } } try { gasUsed = txs.Aggregate(gasUsed, (current, tx) => current + tx.GasUsed); } catch (Exception e) { Logger.LogWarning($"Exception {e}"); Logger.LogWarning($"txs {txs}"); foreach (var tx in txs) { if (tx is null) { continue; } Logger.LogWarning($"tx {tx.Hash.ToHex()} {tx.GasUsed} {tx.Status} {tx.IndexInBlock}"); } } if (fullTx) { txArray = Web3DataFormatUtils.Web3BlockTransactionArray(txs, block !.Hash, block !.Header.Index); } else { foreach (var tx in txs) { txArray.Add(Web3DataFormatUtils.Web3Data(tx.Hash)); } } return(Web3DataFormatUtils.Web3Block(block !, gasUsed, txArray)); }
public string GetStateHashFromTrieRoots(string blockTag) { return(Web3DataFormatUtils.Web3Data(SingleNodeHashFromRoot(blockTag))); }
private string CompileSerpent(string sourceCode) { return(Web3DataFormatUtils.Web3Data("".HexToBytes())); //throw new ApplicationException("Not implemented"); }
public JArray GetAccounts() { return(new JArray { Web3DataFormatUtils.Web3Data(_systemContractReader.NodeAddress()) }); }