diff --git a/BTCPayServer/Payments/PayJoin/PayJoinEndpointController.cs b/BTCPayServer/Payments/PayJoin/PayJoinEndpointController.cs index 4a80f0087..4e3337302 100644 --- a/BTCPayServer/Payments/PayJoin/PayJoinEndpointController.cs +++ b/BTCPayServer/Payments/PayJoin/PayJoinEndpointController.cs @@ -350,13 +350,12 @@ namespace BTCPayServer.Payments.PayJoin && feeOutputIndex < newTx.Outputs.Count && !isOurOutput.Contains(newTx.Outputs[feeOutputIndex]) ? newTx.Outputs[feeOutputIndex] : null; - var rand = new Random(); int senderInputCount = newTx.Inputs.Count; foreach (var selectedUTXO in selectedUTXOs.Select(o => o.Value)) { contributedAmount += (Money)selectedUTXO.Value; var newInput = newTx.Inputs.Add(selectedUTXO.Outpoint); - newInput.Sequence = newTx.Inputs[rand.Next(0, senderInputCount)].Sequence; + newInput.Sequence = newTx.Inputs[(int)(RandomUtils.GetUInt32() % senderInputCount)].Sequence; } ourNewOutput.Value += contributedAmount; var minRelayTxFee = this._dashboard.Get(network.CryptoCode).Status.BitcoinStatus?.MinRelayTxFee ?? diff --git a/BTCPayServer/Security/Bitpay/TokenRepository.cs b/BTCPayServer/Security/Bitpay/TokenRepository.cs index c2a72a107..44f06510d 100644 --- a/BTCPayServer/Security/Bitpay/TokenRepository.cs +++ b/BTCPayServer/Security/Bitpay/TokenRepository.cs @@ -52,11 +52,10 @@ namespace BTCPayServer.Security.Bitpay // It is legacy support and Bitpay generate string of unknown format, trying to replicate them // as good as possible. The string below got generated for me. var chars = "ERo0vkBMOYhyU0ZHvirCplbLDIGWPdi1ok77VnW7QdE"; - var rand = new Random(Math.Abs(RandomUtils.GetInt32())); var generated = new char[chars.Length]; for (int i = 0; i < generated.Length; i++) { - generated[i] = chars[rand.Next(0, generated.Length)]; + generated[i] = chars[(int)(RandomUtils.GetUInt32() % generated.Length)]; } using (var ctx = _Factory.CreateContext())