Exemple #1
0
        public void CanParseAndGeneratePayToPubKeyScript()
        {
            var payToPubHash = new PayToPubkeyHashTemplate();
            var scriptPubKey = new Script("OP_DUP OP_HASH160 b72a6481ec2c2e65aa6bd9b42e213dce16fc6217 OP_EQUALVERIFY OP_CHECKSIG");
            var pubKey       = payToPubHash.ExtractScriptPubKeyParameters(scriptPubKey);

            Assert.Equal("b72a6481ec2c2e65aa6bd9b42e213dce16fc6217", pubKey.ToString());
            var scriptSig = new Script("3044022064f45a382a15d3eb5e7fe72076eec4ef0f56fde1adfd710866e729b9e5f3383d02202720a895914c69ab49359087364f06d337a2138305fbc19e20d18da78415ea9301 0364bd4b02a752798342ed91c681a48793bb1c0853cbcd0b978c55e53485b8e27c");

            var sigResult = payToPubHash.ExtractScriptSigParameters(scriptSig);

            Assert.Equal("3044022064f45a382a15d3eb5e7fe72076eec4ef0f56fde1adfd710866e729b9e5f3383d02202720a895914c69ab49359087364f06d337a2138305fbc19e20d18da78415ea9301", Encoders.Hex.EncodeData(sigResult.TransactionSignature.ToBytes()));
            Assert.Equal("0364bd4b02a752798342ed91c681a48793bb1c0853cbcd0b978c55e53485b8e27c", sigResult.PublicKey.ToString());

            Assert.Equal(payToPubHash.GenerateScriptSig(sigResult.TransactionSignature, sigResult.PublicKey).ToString(), scriptSig.ToString());
            Assert.Equal(payToPubHash.GenerateScriptPubKey(pubKey).ToString(), scriptPubKey.ToString());
        }
Exemple #2
0
        public bool MatchPubKeyHash(TxOut output)
        {
            var id = template.ExtractScriptPubKeyParameters(output.ScriptPubKey);

            return(id == KeyId);
        }