コード例 #1
0
ファイル: WalletMultisig.cs プロジェクト: xrhodium/blockcore
        /// <summary>
        /// Creates an account as expected in bip-44 account structure.
        /// </summary>
        /// <param name="chainCode"></param>
        /// <param name="network"></param>
        /// <param name="accountCreationTime"></param>
        /// <returns></returns>
        public HdAccountMultisig AddNewAccount(MultisigScheme multisigScheme, int coinType, Network network, DateTimeOffset accountCreationTime)
        {
            // Get the current collection of accounts.
            var accounts = this.AccountsRoot.FirstOrDefault().Accounts;

            this.AccountsRoot.FirstOrDefault().LastBlockSyncedHash   = network.GenesisHash;
            this.AccountsRoot.FirstOrDefault().LastBlockSyncedHeight = 0;

            int newAccountIndex = 0;

            if (accounts.Any())
            {
                newAccountIndex = accounts.Max(a => a.Index) + 1;
            }

            string accountHdPath = $"m/44'/{(int)coinType}'/{newAccountIndex}'";

            var newAccount = new HdAccountMultisig(multisigScheme)
            {
                Index             = newAccountIndex,
                ExternalAddresses = new List <HdAddress>(),
                InternalAddresses = new List <HdAddress>(),
                Name         = $"account {newAccountIndex}",
                HdPath       = accountHdPath,
                CreationTime = accountCreationTime
            };

            accounts.Add(newAccount);

            return(newAccount);
        }
コード例 #2
0
ファイル: WalletMultisig.cs プロジェクト: xrhodium/blockcore
 /// <summary>
 /// Adds an account to the current wallet.
 /// </summary>
 /// <remarks>
 /// The name given to the account is of the form "account (i)" by default, where (i) is an incremental index starting at 0.
 /// According to BIP44, an account at index (i) can only be created when the account at index (i - 1) contains at least one transaction.
 /// </remarks>
 /// <seealso cref="https://github.com/bitcoin/bips/blob/master/bip-0044.mediawiki"/>
 /// <param name="password">The password used to decrypt the wallet's <see cref="EncryptedSeed"/>.</param>
 /// <param name="coinType">The type of coin this account is for.</param>
 /// <param name="accountCreationTime">Creation time of the account to be created.</param>
 /// <returns>A new HD account.</returns>
 public HdAccountMultisig AddNewAccount(MultisigScheme scheme, int coinType, DateTimeOffset accountCreationTime)
 {
     return(AddNewAccount(scheme, coinType, this.Network, accountCreationTime));
 }
コード例 #3
0
ファイル: WalletMultisig.cs プロジェクト: xrhodium/blockcore
 public HdAccountMultisig(MultisigScheme scheme)
 {
     this.ExtendedPubKey = "N/A";
     this.MultisigScheme = scheme;
 }