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].GetValue(); return(sigCountExpected == scriptSigOps.Length + 1); } return(true); }
protected override bool CheckScriptSigCore(Network network, 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); } (PubKey[] pubKeys, int sigCountExpected) = network.Federations.GetFederation(scriptPubKeyOps[0].PushData).GetFederationDetails(); return(sigCountExpected == scriptSigOps.Length + 1); } return(true); }
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 TransactionSignature ExtractScriptSigParameters(Network network, Script scriptSig) { Op[] ops = scriptSig.ToOps().ToArray(); if (!CheckScriptSigCore(network, scriptSig, ops, null, null)) { return(null); } byte[] data = ops[0].PushData; if (!TransactionSignature.ValidLength(data.Length)) { return(null); } try { return(new TransactionSignature(data)); } catch (FormatException) { return(null); } }