public async Task <bool> SignAsync( IAddressResolver addressResolver, IKeyStorage keyStorage, IEnumerable <ITxOutput> spentOutputs, CancellationToken cancellationToken = default(CancellationToken)) { if (spentOutputs == null) { throw new ArgumentNullException(nameof(spentOutputs)); } foreach (var spentOutput in spentOutputs) { var address = spentOutput.DestinationAddress(Currency); var walletAddress = await addressResolver .ResolveAddressAsync( currency : Currency, address : address, cancellationToken : cancellationToken) .ConfigureAwait(false); if (walletAddress?.KeyIndex == null) { Log.Error($"Can't find private key for address {address}"); return(false); } Sign(keyStorage.GetPrivateKey(Currency, walletAddress.KeyIndex), spentOutput); } return(true); }
public async Task ResolveAddressAsync__GetSelfAddress_EnsureAddressResolved() { var feed = IPAddress.Loopback; var expected = new AddressResolvedResult( StatusCode.Success, true, IPAddress.Loopback, RegionInfo.CurrentRegion); var actual = await _addressResolver.ResolveAddressAsync(feed); Assert.AreEqual(expected, actual); }