Skip to content

Commit

Permalink
Bug Fix : multi sig Pay2Script must insert additional 0 in signature,…
Browse files Browse the repository at this point in the history
… 1.0.5.3
  • Loading branch information
NicolasDorier committed Sep 19, 2014
1 parent 232dc26 commit 262b06f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion NBitcoin/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.5.2")]
[assembly: AssemblyVersion("1.0.5.3")]
[assembly: AssemblyFileVersion("1.0.0.0")]
7 changes: 6 additions & 1 deletion NBitcoin/StandardScriptTemplate.cs
Original file line number Diff line number Diff line change
Expand Up @@ -269,10 +269,12 @@ public PayToScriptHashSigParameters ExtractScriptSigParameters(Script scriptSig)
return null;
try
{
var multiSig = ops.Length > 0 && ops[0].Code == OpcodeType.OP_0;
PayToScriptHashSigParameters result = new PayToScriptHashSigParameters();
result.Signatures =
ops
.Take(ops.Length - 1)
.Skip(multiSig ? 1 : 0)
.Take(ops.Length - 1 - (multiSig ? 1 : 0))
.Select(o => new TransactionSignature(o.PushData))
.ToArray();
result.RedeemScript = new Script(ops[ops.Length - 1].PushData);
Expand All @@ -287,6 +289,9 @@ public PayToScriptHashSigParameters ExtractScriptSigParameters(Script scriptSig)
public Script GenerateScriptSig(TransactionSignature[] signatures, Script redeemScript)
{
List<Op> ops = new List<Op>();
bool multiSig = signatures.Length > 1;
if(multiSig)
ops.Add(OpcodeType.OP_0);
foreach(var sig in signatures)
{
ops.Add(Op.GetPushOp(sig.ToBytes()));
Expand Down

0 comments on commit 262b06f

Please sign in to comment.