Example #1
0
        public async Task ImportPrivateKeyAsync(Account account, string privateKeyWif, bool rescan, string passphrase)
        {
            if (privateKeyWif == null)
            {
                throw new ArgumentNullException(nameof(privateKeyWif));
            }
            if (passphrase == null)
            {
                throw new ArgumentNullException(nameof(passphrase));
            }

            var client  = new WalletService.WalletServiceClient(_channel);
            var request = new ImportPrivateKeyRequest
            {
                Account       = account.AccountNumber,
                PrivateKeyWif = privateKeyWif,
                Rescan        = rescan,
                Passphrase    = ByteString.CopyFromUtf8(passphrase), // Poorly named: this outputs UTF8 from a UTF16 System.String
            };
            await client.ImportPrivateKeyAsync(request, cancellationToken : _tokenSource.Token);
        }