Ejemplo n.º 1
0
        public override WalletAccount Import(string nep2, string passphrase)
        {
            KeyPair      key      = new KeyPair(GetPrivateKeyFromNEP2(nep2, passphrase));
            NEP6Contract contract = new NEP6Contract
            {
                Script         = Contract.CreateSignatureRedeemScript(key.PublicKey),
                ParameterList  = new[] { ContractParameterType.Signature },
                ParameterNames = new[] { "signature" },
                Deployed       = false
            };
            NEP6Account account;

            if (Scrypt.N == 16384 && Scrypt.R == 8 && Scrypt.P == 8)
            {
                account = new NEP6Account(this, contract.ScriptHash, nep2);
            }
            else
            {
                account = new NEP6Account(this, contract.ScriptHash, key, passphrase);
            }
            account.Contract = contract;
            AddAccount(account, true);
            return(account);
        }
Ejemplo n.º 2
0
        public override WalletAccount Import(X509Certificate2 cert)
        {
            TR.Enter();
            KeyPair key;

            using (ECDsa ecdsa = cert.GetECDsaPrivateKey())
            {
                key = new KeyPair(ecdsa.ExportParameters(true).D);
            }
            NEP6Contract contract = new NEP6Contract
            {
                Script         = Contract.CreateSignatureRedeemScript(key.PublicKey),
                ParameterList  = new[] { ContractParameterType.Signature },
                ParameterNames = new[] { "signature" },
                Deployed       = false
            };
            NEP6Account account = new NEP6Account(this, contract.ScriptHash, key, password)
            {
                Contract = contract
            };

            AddAccount(account, true);
            return(TR.Exit(account));
        }