本文整理汇总了C#中System.Script.ToBytes方法的典型用法代码示例。如果您正苦于以下问题:C# Script.ToBytes方法的具体用法?C# Script.ToBytes怎么用?C# Script.ToBytes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Script
的用法示例。
在下文中一共展示了Script.ToBytes方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ReadScript
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;
}
示例2: AssertCompressed
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();
}
示例3: ReplaceRedeemScript
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);
}
示例4: CanGenerateScriptSig
public override bool CanGenerateScriptSig(Script scriptPubKey)
{
return scriptPubKey.Length == 1 && scriptPubKey.ToBytes(true)[0] == (byte)OpcodeType.OP_TRUE;
}