Esempio n. 1
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);
        }
Esempio n. 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.EncodePoint(false).Skip(1).ToArray());
                }
                fSuccess |= context.Add(contract.RedeemScript, account.PublicKey, signature);
            }
            return(fSuccess);
        }
Esempio n. 3
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];
        }
Esempio n. 4
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 = context.Signable.Sign(account);
                fSuccess |= context.Add(contract, account.PublicKey, signature);
            }
            return(fSuccess);
        }
Esempio n. 5
0
 public bool Sign(SignatureContext context, byte[] redeemScript)
 {
     return(context.Add(redeemScript, PublicKey, Sign(context.Signable)));
 }