Ejemplo n.º 1
0
        public static LegacyTransaction ToTransaction(this RelayResponse response)
        {
            var tx = new LegacyTransaction(
                response.To,
                response.Value.Value,
                response.Nonce.Value,
                response.GasPrice.Value,
                response.Gas.Value,
                response.Input);

            tx.SetSignature(new EthECDSASignature(
                                new Org.BouncyCastle.Math.BigInteger(response.R.RemoveHexPrefix(), 16),
                                new Org.BouncyCastle.Math.BigInteger(response.S.RemoveHexPrefix(), 16),
                                response.V.HexToByteArray()));

            return(tx);
        }
Ejemplo n.º 2
0
        public override async Task SignAsync(LegacyTransaction transaction)
        {
            var txMessage = new EthereumSignTx
            {
                Nonce     = transaction.Nonce,
                GasPrice  = transaction.GasPrice,
                GasLimit  = transaction.GasLimit,
                To        = transaction.ReceiveAddress,
                Value     = transaction.Value,
                AddressNs = GetPath(),
            };

            if (transaction.Data.Length > 0)
            {
                txMessage.DataInitialChunk = transaction.Data;
                txMessage.DataLength       = (uint)transaction.Data.Length;
            }

            var signature = await TrezorManager.SendMessageAsync <EthereumTxRequest, EthereumSignTx>(txMessage);

            transaction.SetSignature(EthECDSASignatureFactory.FromComponents(signature.SignatureR, signature.SignatureS, (byte)signature.SignatureV));
        }