private static void UpdateResultFromFile(UInt160 hash)
        {
            string           address = hash.ToAddress();
            X509Certificate2 cert;

            try
            {
                cert = new X509Certificate2(Path.Combine(Settings.Default.Paths.CertCache, $"{address}.cer"));
            }
            catch (CryptographicException)
            {
                results[hash].Type = CertificateQueryResultType.Missing;
                return;
            }
            if (cert.PublicKey.Oid.Value != "1.2.840.10045.2.1")
            {
                results[hash].Type = CertificateQueryResultType.Missing;
                return;
            }
            if (!hash.Equals(Contract.CreateSignatureRedeemScript(ECPoint.DecodePoint(cert.PublicKey.EncodedKeyValue.RawData, ECCurve.Secp256r1)).ToScriptHash()))
            {
                results[hash].Type = CertificateQueryResultType.Missing;
                return;
            }
            using (X509Chain chain = new X509Chain())
            {
                results[hash].Certificate = cert;
                if (chain.Build(cert))
                {
                    results[hash].Type = CertificateQueryResultType.Good;
                }
                else if (chain.ChainStatus.Length == 1 && chain.ChainStatus[0].Status == X509ChainStatusFlags.NotTimeValid)
                {
                    results[hash].Type = CertificateQueryResultType.Expired;
                }
                else
                {
                    results[hash].Type = CertificateQueryResultType.Invalid;
                }
            }
        }
Exemplo n.º 2
0
        private bool OnImportMultisigAddress(string[] args)
        {
            if (NoWallet())
            {
                return(true);
            }

            if (args.Length < 5)
            {
                Console.WriteLine("Error. Use at least 2 public keys to create a multisig address.");
                return(true);
            }

            int m = int.Parse(args[2]);
            int n = args.Length - 3;

            if (m < 1 || m > n || n > 1024)
            {
                Console.WriteLine("Error. Invalid parameters.");
                return(true);
            }

            ECPoint[] publicKeys = args.Skip(3).Select(p => ECPoint.Parse(p, ECCurve.Secp256r1)).ToArray();

            Contract multiSignContract = Contract.CreateMultiSigContract(m, publicKeys);
            KeyPair  keyPair           = Program.Wallet.GetAccounts().FirstOrDefault(p => p.HasKey && publicKeys.Contains(p.GetKey().PublicKey))?.GetKey();

            WalletAccount account = Program.Wallet.CreateAccount(multiSignContract, keyPair);

            if (Program.Wallet is BRC6Wallet wallet)
            {
                wallet.Save();
            }

            Console.WriteLine("Multisig. Addr.: " + multiSignContract.Address);

            return(true);
        }
Exemplo n.º 3
0
 public WalletAccount GetAccount(ECPoint pubkey)
 {
     return(GetAccount(Contract.CreateSignatureRedeemScript(pubkey).ToScriptHash()));
 }
 public static CertificateQueryResult Query(ECPoint pubkey)
 {
     return(Query(Contract.CreateSignatureRedeemScript(pubkey).ToScriptHash()));
 }