public PayToScriptHashSigParameters ExtractScriptSigParameters(Script scriptSig, Script scriptPubKey) { var ops = scriptSig.ToOps().ToArray(); var ops2 = scriptPubKey == null ? null : scriptPubKey.ToOps().ToArray(); if (!CheckScriptSigCore(scriptSig, ops, scriptPubKey, ops2)) { return(null); } try { var multiSig = ops.Length > 0 && ops[0].Code == OpcodeType.OP_0; PayToScriptHashSigParameters result = new PayToScriptHashSigParameters(); result.Signatures = ops .Skip(multiSig ? 1 : 0) .Take(ops.Length - 1 - (multiSig ? 1 : 0)) .Select(o => o.Code == OpcodeType.OP_0 ? null : new TransactionSignature(o.PushData)) .ToArray(); result.RedeemScript = Script.FromBytesUnsafe(ops[ops.Length - 1].PushData); return(result); } catch (Exception) { return(null); } }
public PayToScriptHashSigParameters ExtractScriptSigParameters(Network network, Script scriptSig, Script scriptPubKey) { Op[] ops = scriptSig.ToOps().ToArray(); Op[] ops2 = scriptPubKey == null ? null : scriptPubKey.ToOps().ToArray(); if (!CheckScriptSigCore(network, scriptSig, ops, scriptPubKey, ops2)) { return(null); } var result = new PayToScriptHashSigParameters(); result.RedeemScript = Script.FromBytesUnsafe(ops[ops.Length - 1].PushData); result.Pushes = ops.Take(ops.Length - 1).Select(o => o.PushData).ToArray(); return(result); }
public PayToScriptHashSigParameters ExtractScriptSigParameters(Script scriptSig) { var ops = scriptSig.ToOps().ToArray(); if (!CheckScriptSigCore(scriptSig, ops, null, null)) { return(null); } try { PayToScriptHashSigParameters result = new PayToScriptHashSigParameters(); result.Signatures = ops .Take(ops.Length - 1) .Select(o => new TransactionSignature(o.PushData)) .ToArray(); result.RedeemScript = new Script(ops[ops.Length - 1].PushData); return(result); } catch (Exception) { return(null); } }
public Script GenerateScriptSig(PayToScriptHashSigParameters parameters) { return(GenerateScriptSig(parameters.Pushes, parameters.RedeemScript)); }
public Script GenerateScriptSig(PayToScriptHashSigParameters parameters) { return GenerateScriptSig(parameters.Pushes, parameters.RedeemScript); }
public PayToScriptHashSigParameters ExtractScriptSigParameters(Script scriptSig, Script scriptPubKey) { var ops = scriptSig.ToOps().ToArray(); var ops2 = scriptPubKey == null ? null : scriptPubKey.ToOps().ToArray(); if(!CheckScriptSigCore(scriptSig, ops, scriptPubKey, ops2)) return null; PayToScriptHashSigParameters result = new PayToScriptHashSigParameters(); result.RedeemScript = Script.FromBytesUnsafe(ops[ops.Length - 1].PushData); result.Pushes = ops.Take(ops.Length - 1).Select(o => o.PushData).ToArray(); return result; }
public PayToScriptHashSigParameters ExtractScriptSigParameters(Script scriptSig) { var ops = scriptSig.ToOps().ToArray(); if(!ops.All(o => o.PushData != null)) return null; try { PayToScriptHashSigParameters result = new PayToScriptHashSigParameters(); result.Signatures = ops .Take(ops.Length - 1) .Select(o => new TransactionSignature(o.PushData)) .ToArray(); result.Script = new Script(ops[ops.Length - 1].PushData); return result; } catch(Exception) { return null; } }
public PayToScriptHashSigParameters ExtractScriptSigParameters(Script scriptSig, Script scriptPubKey) { var ops = scriptSig.ToOps().ToArray(); var ops2 = scriptPubKey == null ? null : scriptPubKey.ToOps().ToArray(); if(!CheckScriptSigCore(scriptSig, ops, scriptPubKey, ops2)) return null; try { var multiSig = ops.Length > 0 && ops[0].Code == OpcodeType.OP_0; PayToScriptHashSigParameters result = new PayToScriptHashSigParameters(); result.Signatures = ops .Skip(multiSig ? 1 : 0) .Take(ops.Length - 1 - (multiSig ? 1 : 0)) .Select(o => o.Code == OpcodeType.OP_0 ? null : new TransactionSignature(o.PushData)) .ToArray(); result.RedeemScript = Script.FromBytesUnsafe(ops[ops.Length - 1].PushData); return result; } catch(Exception) { return null; } }
public Script GenerateScriptSig(PayToScriptHashSigParameters parameters) { return GenerateScriptSig(parameters.Signatures, parameters.RedeemScript); }