/// <summary>
        /// Removes given address from observation repository.
        /// If the address is not in the repository, a BusinessException is thrown.
        /// </summary>
        /// <param name="address"></param>
        /// <returns></returns>
        /// <exception cref="BusinessException"></exception>
        public async Task UnsubscribeAsync(string address)
        {
            if (!_addressValidator.IsValid(address))
            {
                throw new BusinessException(ErrorReason.InvalidAddress, "Address is invalid");
            }

            var entity = new ObservableWalletEntity()
            {
                Address = address
            };
            await _observableWalletRepository.DeleteAsync(entity);
        }
示例#2
0
        public async Task UnsubscribeBroadcastedTx(Guid operationId)
        {
            if (operationId == Guid.Empty)
            {
                throw new BusinessException(ErrorReason.BadRequest, "Operation id is invalid");
            }

            var operation = await _broadcastTxRepo.GetAsync(operationId.ToString());

            if (operation == null)
            {
                throw new BusinessException(ErrorReason.RecordNotFound, "Record not found");
            }

            await _broadcastTxRepo.DeleteAsync(operation);
        }
        public async Task UnsubscribeBroadcastedTx(Guid operationId)
        {
            if (operationId == Guid.Empty)
            {
                throw new BusinessException(ErrorReason.BadRequest, "Operation id is invalid");
            }

            var operation = await _broadcastTxRepo.GetAsync(operationId.ToString());

            if (operation == null)
            {
                throw new BusinessException(ErrorReason.RecordNotFound, "Record not found");
            }

            // Unflag outpoints as spent.
            var outpoints = GetOutpointKeysForRawTransaction(operation.EncodedTransaction);

            foreach (var outpoint in outpoints)
            {
                await _broadcastedOutpointRepo.DeleteAsync(new BroadcastedOutpoint { Value = outpoint });
            }

            await _broadcastTxRepo.DeleteAsync(operation);
        }
示例#4
0
 /// <summary>
 /// Stop watching for receiving transactions
 /// </summary>
 /// <param name="address"></param>
 /// <param name="take"></param>
 /// <param name="afterHash"></param>
 /// <returns></returns>
 public async Task UnsubscribeAddressFromHistory(string address)
 {
     _addressValidator.AssertValid(address);
     var entity = new ObservableAddressEntity(address, TxDirection.Outgoing);
     await _operationRepo.DeleteAsync(entity);
 }