mirror of
https://github.com/btcpayserver/btcpayserver.git
synced 2025-02-22 06:21:44 +01:00
fix coin addition for p2sh
This commit is contained in:
parent
b470ce2dad
commit
514b695907
1 changed files with 13 additions and 2 deletions
|
@ -22,6 +22,7 @@ using NicolasDorier.RateLimits;
|
|||
using Microsoft.Extensions.Logging;
|
||||
using NBXplorer.DerivationStrategy;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using BTCPayServer.Logging;
|
||||
|
||||
namespace BTCPayServer.Payments.PayJoin
|
||||
{
|
||||
|
@ -384,8 +385,18 @@ namespace BTCPayServer.Payments.PayJoin
|
|||
Money ourFeeContribution = Money.Zero;
|
||||
// We need to adjust the fee to keep a constant fee rate
|
||||
var txBuilder = network.NBitcoinNetwork.CreateTransactionBuilder();
|
||||
txBuilder.AddCoins(psbt.Inputs.Select(i => i.GetCoin()));
|
||||
txBuilder.AddCoins(selectedUTXOs.Select(o => o.Value.AsCoin()));
|
||||
var coins = new List<Coin>();
|
||||
if (sendersInputType != ScriptPubKeyType.SegwitP2SH)
|
||||
{
|
||||
coins.AddRange(psbt.Inputs.Select(i => i.GetCoin()));
|
||||
coins.AddRange(selectedUTXOs.Select(o => o.Value.AsCoin()));
|
||||
}
|
||||
else
|
||||
{
|
||||
coins.AddRange(psbt.Inputs.Select(i =>i.GetCoin().ToScriptCoin(PayToScriptHashTemplate.Instance.ExtractScriptSigParameters(i.FinalScriptSig).RedeemScript)));
|
||||
coins.AddRange(selectedUTXOs.Select(pair => pair.Value.AsCoin(derivationSchemeSettings.AccountDerivation)));
|
||||
}
|
||||
txBuilder.AddCoins(coins);
|
||||
Money expectedFee = txBuilder.EstimateFees(newTx, originalFeeRate);
|
||||
Money actualFee = newTx.GetFee(txBuilder.FindSpentCoins(newTx));
|
||||
Money additionalFee = expectedFee - actualFee;
|
||||
|
|
Loading…
Add table
Reference in a new issue