public void BIP65_tests() { BIP65_testsCore( Utils.UnixTimeToDateTime(510000000), Utils.UnixTimeToDateTime(509999999), false); BIP65_testsCore( Utils.UnixTimeToDateTime(510000000), Utils.UnixTimeToDateTime(510000000), true); BIP65_testsCore( Utils.UnixTimeToDateTime(510000000), Utils.UnixTimeToDateTime(510000001), true); BIP65_testsCore( 1000, 999, false); BIP65_testsCore( 1000, 1000, true); BIP65_testsCore( 1000, 1001, true); //Bad comparison BIP65_testsCore( 1000, Utils.UnixTimeToDateTime(510000001), false); BIP65_testsCore( Utils.UnixTimeToDateTime(510000001), 1000, false); Script s = new Script(OpcodeType.OP_CHECKLOCKTIMEVERIFY); Assert.Equal("OP_CLTV", s.ToString()); s = new Script("OP_CHECKLOCKTIMEVERIFY"); Assert.Equal("OP_CLTV", s.ToString()); s = new Script("OP_NOP2"); Assert.Equal("OP_CLTV", s.ToString()); s = new Script("OP_HODL"); Assert.Equal("OP_CLTV", s.ToString()); }
public void P2PKHScriptSigShouldNotBeMistakenForP2SHScriptSig() { var p2pkhScriptSig = new Script("304402206e3f2f829644ffe78b56ec8d0ea3715aee66e533a8195220bdea1526dc6ed3b202205eabcae791abfea55d54f8ec4e6de1bad1f7aa90e91687e81150b411e457025701 029f4485fddb359aeed82d71dc8df2fb0e83e31601c749d468ea92c99c13c5558b"); p2pkhScriptSig.ToString(); var result = PayToScriptHashTemplate.Instance.ExtractScriptSigParameters(p2pkhScriptSig); Assert.Null(result); }
/// <summary> /// For use with Append() and AppendLine() /// </summary> /// <param name="script">The script style to apply to the last appended text.</param> /// <returns>This Paragraph with the last appended text's script style changed.</returns> /// <example> /// Append text to this Paragraph and then set it to superscript. /// <code> /// // Create a document. /// using (DocX document = DocX.Create(@"Test.docx")) /// { /// // Insert a new Paragraph. /// Paragraph p = document.InsertParagraph(); /// /// p.Append("I am ") /// .Append("superscript").Script(Script.superscript) /// .Append(" I am not"); /// /// // Save this document. /// document.Save(); /// }// Release this document from memory. /// </code> /// </example> public Paragraph Script(Script script) { switch (script) { case Novacode.Script.none: break; default: { ApplyTextFormattingProperty(XName.Get("vertAlign", DocX.w.NamespaceName), string.Empty, new XAttribute(XName.Get("val", DocX.w.NamespaceName), script.ToString())); break; } } return this; }
public void CanParseAndGeneratePayToPubKeyScript() { var scriptPubKey = new Script("OP_DUP OP_HASH160 b72a6481ec2c2e65aa6bd9b42e213dce16fc6217 OP_EQUALVERIFY OP_CHECKSIG"); var pubKey = PayToPubkeyHashTemplate.Instance.ExtractScriptPubKeyParameters(scriptPubKey); Assert.Equal("b72a6481ec2c2e65aa6bd9b42e213dce16fc6217", pubKey.ToString()); var scriptSig = new Script("3044022064f45a382a15d3eb5e7fe72076eec4ef0f56fde1adfd710866e729b9e5f3383d02202720a895914c69ab49359087364f06d337a2138305fbc19e20d18da78415ea9301 0364bd4b02a752798342ed91c681a48793bb1c0853cbcd0b978c55e53485b8e27c"); var sigResult = PayToPubkeyHashTemplate.Instance.ExtractScriptSigParameters(scriptSig); Assert.Equal("3044022064f45a382a15d3eb5e7fe72076eec4ef0f56fde1adfd710866e729b9e5f3383d02202720a895914c69ab49359087364f06d337a2138305fbc19e20d18da78415ea9301", Encoders.Hex.EncodeData(sigResult.TransactionSignature.ToBytes())); Assert.Equal("0364bd4b02a752798342ed91c681a48793bb1c0853cbcd0b978c55e53485b8e27c", sigResult.PublicKey.ToString()); Assert.Equal(PayToPubkeyHashTemplate.Instance.GenerateScriptSig(sigResult.TransactionSignature, sigResult.PublicKey).ToString(), scriptSig.ToString()); Assert.Equal(PayToPubkeyHashTemplate.Instance.GenerateScriptPubKey(pubKey).ToString(), scriptPubKey.ToString()); scriptSig = new Script("0 0364bd4b02a752798342ed91c681a48793bb1c0853cbcd0b978c55e53485b8e27c"); sigResult = PayToPubkeyHashTemplate.Instance.ExtractScriptSigParameters(scriptSig); Assert.Null(sigResult.TransactionSignature); var scriptSig2 = PayToPubkeyHashTemplate.Instance.GenerateScriptSig(sigResult); Assert.Equal(scriptSig.ToString(), scriptSig2.ToString()); }
public void CanParseColorMarker() { var script = new Script(Encoders.Hex.DecodeData("6a104f41010003ac0200e58e260412345678")); var marker = ColorMarker.TryParse(script); Assert.NotNull(marker); Assert.Equal(1, marker.Version); Assert.Equal(3, marker.Quantities.Length); Assert.True(marker.Quantities.SequenceEqual(new ulong[] { 300, 0, 624485 })); Assert.True(marker.Metadata.SequenceEqual(new byte[] { 0x12, 0x34, 0x56, 0x78 })); Assert.Equal(script.ToString(), marker.GetScript().ToString()); }