Пример #1
0
 public void Sign(Block block, ECPoint[] miners)
 {
     SignatureContext context = new SignatureContext(block);
     Contract contract = MultiSigContract.Create(null, miners.Length / 2 + 1, miners);
     foreach (ECPoint pubKey in miners)
     {
         UInt160 publicKeyHash = pubKey.EncodePoint(true).ToScriptHash();
         Account account = GetAccount(publicKeyHash);
         if (account == null) continue;
         byte[] signature = block.Sign(account);
         context.Add(contract, account.PublicKey, signature);
     }
     block.Script = context.GetScripts()[0];
 }
Пример #2
0
 public bool Sign(SignatureContext context)
 {
     bool fSuccess = false;
     foreach (UInt160 scriptHash in context.ScriptHashes)
     {
         Contract contract = GetContract(scriptHash);
         if (contract == null) continue;
         Account account = GetAccountByScriptHash(scriptHash);
         if (account == null) continue;
         byte[] signature;
         using (account.Decrypt())
         {
             signature = context.Signable.Sign(account.PrivateKey, account.PublicKey);
         }
         fSuccess |= context.Add(contract.RedeemScript, ECPoint.FromBytes(account.PublicKey, ECCurve.Secp256r1), signature);
     }
     return fSuccess;
 }
Пример #3
0
 public bool Sign(SignatureContext context, byte[] redeemScript)
 {
     return context.Add(redeemScript, PublicKey, Sign(context.Signable));
 }
Пример #4
0
 public bool Sign(SignatureContext context)
 {
     bool fSuccess = false;
     for (int i = 0; i < context.ScriptHashes.Length; i++)
     {
         WalletEntry entry = GetEntry(context.ScriptHashes[i]);
         if (entry == null) continue;
         for (int j = 0; j < entry.PrivateKeys.Length; j++)
         {
             byte[] signature;
             using (entry.Decrypt(j))
             {
                 signature = context.Signable.Sign(entry.PrivateKeys[j], entry.PublicKeys[j]);
             }
             fSuccess |= context.Add(entry.RedeemScript, Secp256r1Point.FromBytes(entry.PublicKeys[j]), signature);
         }
     }
     return fSuccess;
 }
Пример #5
0
 public bool Sign(SignatureContext context)
 {
     bool fSuccess = false;
     foreach (UInt160 scriptHash in context.ScriptHashes)
     {
         Contract contract = GetContract(scriptHash);
         if (contract == null) continue;
         Account account = GetAccountByScriptHash(scriptHash);
         if (account == null) continue;
         byte[] signature;
         using (account.Decrypt())
         {
             signature = context.Signable.Sign(account.PrivateKey, account.PublicKey.EncodePoint(false).Skip(1).ToArray());
         }
         fSuccess |= context.Add(contract.RedeemScript, account.PublicKey, signature);
     }
     return fSuccess;
 }