public TransactionSignature ExtractScriptSigParameters(Script scriptSig) { var ops = scriptSig.ToOps().ToArray(); if (!CheckScriptSigCore(scriptSig, ops, null, null)) { return(null); } var data = ops[0].PushData; if (!TransactionSignature.ValidLength(data.Length)) { return(null); } try { return(new TransactionSignature(data)); } catch (FormatException) { return(null); } }
public Script GenerateScriptSig(TransactionSignature signature, PubKey publicKey) { if (publicKey == null) { throw new ArgumentNullException(nameof(publicKey)); } return(new Script( signature == null ? OpcodeType.OP_0 : Op.GetPushOp(signature.ToBytes()), Op.GetPushOp(publicKey.ToBytes()) )); }
protected override bool CheckScriptSigCore(Script scriptSig, Op[] scriptSigOps, Script scriptPubKey, Op[] scriptPubKeyOps) { var ops = scriptSigOps; if (ops.Length != 1) { return(false); } return(ops[0].PushData != null && TransactionSignature.IsValid(ops[0].PushData)); }
protected override bool CheckScriptSigCore(Script scriptSig, Op[] scriptSigOps, Script scriptPubKey, Op[] scriptPubKeyOps) { var ops = scriptSigOps; if (ops.Length != 2) { return(false); } return(ops[0].PushData != null && (ops[0].Code == OpcodeType.OP_0 || TransactionSignature.IsValid(ops[0].PushData, ScriptVerify.None)) && ops[1].PushData != null && PubKey.Check(ops[1].PushData, false)); }
protected override bool CheckScriptSigCore(Script scriptSig, Op[] scriptSigOps, Script scriptPubKey, Op[] scriptPubKeyOps) { if (!scriptSig.IsPushOnly) { return(false); } if (scriptSigOps[0].Code != OpcodeType.OP_0) { return(false); } if (scriptSigOps.Length == 1) { return(false); } if (!scriptSigOps.Skip(1).All(s => TransactionSignature.ValidLength(s.PushData.Length) || s.Code == OpcodeType.OP_0)) { return(false); } if (scriptPubKeyOps != null) { if (!CheckScriptPubKeyCore(scriptPubKey, scriptPubKeyOps)) { return(false); } var sigCountExpected = scriptPubKeyOps[0].GetInt(); if (sigCountExpected == null) { return(false); } return(sigCountExpected == scriptSigOps.Length + 1); } return(true); }
public Script GenerateScriptSig(TransactionSignature signature) { return(new Script( Op.GetPushOp(signature.ToBytes()) )); }