예제 #1
0
        public void ShouldSignV1()
        {
            var prevTx = Transaction.Parse("01000000018d600e5b601607b9ba7d788830ce442893ba091520d0ac9706b3f5bce0670696010000006a47304402202d83e5f388d44fbf3d93a55d" +
                                           "e8eac7744edb04bfc5845e2392d59c51e7d90a28022043a95b0088bb09022ee519e8421eb5c347f5d8ace24dd4242364605754f171a20121033724" +
                                           "13cbd5741751044d91b0d225715e783a3fce9f51dc5491f938634783dff1ffffffff015c9ce111000000001976a9144faeeb51bcd0b49f238b323e" +
                                           "5f1c6c8bf11ae02a88ac00000000");
            var from           = "tmGygFvgg1B35XeX3oC4e78VSiAyRGcCgME";
            var fromAddress    = new BitcoinPubKeyAddress(from);
            var fromPrivateKey = "cTD2Ew71UHXkn2XTJLyfu6Rbo1os5zCF9sKZm4oiXshcYo6YPcKY";
            var fromKey        = Key.Parse(fromPrivateKey);
            var to             = "tmLaY2Ceabpd9TgMmPv6zfDfVGEwmAWuPKo";
            var toAddress      = new BitcoinPubKeyAddress(to);

            var hex = new TransactionBuilder()
                      .AddCoins(prevTx.Outputs.AsCoins())
                      .Send(toAddress, Money.Coins(0.5m))
                      .SetChange(fromAddress)
                      .SendFees(Money.Coins(0.00002380m))
                      .BuildTransaction(false)
                      .ToHex();

            var tx = new ZcashTransaction(hex);

            tx.Sign(new[] { fromKey }, prevTx.Outputs.AsCoins().ToArray());

            Assert.Equal(
                "c749dbf380e287fb84190b4d6695b82e7eb4f91a1f79c68dc0cfb539fbdd45c4",
                tx.GetHash().ToString());

            Assert.Equal(
                "01000000016cf8b84870d09e65f5809772d8d56e7ec69801291fe3ae7f8e6e6446e80886fd000000006b483045022100f5a4d723f4dbd4b5c2c3e603ed67f5a8798c7a264198cf7035" +
                "eb88d7e92dce4102204237d7e5af9a2fd64545f6bc8fbad0039510dca378795299454dc0253cd46785012103f9e72f0713a4d4a980309a14a2ba563e0b1125ad067818e77553a1eefb" +
                "fc5be7ffffffff0290a2e60e000000001976a9144faeeb51bcd0b49f238b323e5f1c6c8bf11ae02a88ac80f0fa02000000001976a914772efac94ff91e33c6b2540e4b539fbbcd9b0e" +
                "bb88ac00000000",
                tx.ToHex());
        }
예제 #2
0
        public void ShouldDeserializeV3()
        {
            var tx = new ZcashTransaction(v3);

            Assert.Equal("bd3772485a22944991d3e29fa775d1a90b26b5f052b7869a9f2b41a5112ea9c5", tx.GetHash().ToString());
            Assert.Equal("9e57c9ace4f1c6797fbb12334d913838061d08264a7ae186824cd8b94b1e8791", tx.Inputs[0].PrevOut.Hash.ToString());
            Assert.Equal(300000000L, tx.Outputs[0].Value.Satoshi);
        }
예제 #3
0
        public void ShouldDeserializeV1()
        {
            var tx = new ZcashTransaction(v1);

            Assert.Equal("5c6ba844e1ca1c8083cd53e29971bd82f1f9eea1f86c1763a22dd4ca183ae061", tx.GetHash().ToString());
            Assert.Equal("5e6e4ea05be96f47715c193444e77cf9f6bd18afa7fca7800db7dc5d69a024ea", tx.Inputs[0].PrevOut.Hash.ToString());
            Assert.Equal(288595012L, tx.Outputs[0].Value.Satoshi);
        }
예제 #4
0
        public void ShouldDeserializeV4()
        {
            var tx = new ZcashTransaction(v4);

            Assert.Equal("011bc69c232c8fa864d9647700a47452447f15c7913555c2291030809361172c", tx.GetHash().ToString());
            Assert.Equal("e7ab8fb7c05097e88a29a816bdc75c958e58a8deee659c14baf9ffe51da96307", tx.Inputs[0].PrevOut.Hash.ToString());
            Assert.Contains(tx.Outputs, x => x.Value.Satoshi == 001000000L);
            Assert.Contains(tx.Outputs, x => x.Value.Satoshi == 269992303L);
        }