Пример #1
0
 public static byte[] CreateSignatureRedeemScript(ECPoint publicKey)
 {
     using (ScriptBuilder sb = new ScriptBuilder())
     {
         sb.Push(publicKey.EncodePoint(true));
         sb.Add(ScriptOp.OP_CHECKSIG);
         return sb.ToArray();
     }
 }
Пример #2
0
 public static byte[] CreateMultiSigRedeemScript(int m, params ECPoint[] publicKeys)
 {
     if (!(1 <= m && m <= publicKeys.Length && publicKeys.Length <= 1024))
         throw new ArgumentException();
     using (ScriptBuilder sb = new ScriptBuilder())
     {
         sb.Push(m);
         for (int i = 0; i < publicKeys.Length; i++)
         {
             sb.Push(publicKeys[i].EncodePoint(true));
         }
         sb.Push(publicKeys.Length);
         sb.Add(ScriptOp.OP_CHECKMULTISIG);
         return sb.ToArray();
     }
 }
Пример #3
0
 public Script[] GetScripts()
 {
     if (!Completed) throw new InvalidOperationException();
     Script[] scripts = new Script[signatures.Length];
     for (int i = 0; i < scripts.Length; i++)
     {
         using (ScriptBuilder sb = new ScriptBuilder())
         {
             foreach (byte[] signature in signatures[i].OrderBy(p => p.Key).Select(p => p.Value))
             {
                 sb.Push(signature);
             }
             scripts[i] = new Script
             {
                 StackScript = sb.ToArray(),
                 RedeemScript = redeemScripts[i]
             };
         }
     }
     return scripts;
 }
Пример #4
0
 public Script GetScript()
 {
     if (!Completed) throw new InvalidOperationException();
     using (ScriptBuilder sb = new ScriptBuilder())
     {
         for (int i = 0; i < signatures.Length; i++)
         {
             if (signatures[i] != null)
             {
                 sb.Push(signatures[i]);
             }
         }
         return new Script
         {
             StackScript = sb.ToArray(),
             RedeemScript = redeemScript
         };
     }
 }