Esempio n. 1
0
        void SigHash(List <TestVector> tvs)
        {
            var i = 0;

            foreach (var tv in tvs)
            {
                i++;
                var tx = KzTransaction.ParseHex(tv.rawTx);
                var(scriptCodeOk, scriptCode) = KzScript.ParseHex(tv.rawScript, withoutLength: true);
                Assert.True(tx != null && scriptCodeOk);

                var shreg = KzScriptInterpreter.ComputeSignatureHash(scriptCode, tx, tv.nIn, tv.sigHashType, KzAmount.Zero).ToString();
                Assert.Equal(tv.sigHashRegHex, shreg);

                var shold = KzScriptInterpreter.ComputeSignatureHash(scriptCode, tx, tv.nIn, tv.sigHashType, KzAmount.Zero, 0).ToString();
                Assert.Equal(tv.sigHashOldHex, shold);
            }
        }
Esempio n. 2
0
File: Zmq.cs Progetto: kzbsv/KzjHack
        static async Task ReadTxPipeAsync(PipeReader reader)
        {
            var tx = new KzTransaction();

            // Read Bitcoin transactions from a PipeReader
            while (_zmqRunning)
            {
                var rr = await reader.ReadAsync();

                var consumed = 0L;
                var buf      = rr.Buffer;
                if (tx.TryReadTransaction(ref buf))
                {
                    reader.AdvanceTo(buf.GetPosition(consumed));
                    KzH.WriteLine($"Tx parsed id={tx.TxId.ToHex()}");
                }
                else
                {
                    reader.AdvanceTo(buf.Start, buf.End);
                    KzH.WriteLine($"Tx parse failed");
                }
            }
        }
Esempio n. 3
0
 public static IKzWriter Add(this IKzWriter w, KzTransaction tx) => tx.AddTo(w);