/// <summary> /// Converts the top stack item to locktime without removing it. Return value indicates success. /// </summary> /// <param name="opData">Data to use</param> /// <param name="error">Error message (null if sucessful, otherwise will contain information about the failure)</param> /// <returns>True if operation was successful, false if otherwise</returns> protected bool TrySetLockTime(IOpData opData, out string error) { if (opData.ItemCount < 1) { error = Err.OpNotEnoughItems; return(false); } // The two locktime OPs (CheckLocktimeVerify and CheckSequenceVerify) used to be NOPs. NOPs don't do anything. // For backward compatibility of the softfork, Run() Peeks at the top item of the stack instead of Poping it. byte[] data = opData.Peek(); if (!TryConvertToLong(data, out lt, opData.StrictNumberEncoding, 5)) { error = "Invalid number format."; return(false); } if (lt < 0) { error = "Locktime can not be negative."; return(false); } error = null; return(true); }
protected bool TrySetLockTime(IOpData opData, out string error) { if (opData.ItemCount < 1) { error = "Not enough items left in the stack."; return(false); } // The two locktime OPs (CheckLocktimeVerify and CheckSequenceVerify) used to be NOPs. NOPs don't do anything. // For backward compatibility of the softfork, Run Peeks at the top item of the stack instead of Poping it. byte[] data = opData.Peek(); // TODO: move this check to OpHelper // (for locktimes max length is 5 for others it is 4) if (data.Length > 5) { error = "Data length for locktimes can not be bigger than 5."; return(false); } if (!OpHelper.TryConvertByteArrayToInt(data, out lt, true)) { error = "Invalid number format."; return(false); } if (lt < 0) { error = "Locktime can not be negative."; return(false); } error = null; return(true); }
/// <summary> /// Duplicates the top stack item. Return value indicates success. /// </summary> /// <param name="opData">Data to use</param> /// <param name="error">Error message (null if sucessful, otherwise will contain information about the failure)</param> /// <returns>True if operation was successful, false if otherwise</returns> public override bool Run(IOpData opData, out string error) { if (opData.ItemCount < 1) { error = Err.OpNotEnoughItems; return(false); } opData.Push(opData.Peek()); return(CheckItemCount(opData, out error)); }
/// <summary> /// Duplicates the top stack item. Return value indicates success. /// </summary> /// <param name="opData">Data to use</param> /// <param name="error">Error message (null if sucessful, otherwise will contain information about the failure)</param> /// <returns>True if operation was successful, false if otherwise</returns> public override bool Run(IOpData opData, out string error) { if (opData.ItemCount < 1) { error = "There was no item left in the stack to duplicate."; return(false); } opData.Push(opData.Peek()); error = null; return(true); }
/// <summary> /// The item at the top of the stack is copied and inserted before the second-to-top item. Return value indicates success. /// </summary> /// <param name="opData">Data to use</param> /// <param name="error">Error message (null if sucessful, otherwise will contain information about the failure)</param> /// <returns>True if operation was successful, false if otherwise</returns> public override bool Run(IOpData opData, out string error) { if (opData.ItemCount < 2) { error = Err.OpNotEnoughItems; return(false); } byte[] data = opData.Peek(); opData.Insert(data, 2); return(CheckItemCount(opData, out error)); }
/// <summary> /// Pushes the size of the top stack item to the stack without removing the item. Return value indicates success. /// </summary> /// <param name="opData">Data to use</param> /// <param name="error">Error message (null if sucessful, otherwise will contain information about the failure)</param> /// <returns>True if operation was successful, false if otherwise</returns> public override bool Run(IOpData opData, out string error) { if (opData.ItemCount < 1) { error = Err.OpNotEnoughItems; return(false); } byte[] temp = opData.Peek(); opData.Push(IntToByteArray(temp.Length)); return(CheckItemCount(opData, out error)); }
/// <summary> /// The item at the top of the stack is copied and inserted before the second-to-top item. Return value indicates success. /// </summary> /// <param name="opData">Data to use</param> /// <param name="error">Error message (null if sucessful, otherwise will contain information about the failure)</param> /// <returns>True if operation was successful, false if otherwise</returns> public override bool Run(IOpData opData, out string error) { if (opData.ItemCount < 2) { error = "There was not enough items left in the stack to tuck."; return(false); } byte[] data = opData.Peek(); opData.Insert(data, 2); error = null; return(true); }
/// <summary> /// Pushes the size of the top stack item to the stack. Return value indicates success. /// </summary> /// <param name="opData">Data to use</param> /// <param name="error">Error message (null if sucessful, otherwise will contain information about the failure)</param> /// <returns>True if operation was successful, false if otherwise</returns> public bool Run(IOpData opData, out string error) { if (opData.ItemCount < 1) { error = "There was not enough items left in the stack."; return(false); } byte[] temp = opData.Peek(); opData.Push(OpHelper.IntToByteArray(temp.Length)); error = null; return(true); }
/// <summary> /// Duplicates top stack item if its value is not 0. Return value indicates success. /// </summary> /// <param name="opData">Data to use</param> /// <param name="error">Error message (null if sucessful, otherwise will contain information about the failure)</param> /// <returns>True if operation was successful, false if otherwise</returns> public override bool Run(IOpData opData, out string error) { if (opData.ItemCount < 1) { error = Err.OpNotEnoughItems; return(false); } byte[] data = opData.Peek(); if (IsNotZero(data)) { opData.Push(data); } return(CheckItemCount(opData, out error)); }
/// <summary> /// Duplicates top stack item if its value is not 0. Return value indicates success. /// </summary> /// <param name="opData">Data to use</param> /// <param name="error">Error message (null if sucessful, otherwise will contain information about the failure)</param> /// <returns>True if operation was successful, false if otherwise</returns> public override bool Run(IOpData opData, out string error) { if (opData.ItemCount < 1) { error = "There was no item left in the stack to check and duplicate."; return(false); } byte[] data = opData.Peek(); if (OpHelper.IsNotZero(data)) { opData.Push(data); } error = null; return(true); }
public override bool Run(IOpData opData, out string error) { if (opData.ItemCount < 1) { error = "Not enough items left on the stack."; return(false); } // OP_CheckLocktimeVerify was a NOP that was activated through a soft fork. NOPs don't do anything, // for backward compatibility of the softfork, Run Peeks at the top item of the stack instead of Poping it byte[] ltBa = opData.Peek(); // TODO: iterpret this as LockTime // compare to tx.locktime throw new NotImplementedException(); }