private Task SaveWalletVotePreference(Agenda agenda, Agenda.Choice choice) { var walletClient = App.Current.Synchronizer.WalletRpcClient; var choices = new TupleValue <string, string>[] { TupleValue.Create(agenda.ID, choice.ID) }; return(walletClient.SetVoteChoicesAsync(choices)); }
public async Task <TupleValue <uint, Agenda[]> > AgendasAsync() { var client = new AgendaService.AgendaServiceClient(_channel); var request = new AgendasRequest(); var response = await client.AgendasAsync(request, cancellationToken : _tokenSource.Token); var agendas = response.Agendas.Select(a => new Agenda { ID = a.Id, Description = a.Description, Choices = a.Choices.Select(c => new Agenda.Choice { ID = c.Id, Description = c.Description, Bits = (ushort)c.Bits, IsAbstain = c.IsAbstain, IsNo = c.IsNo, }).ToArray(), Mask = (ushort)a.Mask, StartTime = DateTimeOffsetExtras.FromUnixTimeSeconds(a.StartTime), ExpireTime = DateTimeOffsetExtras.FromUnixTimeSeconds(a.ExpireTime), }).ToArray(); return(TupleValue.Create(response.Version, agendas)); }
public async Task <TupleValue <string, bool> > ImportScriptAsync(byte[] scriptBytes, bool rescan, int scanFrom, string passphrase, bool requireRedeemable) { if (scriptBytes == null) { throw new ArgumentNullException(nameof(scriptBytes)); } if (passphrase == null) { throw new ArgumentNullException(nameof(passphrase)); } var client = new WalletService.WalletServiceClient(_channel); var request = new ImportScriptRequest { Script = ByteString.CopyFrom(scriptBytes), Rescan = rescan, Passphrase = ByteString.CopyFromUtf8(passphrase), // Poorly named: this outputs UTF8 from a UTF16 System.String ScanFrom = scanFrom, RequireRedeemable = requireRedeemable, }; var resp = await client.ImportScriptAsync(request, cancellationToken : _tokenSource.Token); return(TupleValue.Create(resp.P2ShAddress, resp.Redeemable)); }
public async Task <TupleValue <string, string>[]> VoteChoicesAsync() { var client = new VotingService.VotingServiceClient(_channel); var request = new VoteChoicesRequest(); var response = await client.VoteChoicesAsync(request, cancellationToken : _tokenSource.Token); return(response.Choices.Select(c => TupleValue.Create(c.AgendaId, c.ChoiceId)).ToArray()); }
/// <summary> /// Queries the RPC server for the next external BIP0044 address for an account /// </summary> /// <param name="account">Account to create address for</param> /// <returns>Tuple containing the address and pubkey address strings</returns> public async Task <TupleValue <string, string> > NextExternalAddressAsync(Account account) { var client = new WalletService.WalletServiceClient(_channel); var request = new NextAddressRequest { Account = account.AccountNumber, Kind = NextAddressRequest.Types.Kind.Bip0044External, }; var resp = await client.NextAddressAsync(request, cancellationToken : _tokenSource.Token); return(TupleValue.Create(resp.Address, resp.PublicKey)); }
private async Task <TupleValue <uint, List <AgendaChoiceViewModel> > > FetchWalletVotingPreferences() { var walletClient = App.Current.Synchronizer.WalletRpcClient; var agendasTask = walletClient.AgendasAsync(); var choicesTask = walletClient.VoteChoicesAsync(); var agendas = await agendasTask; var choices = await choicesTask; var agendaChoices = agendas.Item2.Select(a => { var selectedAgendaChoiceID = choices.First(c => c.Item1 == a.ID).Item2; return(new AgendaChoiceViewModel(a, a.Choices.First(c => c.ID == selectedAgendaChoiceID), OnAgendaChoiceChanged)); }).ToList(); return(TupleValue.Create(agendas.Item1, agendaChoices)); }
public async Task <TupleValue <int, BlockIdentity?> > FetchHeadersAsync() { var client = new WalletLoaderService.WalletLoaderServiceClient(_channel); var request = new FetchHeadersRequest(); var response = await client.FetchHeadersAsync(request, cancellationToken : _tokenSource.Token); BlockIdentity?blockIdentity = null; if (response.FetchedHeadersCount != 0) { blockIdentity = new BlockIdentity(new Blake256Hash(response.FirstNewBlockHash.ToByteArray()), response.FirstNewBlockHeight); } return(TupleValue.Create((int)response.FetchedHeadersCount, blockIdentity)); }
private Task UpdateStakepoolVotePreferences() { var voteBits = CalculateVoteBits(); var updateTasks = ConfiguredStakePools.OfType <StakePoolSelection>() .Select(sp => { var bestApiVersion = PoolApiClient.BestSupportedApiVersion(sp.PoolInfo.SupportedApiVersions); return(TupleValue.Create(sp, bestApiVersion)); }) .Where(t => t.Item2 >= 2) .Select(t => { var sp = t.Item1; var bestApiVersion = t.Item2; var client = new PoolApiClient(bestApiVersion, sp.PoolInfo.Uri, sp.ApiToken, _httpClient); return(client.SetVoteBitsAsync(voteBits)); }); return(Task.WhenAll(updateTasks)); }
public IEnumerable <TupleValue <Account, AccountProperties> > EnumerateAccounts() { return(_bip0032Accounts.Select((p, i) => TupleValue.Create(new Account((uint)i), p)) .Concat(new[] { TupleValue.Create(new Account(ImportedAccountNumber), _importedAccount) })); }