예제 #1
0
        public bool AddKeySet(string walletName, HDKeySet keyset)
        {
            KeySetData data = new KeySetData
            {
                KeySet = keyset,
                State  = new HDKeyState()
            };

            return(KeySetTable.GetChild(walletName).Create(keyset.Name, data, false));
        }
        public async Task <bool> CreateKeySetIfNotExists(string walletName, HDKeySet keyset)
        {
            try
            {
                await Post <HDKeySet>("wallets/" + EscapeUrlPart(walletName) + "/keysets", keyset).ConfigureAwait(false);

                return(true);
            }
            catch (QBitNinjaException ex)
            {
                if (ex.StatusCode == 409)
                {
                    return(false);
                }
                throw;
            }
        }
예제 #3
0
        protected override async Task CreateTask(System.Threading.CancellationToken cancelation)
        {
            HDKeySet keyset = new HDKeySet();

            keyset.Name           = Name;
            keyset.Path           = String.IsNullOrWhiteSpace(KeyPath) ? null : new KeyPath(KeyPath);
            keyset.SignatureCount = SignatureCount;
            keyset.ExtPubKeys
                =
                    ExtPubKeys
                    .Select(_ => new BitcoinExtPubKey(_.Value, _Network))
                    .ToArray();

            var client = _Parent._Parent.ClientFactory.CreateClient();
            await client.CreateKeySet(_Parent.Name, keyset);

            Info("Keyset created");
            _Parent.Refresh.Execute(false);
        }
예제 #4
0
        public HDKeySet CreateKeyset(string walletName, [FromBody] HDKeySet keyset)
        {
            AssertValidUrlPart(keyset.Name, "Keyset name");
            if (keyset.ExtPubKeys == null || keyset.ExtPubKeys.Length == 0)
            {
                throw Error(400, "ExtPubKeys not specified");
            }
            if (keyset.ExtPubKeys.Length < keyset.SignatureCount)
            {
                throw Error(400, "SignatureCount should not be higher than the number of HD Keys");
            }
            if (keyset.Path != null && keyset.Path.ToString().Contains("'"))
            {
                throw Error(400, "The keypath should not contains hardened children");
            }
            var repo = Configuration.CreateWalletRepository();

            if (!repo.AddKeySet(walletName, keyset))
            {
                throw Error(409, "Keyset already exists");
            }
            return(keyset);
        }
예제 #5
0
        public HDKeySet CreateKeyset(string walletName, [FromBody] HDKeySet keyset)
        {
            AssertValidUrlPart(keyset.Name, "Keyset name");
            if (keyset.ExtPubKeys == null || keyset.ExtPubKeys.Length == 0)
            {
                throw Error(400, "ExtPubKeys not specified");
            }
            if (keyset.ExtPubKeys.Length < keyset.SignatureCount)
            {
                throw Error(400, "SignatureCount should not be higher than the number of HD Keys");
            }
            if (keyset.Path != null && keyset.Path.ToString().Contains("'"))
            {
                throw Error(400, "The keypath should not contains hardened children");
            }
            var repo = Configuration.CreateWalletRepository();

            KeySetData keysetData = new KeySetData
            {
                KeySet = keyset,
                State  = new HDKeyState()
            };

            if (!repo.AddKeySet(walletName, keysetData))
            {
                throw Error(409, "Keyset already exists");
            }

            var newAddresses = repo.Scan(walletName, keysetData, 0, 20);

            foreach (var addresses in newAddresses.Partition(20))
            {
                var unused = Configuration.Topics.AddedAddresses.AddAsync(addresses.ToArray());
            }
            return(keyset);
        }
 public Task <bool> CreateIfNotExists(HDKeySet keyset)
 {
     keyset.Name = Name;
     return(Client.CreateKeySetIfNotExists(Wallet.Name, keyset));
 }
 public Task <HDKeySet> Create(HDKeySet keyset)
 {
     keyset.Name = Name;
     return(Client.CreateKeySet(Wallet.Name, keyset));
 }
 public Task <HDKeySet> CreateKeySet(string walletName, HDKeySet keyset)
 {
     return(Post <HDKeySet>("wallets/" + EscapeUrlPart(walletName) + "/keysets", keyset));
 }