예제 #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");
        }