mirror of
https://github.com/btcpayserver/btcpayserver.git
synced 2024-11-19 18:11:36 +01:00
Make sure we match the user's sequence
This commit is contained in:
parent
59bdb943dd
commit
dad2642fa7
@ -392,6 +392,7 @@ namespace BTCPayServer.Tests
|
||||
lastInvoiceId = invoice.Id;
|
||||
var invoiceAddress = BitcoinAddress.Create(invoice.BitcoinAddress, cashCow.Network);
|
||||
var txBuilder = network.NBitcoinNetwork.CreateTransactionBuilder();
|
||||
txBuilder.OptInRBF = true;
|
||||
txBuilder.AddCoins(coin);
|
||||
txBuilder.Send(invoiceAddress, vector.Paid);
|
||||
txBuilder.SendFees(vector.Fee);
|
||||
@ -402,6 +403,10 @@ namespace BTCPayServer.Tests
|
||||
if (vector.ExpectedError is null)
|
||||
{
|
||||
Assert.Contains(pj.Inputs, o => o.PrevOut == receiverCoin.Outpoint);
|
||||
foreach (var input in pj.GetGlobalTransaction().Inputs)
|
||||
{
|
||||
Assert.Equal(Sequence.OptInRBF, input.Sequence);
|
||||
}
|
||||
if (!skipLockedCheck)
|
||||
Assert.True(await payjoinRepository.TryUnlock(receiverCoin.Outpoint));
|
||||
}
|
||||
|
@ -331,10 +331,13 @@ namespace BTCPayServer.Payments.PayJoin
|
||||
var ourNewOutput = newTx.Outputs[originalPaymentOutput.Index];
|
||||
HashSet<TxOut> isOurOutput = new HashSet<TxOut>();
|
||||
isOurOutput.Add(ourNewOutput);
|
||||
var rand = new Random();
|
||||
int senderInputCount = newTx.Inputs.Count;
|
||||
foreach (var selectedUTXO in selectedUTXOs.Select(o => o.Value))
|
||||
{
|
||||
contributedAmount += (Money)selectedUTXO.Value;
|
||||
newTx.Inputs.Add(selectedUTXO.Outpoint);
|
||||
var newInput = newTx.Inputs.Add(selectedUTXO.Outpoint);
|
||||
newInput.Sequence = newTx.Inputs[rand.Next(0, senderInputCount)].Sequence;
|
||||
}
|
||||
ourNewOutput.Value += contributedAmount;
|
||||
var minRelayTxFee = this._dashboard.Get(network.CryptoCode).Status.BitcoinStatus?.MinRelayTxFee ??
|
||||
@ -376,7 +379,6 @@ namespace BTCPayServer.Payments.PayJoin
|
||||
}
|
||||
}
|
||||
|
||||
var rand = new Random();
|
||||
Utils.Shuffle(newTx.Inputs, rand);
|
||||
Utils.Shuffle(newTx.Outputs, rand);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user