Example #1
0
        public KeyManager(BitcoinEncryptedSecretNoEC encryptedSecret, byte[] chainCode, string password, int minGapLimit = AbsoluteMinGapLimit, string filePath = null, KeyPath accountKeyPath = null)
        {
            HdPubKeys               = new List <HdPubKey>();
            HdPubKeyScriptBytes     = new List <byte[]>();
            ScriptHdPubKeyMap       = new Dictionary <Script, HdPubKey>();
            HdPubKeysLock           = new object();
            HdPubKeyScriptBytesLock = new object();
            ScriptHdPubKeyMapLock   = new object();
            BlockchainState         = new BlockchainState();
            BlockchainStateLock     = new object();
            HardwareWalletInfo      = null;

            if (password is null)
            {
                password = "";
            }

            SetMinGapLimit(minGapLimit);

            EncryptedSecret = Guard.NotNull(nameof(encryptedSecret), encryptedSecret);
            ChainCode       = Guard.NotNull(nameof(chainCode), chainCode);
            var extKey = new ExtKey(encryptedSecret.GetKey(password), chainCode);

            MasterFingerprint = extKey.Neuter().PubKey.GetHDFingerPrint();
            AccountKeyPath    = accountKeyPath ?? DefaultAccountKeyPath;
            ExtPubKey         = extKey.Derive(AccountKeyPath).Neuter();

            SetFilePath(filePath);
            ToFileLock = new object();
            ToFile();
        }
Example #2
0
        public KeyManager(BitcoinEncryptedSecretNoEC encryptedSecret, byte[] chainCode, string password, string filePath = null)
        {
            HdPubKeys               = new List <HdPubKey>();
            HdPubKeyScriptBytes     = new List <byte[]>();
            ScriptHdPubkeyMap       = new Dictionary <Script, HdPubKey>();
            HdPubKeysLock           = new object();
            HdPubKeyScriptBytesLock = new object();
            ScriptHdPubkeyMapLock   = new object();
            BlockchainState         = new BlockchainState();
            BlockchainStateLock     = new object();

            if (password is null)
            {
                password = "";
            }

            EncryptedSecret = Guard.NotNull(nameof(encryptedSecret), encryptedSecret);
            ChainCode       = Guard.NotNull(nameof(chainCode), chainCode);
            var extKey = new ExtKey(encryptedSecret.GetKey(password), chainCode);

            ExtPubKey = extKey.Derive(AccountKeyPath).Neuter();

            SetFilePath(filePath);
            ToFileLock = new object();
            ToFile();
        }
Example #3
0
        public KeyManager(BitcoinEncryptedSecretNoEC encryptedSecret, byte[] chainCode, HDFingerprint?masterFingerprint, ExtPubKey extPubKey, bool?passwordVerified, int?minGapLimit, BlockchainState blockchainState, string filePath = null, KeyPath accountKeyPath = null)
        {
            HdPubKeys               = new List <HdPubKey>();
            HdPubKeyScriptBytes     = new List <byte[]>();
            ScriptHdPubKeyMap       = new Dictionary <Script, HdPubKey>();
            HdPubKeysLock           = new object();
            HdPubKeyScriptBytesLock = new object();
            ScriptHdPubKeyMapLock   = new object();
            BlockchainStateLock     = new object();

            EncryptedSecret   = encryptedSecret;
            ChainCode         = chainCode;
            MasterFingerprint = masterFingerprint;
            ExtPubKey         = Guard.NotNull(nameof(extPubKey), extPubKey);

            PasswordVerified = passwordVerified;
            SetMinGapLimit(minGapLimit);

            BlockchainState    = blockchainState ?? new BlockchainState();
            HardwareWalletInfo = null;
            AccountKeyPath     = accountKeyPath ?? DefaultAccountKeyPath;

            SetFilePath(filePath);
            ToFileLock = new object();
            ToFile();
        }
Example #4
0
        public KeyManager(BitcoinEncryptedSecretNoEC encryptedSecret, byte[] chainCode, ExtPubKey extPubKey, bool?passwordVerified, BlockchainState blockchainState, string filePath = null)
        {
            HdPubKeys               = new List <HdPubKey>();
            HdPubKeyScriptBytes     = new List <byte[]>();
            ScriptHdPubkeyMap       = new Dictionary <Script, HdPubKey>();
            HdPubKeysLock           = new object();
            HdPubKeyScriptBytesLock = new object();
            ScriptHdPubkeyMapLock   = new object();
            BlockchainStateLock     = new object();

            EncryptedSecret = Guard.NotNull(nameof(encryptedSecret), encryptedSecret);
            ChainCode       = Guard.NotNull(nameof(chainCode), chainCode);
            ExtPubKey       = Guard.NotNull(nameof(extPubKey), extPubKey);

            PasswordVerified = passwordVerified;

            BlockchainState = blockchainState ?? new BlockchainState();

            SetFilePath(filePath);
            ToFileLock = new object();
            ToFile();
        }