protected override Keccak Handle(TransactionForRpc transaction, IWeb3EthApi api) { var deltaWithCid = api.GetLatestDeltaWithCid(); var parentDelta = deltaWithCid.Delta; Keccak root = parentDelta.StateRoot.ToKeccak(); var publicEntry = api.ToPublicEntry(transaction, root); return(api.SendTransaction(publicEntry)); }
protected override Keccak Handle(byte[] transaction, IWeb3EthApi api) { PublicEntry publicEntry; try { Transaction tx = Rlp.Decode <Transaction>(transaction); EthereumEcdsa ecdsa = new EthereumEcdsa(MainnetSpecProvider.Instance, LimboLogs.Instance); tx.SenderAddress = ecdsa.RecoverAddress(tx, MainnetSpecProvider.IstanbulBlockNumber); tx.Timestamp = (UInt256)DateTimeOffset.UtcNow.ToUnixTimeSeconds(); publicEntry = new PublicEntry { Data = (tx.Data ?? tx.Init).ToByteString(), GasLimit = (ulong)tx.GasLimit, GasPrice = tx.GasPrice.ToUint256ByteString(), Nonce = (ulong)tx.Nonce, SenderAddress = tx.SenderAddress.Bytes.ToByteString(), ReceiverAddress = tx.To?.Bytes.ToByteString() ?? ByteString.Empty, Amount = tx.Value.ToUint256ByteString(), Signature = new Protocol.Cryptography.Signature { RawBytes = ByteString.CopyFrom((byte)1) } }; } catch { try { TransactionBroadcast transactionBroadcast = TransactionBroadcast.Parser.ParseFrom(transaction); publicEntry = transactionBroadcast.PublicEntry; } catch (Exception) { throw new InvalidDataException($"Transaction data could not be deserialized into a {nameof(PublicEntry)}"); } } return(api.SendTransaction(publicEntry)); }