public async void ShouldSignCorrectly() { await Task.Yield(); string privateKey = "0xa07cb7889ab3a164dcc72cb6103f2573c7ef2d4a855810594d2bf25df60bc39e"; PlasmaCore.Transactions.Transaction transaction = new PlasmaCore.Transactions.Transaction(); transaction.AddInput(2000, 0, 1); transaction.AddOutput("0xf86b5b1c2c8de1ea4dc737c849272340fa3561c5", "0x0000000000000000000000000000000000000000", 123); transaction.AddOutput("0xf86b5b1c2c8de1ea4dc737c849272340fa3561c5", "0x0000000000000000000000000000000000000000", 5555308); TypedDataTransactionEncoder txEncoder = new TypedDataTransactionEncoder(omgDomain); byte[] encodedTx = txEncoder.EncodeRaw(transaction); var rawHash = new Sha3Keccack().CalculateHash(encodedTx); var ecKey = new Nethereum.Signer.EthECKey(privateKey); var ecdsaSignature = ecKey.SignAndCalculateV(rawHash); string signature = Nethereum.Signer.EthECDSASignature.CreateStringSignature(ecdsaSignature); Assert.Equal("0xed0ff5633cb85aa0f64684759185f8a9f94fd1b654be5942d562bf64f504e3a96a83b90a5e50e50b8a75d4f711d1c0e56066519237dbd94e564084a561b8ba2f1b", signature.EnsureHexPrefix()); transaction.SetSignature(0, signature.HexToByteArray()); var signedEncodedTx = txEncoder.EncodeSigned(transaction).ToHex(true); Assert.Equal("0xf9012ef843b841ed0ff5633cb85aa0f64684759185f8a9f94fd1b654be5942d562bf64f504e3a96a83b90a5e50e50b8a75d4f711d1c0e56066519237dbd94e564084a561b8ba2f1bd2c58207d08001c3808080c3808080c3808080f8b3eb94f86b5b1c2c8de1ea4dc737c849272340fa3561c59400000000000000000000000000000000000000007bee94f86b5b1c2c8de1ea4dc737c849272340fa3561c59400000000000000000000000000000000000000008354c46ceb94000000000000000000000000000000000000000094000000000000000000000000000000000000000080eb94000000000000000000000000000000000000000094000000000000000000000000000000000000000080a00000000000000000000000000000000000000000000000000000000000000000", signedEncodedTx.EnsureHexPrefix()); }
/// <summary> /// Deposits given amount of ether (wei) to the child chain /// </summary> /// <param name="profileFrom">profile of the sender</param> /// <param name="amount">amount of ether (wei) to send</param> /// <returns>transaction object</returns> public async Task <BCTransaction> Deposit(Profile profileFrom, BigInteger amount) { if (rootChainContract != null) { var depositPlasmaTx = new PlasmaCore.Transactions.Transaction(); depositPlasmaTx.AddOutput(profileFrom.ID, ZERO_ADDRESS, amount); RawTransactionEncoder txEncoder = new RawTransactionEncoder(); byte[] encodedDepositTx = txEncoder.EncodeRaw(depositPlasmaTx); var depositTx = await rootChainContract.Deposit(web3, profileFrom.ID, encodedDepositTx, amount); string signedDepositTx = await SignTransaction(profileFrom, depositTx); return(await SubmitTransactionOnRootChain(web3, signedDepositTx)); } return(null); }