Exemplo n.º 1
0
        public void CanParseAndGeneratePayToScript()
        {
            var template = new PayToScriptHashTemplate();
            var redeem   = "1 0364bd4b02a752798342ed91c681a48793bb1c0853cbcd0b978c55e53485b8e27c 0364bd4b02a752798342ed91c681a48793bb1c0853cbcd0b978c55e53485b8e27d 2 OP_CHECKMULTISIG";

            var scriptPubkey = "OP_HASH160 b5b88dd9befc9236915fcdbb7fd50052df50c855 OP_EQUAL";

            var scriptSig = "3044022064f45a382a15d3eb5e7fe72076eec4ef0f56fde1adfd710866e729b9e5f3383d02202720a895914c69ab49359087364f06d337a2138305fbc19e20d18da78415ea9301 51210364bd4b02a752798342ed91c681a48793bb1c0853cbcd0b978c55e53485b8e27c210364bd4b02a752798342ed91c681a48793bb1c0853cbcd0b978c55e53485b8e27d52ae";

            var pubParams = template.ExtractScriptPubKeyParameters(new Script(scriptPubkey));

            Assert.Equal("b5b88dd9befc9236915fcdbb7fd50052df50c855", pubParams.ToString());
            Assert.Equal(scriptPubkey, template.GenerateScriptPubKey(pubParams).ToString());

            var sigParams = template.ExtractScriptSigParameters(new Script(scriptSig));

            Assert.Equal("3044022064f45a382a15d3eb5e7fe72076eec4ef0f56fde1adfd710866e729b9e5f3383d02202720a895914c69ab49359087364f06d337a2138305fbc19e20d18da78415ea9301", Encoders.Hex.EncodeData(sigParams.Signatures[0].ToBytes()));
            Assert.Equal(redeem, sigParams.RedeemScript.ToString());
            Assert.Equal(scriptSig, template.GenerateScriptSig(sigParams.Signatures, sigParams.RedeemScript).ToString());
        }
Exemplo n.º 2
0
        public bool MatchScriptHash(TxOut output)
        {
            ScriptId id = template.ExtractScriptPubKeyParameters(output.ScriptPubKey);

            return(id == ScriptId);
        }