mirror of
https://github.com/aljazceru/btcpayserver.git
synced 2025-12-18 14:34:23 +01:00
Open wallet with BIP21 links (#1565)
* Open wallet with BIP21 links https://i.imgur.com/IWefMKB.gifv * remove debugger; * Move to settings
This commit is contained in:
@@ -388,7 +388,7 @@ namespace BTCPayServer.Controllers
|
||||
[Route("{walletId}/send")]
|
||||
public async Task<IActionResult> WalletSend(
|
||||
[ModelBinder(typeof(WalletIdModelBinder))]
|
||||
WalletId walletId, string defaultDestination = null, string defaultAmount = null)
|
||||
WalletId walletId, string defaultDestination = null, string defaultAmount = null, string bip21 = null)
|
||||
{
|
||||
if (walletId?.StoreId == null)
|
||||
return NotFound();
|
||||
@@ -416,6 +416,10 @@ namespace BTCPayServer.Controllers
|
||||
},
|
||||
CryptoCode = walletId.CryptoCode
|
||||
};
|
||||
if (!string.IsNullOrEmpty(bip21))
|
||||
{
|
||||
LoadFromBIP21(model, bip21, network);
|
||||
}
|
||||
var feeProvider = _feeRateProvider.CreateFeeProvider(network);
|
||||
var recommendedFees =
|
||||
new[]
|
||||
@@ -1173,6 +1177,8 @@ namespace BTCPayServer.Controllers
|
||||
var store = (await Repository.FindStore(walletId.StoreId, GetUserId()));
|
||||
var vm = new WalletSettingsViewModel()
|
||||
{
|
||||
StoreName = store.StoreName,
|
||||
UriScheme = derivationSchemeSettings.Network.UriScheme,
|
||||
Label = derivationSchemeSettings.Label,
|
||||
DerivationScheme = derivationSchemeSettings.AccountDerivation.ToString(),
|
||||
DerivationSchemeInput = derivationSchemeSettings.AccountOriginal,
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Linq;
|
||||
@@ -17,6 +17,8 @@ namespace BTCPayServer.Models.WalletViewModels
|
||||
|
||||
public List<WalletSettingsAccountKeyViewModel> AccountKeys { get; set; } = new List<WalletSettingsAccountKeyViewModel>();
|
||||
public bool NBXSeedAvailable { get; set; }
|
||||
public string StoreName { get; set; }
|
||||
public string UriScheme { get; set; }
|
||||
}
|
||||
|
||||
public class WalletSettingsAccountKeyViewModel
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
<th>Store Name</th>
|
||||
<th>Crypto Code</th>
|
||||
<th>Balance</th>
|
||||
<th style="text-align:right">Actions</th>
|
||||
<th class="text-right">Actions</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@@ -47,7 +47,7 @@
|
||||
}
|
||||
<td>@wallet.CryptoCode</td>
|
||||
<td>@wallet.Balance</td>
|
||||
<td style="text-align:right">
|
||||
<td class="text-right">
|
||||
<a asp-action="WalletTransactions" asp-route-walletId="@wallet.Id">Manage</a>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
@@ -23,48 +23,50 @@
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
<form method="post" asp-action="WalletSettings">
|
||||
<input type="hidden" asp-for="StoreName"/>
|
||||
<input type="hidden" asp-for="UriScheme"/>
|
||||
<div class="form-group">
|
||||
<label asp-for="Label"></label>
|
||||
<input asp-for="Label" class="form-control" />
|
||||
<input asp-for="Label" class="form-control"/>
|
||||
<span asp-validation-for="Label" class="text-danger"></span>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label asp-for="DerivationScheme"></label>
|
||||
<input asp-for="DerivationScheme" class="form-control" readonly />
|
||||
<input asp-for="DerivationScheme" class="form-control" readonly/>
|
||||
<span asp-validation-for="DerivationScheme" class="text-danger"></span>
|
||||
</div>
|
||||
@if (!string.IsNullOrEmpty(Model.DerivationSchemeInput) && Model.DerivationSchemeInput != Model.DerivationScheme)
|
||||
{
|
||||
<div class="form-group">
|
||||
<label asp-for="DerivationSchemeInput"></label>
|
||||
<input asp-for="DerivationSchemeInput" class="form-control" readonly />
|
||||
<input asp-for="DerivationSchemeInput" class="form-control" readonly/>
|
||||
<span asp-validation-for="DerivationSchemeInput" class="text-danger"></span>
|
||||
</div>
|
||||
}
|
||||
@for (int i = 0; i < Model.AccountKeys.Count; i++)
|
||||
{
|
||||
<hr />
|
||||
<hr/>
|
||||
<h5>Account key @i</h5>
|
||||
<div class="form-group">
|
||||
<label asp-for="@Model.AccountKeys[i].AccountKey"></label>
|
||||
<input asp-for="@Model.AccountKeys[i].AccountKey" class="form-control" readonly />
|
||||
<input asp-for="@Model.AccountKeys[i].AccountKey" class="form-control" readonly/>
|
||||
<span asp-validation-for="@Model.AccountKeys[i].AccountKey" class="text-danger"></span>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label asp-for="@Model.AccountKeys[i].MasterFingerprint"></label>
|
||||
<input asp-for="@Model.AccountKeys[i].MasterFingerprint" class="form-control" />
|
||||
<input asp-for="@Model.AccountKeys[i].MasterFingerprint" class="form-control"/>
|
||||
<span asp-validation-for="@Model.AccountKeys[i].MasterFingerprint" class="text-danger"></span>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label asp-for="@Model.AccountKeys[i].AccountKeyPath"></label>
|
||||
<input asp-for="@Model.AccountKeys[i].AccountKeyPath" class="form-control" />
|
||||
<input asp-for="@Model.AccountKeys[i].AccountKeyPath" class="form-control"/>
|
||||
<span asp-validation-for="@Model.AccountKeys[i].AccountKeyPath" class="text-danger"></span>
|
||||
</div>
|
||||
@if (Model.IsMultiSig)
|
||||
{
|
||||
<div class="form-group">
|
||||
<label asp-for="SelectedSigningKey"></label>
|
||||
<input asp-for="SelectedSigningKey" type="radio" value="@Model.AccountKeys[i].AccountKey" />
|
||||
<input asp-for="SelectedSigningKey" type="radio" value="@Model.AccountKeys[i].AccountKey"/>
|
||||
</div>
|
||||
}
|
||||
}
|
||||
@@ -80,9 +82,35 @@
|
||||
{
|
||||
<button name="command" type="submit" class="dropdown-item" value="view-seed">View seed</button>
|
||||
}
|
||||
|
||||
@if (Model.UriScheme == "bitcoin")
|
||||
{
|
||||
<button type="button" class="dropdown-item register-wallet" data-storename="@Model.StoreName" data-scheme="@Model.UriScheme" data-url="@Url.Action("WalletSend", "Wallets", new {walletId = Context.GetRouteValue("walletId"), bip21 = "%s"})">Open this bitcoin wallet on payment links</button>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
$(document).ready(function(){
|
||||
if(navigator.registerProtocolHandler){
|
||||
$(".register-wallet")
|
||||
.show()
|
||||
.on("click", function(){
|
||||
var store = $(this).data("storename");
|
||||
var scheme = $(this).data("scheme");
|
||||
var url = decodeURIComponent($(this).data("url"));
|
||||
navigator.registerProtocolHandler(scheme, url, "BTCPay Wallet -" + store);
|
||||
});
|
||||
}
|
||||
});
|
||||
</script>
|
||||
<style>
|
||||
.register-wallet{
|
||||
display: none;
|
||||
}
|
||||
</style>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user