예제 #1
0
        KzBTransaction BuildSpendingTransaction(KzScript scriptSig, KzBTransaction txCredit)
        {
            var tx = new KzBTransaction {
                LockTime = 0, Version = 1,
            };

            tx.AddIn(new KzOutPoint(), Kz.Script().Push(0).Push(0));
            //tx.AddOut(scriptPubKey, nValue);
            return(tx);
        }
예제 #2
0
 public void Encoding()
 {
     foreach (var tv in tv1s)
     {
         var bytes = hex.Decode(tv.h);
         var s     = new KzScript(tv.h);
         var ops   = s.Decode().ToArray();
         var d     = s.ToVerboseString();
         Assert.Equal(tv.d, d);
     }
 }
예제 #3
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);
            }
        }
예제 #4
0
        public void Decode()
        {
            foreach (var hex in new [] {
                "76a914c2eaba3b9c29575322c6e24fdc1b49bdfe405bad88ac",
                "4730440220327588eb1c9e502358142b67b3cd799cb6163fde4f1a92490affda78734bc63c0220639a29e63d78c971177a1792cec1b0a7e65c973edbf03eba3b3380d97b829f80412103ea03d07638e40b53d8098b62e964112f562af5ba1bffaa146ffd9e7f7d1a5c67",
                "6a22314c74794d45366235416e4d6f70517242504c6b3446474e3855427568784b71726e0101337b2274223a32302e36322c2268223a35392c2270223a313031322c2263223a312c227773223a362e322c227764223a3236307d22314a6d64484e4456336f6434796e614c7635696b4d6234616f763737507a665169580a31353537303838383133"
            })
            {
                var sb = new KzScript(hex);
                var s  = sb.ToString();
            }

            var address = new KzPubKey(true);
            var e       = new KzUInt160("c2eaba3b9c29575322c6e24fdc1b49bdfe405bad", true);
            var s1      = KzEncoders.B58Check.Encode(Kz.PUBKEY_ADDRESS, e.ReadOnlySpan);
            var s2      = KzEncoders.B58Check.Encode(Kz.SCRIPT_ADDRESS, e.ReadOnlySpan);
            //e.Span.CopyTo(address.Span);
            //var id = address.GetID();
        }
예제 #5
0
            public TV2(params string[] args)
            {
                sig   = args[0];
                pub   = args[1];
                flags = args[2];
                error = args[3];

                scriptSig   = KzScript.ParseTestScript(sig);
                scriptPub   = KzScript.ParseTestScript(pub);
                scriptFlags = KzScriptInterpreter.ParseFlags(flags);
                scriptError = ToScriptError(error);

                opcodes = scriptSig.Decode().Select(o => o.Code)
                          .Concat(scriptPub.Decode().Select(o => o.Code))
                          .Distinct()
                          .OrderBy(o => o).ToArray();

                keyopcode = opcodes.Length == 0 ? (KzOpcode?)null : opcodes.Last();
            }
예제 #6
0
 public virtual bool CheckSig(KzValType scriptSig, KzValType vchPubKey, KzScript scriptCode, KzScriptFlags flags) => false;
예제 #7
0
 public static IKzWriter Add(this IKzWriter w, KzScript script, bool withoutCodeSeparators = false) => script.AddTo(w, withoutCodeSeparators);