Exemple #1
0
		private bool ReadScript(Script script)
		{
			var bytes = script.ToBytes(true);
			if(bytes.Length == 0 || bytes[0] != (byte)OpcodeType.OP_RETURN)
				return false;
			foreach(var op in script.ToOps())
			{
				if(op.PushData != null && !op.IsInvalid)
				{
					if(ReadData(op.PushData))
						return true;
				}
			}
			return false;
		}
Exemple #2
0
		private Script AssertCompressed(Script script, int expectedSize)
		{
			var compressor = new ScriptCompressor(script);
			var compressed = compressor.ToBytes();
			Assert.Equal(expectedSize, compressed.Length);

			compressor = new ScriptCompressor();
			compressor.ReadWrite(compressed);
			AssertEx.CollectionEquals(compressor.GetScript().ToBytes(), script.ToBytes());

			var compressed2 = compressor.ToBytes();
			AssertEx.CollectionEquals(compressed, compressed2);
			return compressor.GetScript();
		}
Exemple #3
0
		void ReplaceRedeemScript(TxIn input, Script redeemScript)
		{
			ScriptEvaluationContext ctx = new ScriptEvaluationContext();
			ctx.ScriptVerify = ScriptVerify.StrictEnc;
			ctx.EvalScript(input.ScriptSig, new Transaction(), 0);
			var stack = ctx.Stack;
			Assert.True(stack.Count > 0);
			stack.Pop();
			stack.Push(redeemScript.ToBytes());
			input.ScriptSig = PushAll(stack);
		}
Exemple #4
0
		public override bool CanGenerateScriptSig(Script scriptPubKey)
		{
			return scriptPubKey.Length == 1 && scriptPubKey.ToBytes(true)[0] == (byte)OpcodeType.OP_TRUE;
		}