private async Task <IBitcoinBasedTransaction> CreateRedeemTxAsync( Swap swap, IBitcoinBasedTransaction paymentTx, string redeemAddress, byte[] redeemScript, bool increaseSequenceNumber = false) { Log.Debug("Create redeem tx for swap {@swapId}", swap.Id); var currency = Currencies.Get <BitcoinBasedConfig>(Currency); var amountInSatoshi = currency.CoinToSatoshi( AmountHelper.QtyToSellAmount( swap.Side.Opposite(), swap.Qty, swap.Price, currency.DigitsMultiplier)); var sequenceNumber = 0u; if (increaseSequenceNumber) { var previousSequenceNumber = (swap?.RedeemTx as IBitcoinBasedTransaction)?.GetSequenceNumber(0) ?? 0; sequenceNumber = previousSequenceNumber == 0 ? Sequence.SEQUENCE_FINAL - 1024 : (previousSequenceNumber == Sequence.SEQUENCE_FINAL ? Sequence.SEQUENCE_FINAL : previousSequenceNumber + 1); } var tx = await _transactionFactory .CreateSwapRedeemTxAsync( paymentTx : paymentTx, amount : amountInSatoshi, redeemAddress : redeemAddress, redeemScript : redeemScript, currency : currency, sequenceNumber : sequenceNumber) .ConfigureAwait(false); if (tx == null) { throw new InternalException( code: Errors.TransactionCreationError, description: $"Redeem tx creation error for swap {swap.Id}"); } tx.Type = BlockchainTransactionType.Output | BlockchainTransactionType.SwapRedeem; return(tx); }
private async Task <IBitcoinBasedTransaction> CreateRedeemTxAsync( ClientSwap swap, IBitcoinBasedTransaction paymentTx, string redeemAddress) { Log.Debug("Create redeem tx for swap {@swapId}", swap.Id); var tx = await _transactionFactory .CreateSwapRedeemTxAsync( paymentTx : paymentTx, swap : swap, redeemAddress : redeemAddress) .ConfigureAwait(false); if (tx == null) { throw new InternalException( code: Errors.TransactionCreationError, description: $"Redeem tx creation error for swap {swap.Id}"); } return(tx); }