private async Task AcceptorPaymentSpent( ICurrencySwap currencySwap, SwapEventArgs swapArgs, CancellationToken cancellationToken = default) { var swap = swapArgs.Swap; Log.Debug("Acceptor payment spent event for swap {@swapId}", swap.Id); try { // redeem by acceptor async (using purchased currency protocol) if (swap.IsAcceptor && swap.IsSoldCurrency(currencySwap.Currency) && swap.RewardForRedeem == 0) { await GetCurrencySwap(swap.PurchasedCurrency) .RedeemAsync(swap, cancellationToken) .ConfigureAwait(false); } } catch (Exception e) { Log.Error(e, "Acceptor payment spent handler error"); } }
private async Task AcceptorPaymentConfirmed( ICurrencySwap currencySwap, SwapEventArgs swapArgs, CancellationToken cancellationToken = default) { var swap = swapArgs.Swap; Log.Debug("Acceptor payment confirmed event for swap {@swapId}", swap.Id); try { // party redeem if (swap.IsInitiator && swap.IsPurchasedCurrency(currencySwap.Currency) && swap.PartyRewardForRedeem > 0) // todo: user param >= 2*RedeemFee { await GetCurrencySwap(swap.SoldCurrency) .RedeemForPartyAsync(swap, cancellationToken) .ConfigureAwait(false); } } catch (Exception e) { Log.Error(e, "Acceptor payment confirmed handler error"); } }
private async void InitiatorPaymentConfirmed( ICurrencySwap currencySwap, SwapEventArgs swapArgs) { var swap = swapArgs.Swap; Log.Debug("Initiator payment confirmed event for swap {@swapId}", swap.Id); try { // broadcast acceptor's payment tx (using sold currency protocol) if (swap.IsAcceptor && swap.IsPurchasedCurrency(currencySwap.Currency)) { await GetCurrencySwap(swap.SoldCurrency) .BroadcastPaymentAsync(swap) .ConfigureAwait(false); // wait for redeem by other party or someone else if (swap.RewardForRedeem > 0) { await GetCurrencySwap(swap.PurchasedCurrency) .WaitForRedeemAsync(swap) .ConfigureAwait(false); } } } catch (Exception e) { Log.Error(e, "Initiator payment confirmed handler error"); } }
private async Task InitiatorPaymentConfirmed( ICurrencySwap currencySwap, SwapEventArgs swapArgs, CancellationToken cancellationToken = default) { var swap = swapArgs.Swap; Log.Debug("Initiator payment confirmed event for swap {@swapId}", swap.Id); try { // broadcast acceptors payment tx (using sold currency protocol) if (swap.IsAcceptor && swap.IsPurchasedCurrency(currencySwap.Currency)) { await GetCurrencySwap(swap.SoldCurrency) .PayAsync(swap, cancellationToken) .ConfigureAwait(false); if (swap.StateFlags.HasFlag(SwapStateFlags.IsPaymentBroadcast)) { // start redeem control async await GetCurrencySwap(swap.SoldCurrency) .StartWaitForRedeemAsync(swap, cancellationToken) .ConfigureAwait(false); } // wait for redeem by other party or someone else if (swap.RewardForRedeem > 0) { await GetCurrencySwap(swap.PurchasedCurrency) .StartWaitForRedeemBySomeoneAsync(swap, cancellationToken) .ConfigureAwait(false); } } } catch (Exception e) { Log.Error(e, "Initiator payment confirmed handler error"); } }