RBF on by default, can disable it in Wallet Send /advanced settings.

This commit is contained in:
nicolas.dorier
2019-05-08 15:24:20 +09:00
parent 3a05f7e294
commit d7fc079376
8 changed files with 28 additions and 5 deletions

View File

@@ -64,6 +64,7 @@ namespace BTCPayServer
public KeyPath CoinType { get; internal set; } public KeyPath CoinType { get; internal set; }
public int MaxTrackedConfirmation { get; internal set; } = 6; public int MaxTrackedConfirmation { get; internal set; } = 6;
public string[] DefaultRateRules { get; internal set; } = Array.Empty<string>(); public string[] DefaultRateRules { get; internal set; } = Array.Empty<string>();
public bool SupportRBF { get; internal set; }
public override string ToString() public override string ToString()
{ {

View File

@@ -25,7 +25,8 @@ namespace BTCPayServer
CryptoImagePath = "imlegacy/bitcoin.svg", CryptoImagePath = "imlegacy/bitcoin.svg",
LightningImagePath = "imlegacy/bitcoin-lightning.svg", LightningImagePath = "imlegacy/bitcoin-lightning.svg",
DefaultSettings = BTCPayDefaultSettings.GetDefaultSettings(NetworkType), DefaultSettings = BTCPayDefaultSettings.GetDefaultSettings(NetworkType),
CoinType = NetworkType == NetworkType.Mainnet ? new KeyPath("0'") : new KeyPath("1'") CoinType = NetworkType == NetworkType.Mainnet ? new KeyPath("0'") : new KeyPath("1'"),
SupportRBF = true
}); });
} }
} }

View File

@@ -175,7 +175,7 @@ namespace BTCPayServer.Controllers
model.CurrentBalance = (await balance).ToDecimal(MoneyUnit.BTC); model.CurrentBalance = (await balance).ToDecimal(MoneyUnit.BTC);
model.RecommendedSatoshiPerByte = (int)(await recommendedFees).GetFee(1).Satoshi; model.RecommendedSatoshiPerByte = (int)(await recommendedFees).GetFee(1).Satoshi;
model.FeeSatoshiPerByte = model.RecommendedSatoshiPerByte; model.FeeSatoshiPerByte = model.RecommendedSatoshiPerByte;
model.SupportRBF = network.SupportRBF;
using (CancellationTokenSource cts = new CancellationTokenSource()) using (CancellationTokenSource cts = new CancellationTokenSource())
{ {
try try
@@ -212,7 +212,7 @@ namespace BTCPayServer.Controllers
var network = this.NetworkProvider.GetNetwork(walletId?.CryptoCode); var network = this.NetworkProvider.GetNetwork(walletId?.CryptoCode);
if (network == null) if (network == null)
return NotFound(); return NotFound();
vm.SupportRBF = network.SupportRBF;
var destination = ParseDestination(vm.Destination, network.NBitcoinNetwork); var destination = ParseDestination(vm.Destination, network.NBitcoinNetwork);
if (destination == null) if (destination == null)
ModelState.AddModelError(nameof(vm.Destination), "Invalid address"); ModelState.AddModelError(nameof(vm.Destination), "Invalid address");
@@ -233,7 +233,8 @@ namespace BTCPayServer.Controllers
Amount = vm.Amount.Value, Amount = vm.Amount.Value,
SubstractFees = vm.SubstractFees, SubstractFees = vm.SubstractFees,
FeeSatoshiPerByte = vm.FeeSatoshiPerByte, FeeSatoshiPerByte = vm.FeeSatoshiPerByte,
NoChange = vm.NoChange NoChange = vm.NoChange,
DisableRBF = vm.DisableRBF
}; };
if (command == "ledger") if (command == "ledger")
{ {
@@ -254,6 +255,10 @@ namespace BTCPayServer.Controllers
CreatePSBTRequest psbtRequest = new CreatePSBTRequest(); CreatePSBTRequest psbtRequest = new CreatePSBTRequest();
CreatePSBTDestination psbtDestination = new CreatePSBTDestination(); CreatePSBTDestination psbtDestination = new CreatePSBTDestination();
psbtRequest.Destinations.Add(psbtDestination); psbtRequest.Destinations.Add(psbtDestination);
if (network.SupportRBF)
{
psbtRequest.RBF = !sendModel.DisableRBF;
}
psbtDestination.Destination = BitcoinAddress.Create(sendModel.Destination, network.NBitcoinNetwork); psbtDestination.Destination = BitcoinAddress.Create(sendModel.Destination, network.NBitcoinNetwork);
psbtDestination.Amount = Money.Coins(sendModel.Amount); psbtDestination.Amount = Money.Coins(sendModel.Amount);
psbtRequest.FeePreference = new FeePreference(); psbtRequest.FeePreference = new FeePreference();
@@ -447,7 +452,7 @@ namespace BTCPayServer.Controllers
int account = 0, int account = 0,
// sendtoaddress // sendtoaddress
bool noChange = false, bool noChange = false,
string destination = null, string amount = null, string feeRate = null, bool substractFees = false string destination = null, string amount = null, string feeRate = null, bool substractFees = false, bool disableRBF = false
) )
{ {
if (!HttpContext.WebSockets.IsWebSocketRequest) if (!HttpContext.WebSockets.IsWebSocketRequest)
@@ -511,6 +516,7 @@ namespace BTCPayServer.Controllers
model.SubstractFees = substractFees; model.SubstractFees = substractFees;
model.NoChange = noChange; model.NoChange = noChange;
model.DisableRBF = disableRBF;
if (command == "test") if (command == "test")
{ {
result = await hw.Test(normalOperationTimeout.Token); result = await hw.Test(normalOperationTimeout.Token);

View File

@@ -9,6 +9,7 @@ namespace BTCPayServer.Models.WalletViewModels
{ {
public int FeeSatoshiPerByte { get; set; } public int FeeSatoshiPerByte { get; set; }
public bool SubstractFees { get; set; } public bool SubstractFees { get; set; }
public bool DisableRBF { get; set; }
public decimal Amount { get; set; } public decimal Amount { get; set; }
public string Destination { get; set; } public string Destination { get; set; }
public bool NoChange { get; set; } public bool NoChange { get; set; }

View File

@@ -35,5 +35,8 @@ namespace BTCPayServer.Models.WalletViewModels
public int Divisibility { get; set; } public int Divisibility { get; set; }
public string Fiat { get; set; } public string Fiat { get; set; }
public string RateError { get; set; } public string RateError { get; set; }
public bool SupportRBF { get; set; }
[Display(Name = "Disable RBF")]
public bool DisableRBF { get; set; }
} }
} }

View File

@@ -71,6 +71,14 @@
<a href="https://docs.btcpayserver.org/features/wallet#make-sure-no-change-utxo-is-created-expert-mode" target="_blank"><span class="fa fa-question-circle-o" title="More information..."></span></a> <a href="https://docs.btcpayserver.org/features/wallet#make-sure-no-change-utxo-is-created-expert-mode" target="_blank"><span class="fa fa-question-circle-o" title="More information..."></span></a>
<input asp-for="NoChange" class="form-check" /> <input asp-for="NoChange" class="form-check" />
</div> </div>
@if (Model.SupportRBF)
{
<div class="form-group">
<label asp-for="DisableRBF"></label>
<a href="https://bitcoin.org/en/glossary/rbf" target="_blank"><span class="fa fa-question-circle-o" title="More information..."></span></a>
<input asp-for="DisableRBF" class="form-check" />
</div>
}
</div> </div>
</div> </div>
</div> </div>

View File

@@ -15,6 +15,7 @@
<input type="hidden" asp-for="Destination" /> <input type="hidden" asp-for="Destination" />
<input type="hidden" asp-for="Amount" /> <input type="hidden" asp-for="Amount" />
<input type="hidden" asp-for="FeeSatoshiPerByte" /> <input type="hidden" asp-for="FeeSatoshiPerByte" />
<input type="hidden" asp-for="DisableRBF" />
<input type="hidden" asp-for="SubstractFees" /> <input type="hidden" asp-for="SubstractFees" />
<input type="hidden" asp-for="NoChange" /> <input type="hidden" asp-for="NoChange" />
<p> <p>

View File

@@ -4,6 +4,7 @@
var fee = $("#FeeSatoshiPerByte").val(); var fee = $("#FeeSatoshiPerByte").val();
var substractFee = $("#SubstractFees").val(); var substractFee = $("#SubstractFees").val();
var noChange = $("#NoChange").val(); var noChange = $("#NoChange").val();
var disableRBF = $("#DisableRBF").val();
var loc = window.location, ws_uri; var loc = window.location, ws_uri;
if (loc.protocol === "https:") { if (loc.protocol === "https:") {
@@ -48,6 +49,7 @@
args += "&feeRate=" + fee; args += "&feeRate=" + fee;
args += "&substractFees=" + substractFee; args += "&substractFees=" + substractFee;
args += "&noChange=" + noChange; args += "&noChange=" + noChange;
args += "&disableRBF=" + disableRBF;
if (noChange === "True") { if (noChange === "True") {
WriteAlert("warning", 'WARNING: Because you want to make sure no change UTXO is created, you will end up sending more than the chosen amount to your destination. Please validate the transaction on your ledger'); WriteAlert("warning", 'WARNING: Because you want to make sure no change UTXO is created, you will end up sending more than the chosen amount to your destination. Please validate the transaction on your ledger');