Esempio n. 1
0
        public void TestP2SH_P2PKH()
        {
            //Create p2pkh
            CryptoRSA rsa = new CryptoRSA(key, true);

            Interpreter.Initialize();

            //Create address
            byte[] pubkeyhash;

            using (var rid = RIPEMD160.Create())
                using (var sha = SHA256.Create())
                    pubkeyhash = rid.ComputeHash(sha.ComputeHash(key.publicKey));

            LockingScript   ls = new LockingScript(BASE58.Encode(pubkeyhash));
            UnlockingScript us = new UnlockingScript(rsa.Sign(transaction.Hash()), key.publicKey);

            //Create p2sh and insert p2pkh in it
            LockingScript   ls1 = new LockingScript(ls);
            UnlockingScript us1 = new UnlockingScript(ls, us);

            us1.InsertScript(ls1);

            Assert.AreEqual(EXECUTION_RESULT.SUCCESS, us1.Run(transaction), "Execution of P2SH script failed");
        }
Esempio n. 2
0
        public void TestP2PK()
        {
            CryptoRSA rsa = new CryptoRSA(key, true);

            Interpreter.Initialize();

            LockingScript   ls = new LockingScript(key.publicKey);
            UnlockingScript us = new UnlockingScript(rsa.Sign(transaction.Hash()));

            //Put locking script in unlocking script
            us.InsertScript(ls);
            Assert.AreEqual(EXECUTION_RESULT.SUCCESS, us.Run(transaction), "Execution of P2PK script failed");
        }
Esempio n. 3
0
        public void TestP2SH_P2PK()
        {
            //Create p2pk
            CryptoRSA rsa = new CryptoRSA(key, true);

            Interpreter.Initialize();

            LockingScript   ls = new LockingScript(key.publicKey);
            UnlockingScript us = new UnlockingScript(rsa.Sign(transaction.Hash()));

            //Create p2sh and insert p2pk in it
            LockingScript   ls1 = new LockingScript(ls);
            UnlockingScript us1 = new UnlockingScript(ls, us);

            us1.InsertScript(ls1);

            Assert.AreEqual(EXECUTION_RESULT.SUCCESS, us1.Run(transaction), "Execution of P2SH script failed");
        }