Compare commits

...

8 Commits

Author SHA1 Message Date
34755b32dc bump 2020-04-19 02:09:12 +09:00
6679ee1ca2 Merge pull request #1472 from Kukks/payjoin/p2shfixes
Fix Payjoin p2sh
2020-04-19 02:01:10 +09:00
0077105a2d remove hacks 2020-04-18 08:29:07 +02:00
51db617584 fixes 2020-04-18 08:09:49 +02:00
514b695907 fix coin addition for p2sh 2020-04-18 08:09:49 +02:00
b470ce2dad fix p2sh test error codes 2020-04-18 08:09:49 +02:00
161850150a fix p2sh detection input 2020-04-18 08:09:49 +02:00
b02cfa9d41 fix subtract fees auto tick when clicking on balance 2020-04-17 15:24:27 +02:00
6 changed files with 22 additions and 11 deletions

View File

@ -5,7 +5,7 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="NBitcoin" Version="5.0.29" />
<PackageReference Include="NBitcoin" Version="5.0.30" />
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
</ItemGroup>

View File

@ -141,8 +141,14 @@ namespace BTCPayServer.Tests
var receiverCoin = await receiverUser.ReceiveUTXO(Money.Satoshis(810), network);
var clientShouldError = unsupportedFormats.Contains(senderAddressType);
var errorCode = ( unsupportedFormats.Contains( receiverAddressType) || receiverAddressType != senderAddressType)? "unsupported-inputs" : null;
string errorCode = null;
if (unsupportedFormats.Contains(receiverAddressType))
{
errorCode = "unsupported-inputs";
}else if (receiverAddressType != senderAddressType)
{
errorCode = "out-of-utxos";
}
var invoice = receiverUser.BitPay.CreateInvoice(new Invoice() {Price = 50000, Currency = "sats", FullNotifications = true});
var invoiceAddress = BitcoinAddress.Create(invoice.BitcoinAddress, cashCow.Network);

View File

@ -19,7 +19,6 @@ using NBXplorer;
using NBXplorer.Models;
using Newtonsoft.Json.Linq;
using NicolasDorier.RateLimits;
using Microsoft.Extensions.Logging;
using NBXplorer.DerivationStrategy;
using System.Diagnostics.CodeAnalysis;
@ -384,8 +383,8 @@ 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()));
txBuilder.AddCoins(psbt.Inputs.Select(i => i.GetSignableCoin()));
txBuilder.AddCoins(selectedUTXOs.Select(o => o.Value.AsCoin(derivationSchemeSettings.AccountDerivation)));
Money expectedFee = txBuilder.EstimateFees(newTx, originalFeeRate);
Money actualFee = newTx.GetFee(txBuilder.FindSpentCoins(newTx));
Money additionalFee = expectedFee - actualFee;
@ -440,7 +439,8 @@ namespace BTCPayServer.Payments.PayJoin
foreach (var selectedUtxo in selectedUTXOs.Select(o => o.Value))
{
var signedInput = newPsbt.Inputs.FindIndexedInput(selectedUtxo.Outpoint);
signedInput.UpdateFromCoin(selectedUtxo.AsCoin());
var coin = selectedUtxo.AsCoin(derivationSchemeSettings.AccountDerivation);
signedInput.UpdateFromCoin(coin);
var privateKey = accountKey.Derive(selectedUtxo.KeyPath).PrivateKey;
signedInput.Sign(privateKey);
signedInput.FinalizeInput();

View File

@ -34,9 +34,9 @@ namespace BTCPayServer.Services
if (i.WitnessUtxo.ScriptPubKey.IsScriptType(ScriptType.P2WPKH))
return ScriptPubKeyType.Segwit;
if (i.WitnessUtxo.ScriptPubKey.IsScriptType(ScriptType.P2SH) &&
i.FinalScriptWitness.ToScript().IsScriptType(ScriptType.P2WPKH))
PayToWitPubKeyHashTemplate.Instance.ExtractWitScriptParameters(i.FinalScriptWitness) is {})
return ScriptPubKeyType.SegwitP2SH;
return null as ScriptPubKeyType?;
return null;
}
}
@ -212,8 +212,10 @@ namespace BTCPayServer.Services
if (sentAfter > sentBefore)
{
var overPaying = sentAfter - sentBefore;
if (!newPSBT.TryGetEstimatedFeeRate(out var newFeeRate) || !newPSBT.TryGetVirtualSize(out var newVirtualSize))
throw new PayjoinSenderException("The payjoin receiver did not included UTXO information to calculate fee correctly");
var additionalFee = newPSBT.GetFee() - originalFee;
if (overPaying > additionalFee)
throw new PayjoinSenderException("The payjoin receiver is sending more money to himself");

View File

@ -38,7 +38,10 @@ $(function () {
var parentContainer = $(this).parents(".form-group");
var outputAmountElement = parentContainer.find(".output-amount");
outputAmountElement.val(val);
parentContainer.find(".subtract-fees").prop('checked', true);
var subtractFeesEl = parentContainer.find(".subtract-fees");
if(subtractFeesEl.length === 0)
subtractFeesEl = $(".subtract-fees");
subtractFeesEl.prop('checked', true);
updateFiatValue(outputAmountElement);
return false;
});

View File

@ -1,5 +1,5 @@
<Project>
<PropertyGroup>
<Version>1.0.4.0</Version>
<Version>1.0.4.1</Version>
</PropertyGroup>
</Project>