mirror of
https://github.com/aljazceru/btcpayserver.git
synced 2025-12-17 22:14:26 +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")]
|
[Route("{walletId}/send")]
|
||||||
public async Task<IActionResult> WalletSend(
|
public async Task<IActionResult> WalletSend(
|
||||||
[ModelBinder(typeof(WalletIdModelBinder))]
|
[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)
|
if (walletId?.StoreId == null)
|
||||||
return NotFound();
|
return NotFound();
|
||||||
@@ -416,6 +416,10 @@ namespace BTCPayServer.Controllers
|
|||||||
},
|
},
|
||||||
CryptoCode = walletId.CryptoCode
|
CryptoCode = walletId.CryptoCode
|
||||||
};
|
};
|
||||||
|
if (!string.IsNullOrEmpty(bip21))
|
||||||
|
{
|
||||||
|
LoadFromBIP21(model, bip21, network);
|
||||||
|
}
|
||||||
var feeProvider = _feeRateProvider.CreateFeeProvider(network);
|
var feeProvider = _feeRateProvider.CreateFeeProvider(network);
|
||||||
var recommendedFees =
|
var recommendedFees =
|
||||||
new[]
|
new[]
|
||||||
@@ -1173,6 +1177,8 @@ namespace BTCPayServer.Controllers
|
|||||||
var store = (await Repository.FindStore(walletId.StoreId, GetUserId()));
|
var store = (await Repository.FindStore(walletId.StoreId, GetUserId()));
|
||||||
var vm = new WalletSettingsViewModel()
|
var vm = new WalletSettingsViewModel()
|
||||||
{
|
{
|
||||||
|
StoreName = store.StoreName,
|
||||||
|
UriScheme = derivationSchemeSettings.Network.UriScheme,
|
||||||
Label = derivationSchemeSettings.Label,
|
Label = derivationSchemeSettings.Label,
|
||||||
DerivationScheme = derivationSchemeSettings.AccountDerivation.ToString(),
|
DerivationScheme = derivationSchemeSettings.AccountDerivation.ToString(),
|
||||||
DerivationSchemeInput = derivationSchemeSettings.AccountOriginal,
|
DerivationSchemeInput = derivationSchemeSettings.AccountOriginal,
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.ComponentModel.DataAnnotations;
|
using System.ComponentModel.DataAnnotations;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
@@ -17,6 +17,8 @@ namespace BTCPayServer.Models.WalletViewModels
|
|||||||
|
|
||||||
public List<WalletSettingsAccountKeyViewModel> AccountKeys { get; set; } = new List<WalletSettingsAccountKeyViewModel>();
|
public List<WalletSettingsAccountKeyViewModel> AccountKeys { get; set; } = new List<WalletSettingsAccountKeyViewModel>();
|
||||||
public bool NBXSeedAvailable { get; set; }
|
public bool NBXSeedAvailable { get; set; }
|
||||||
|
public string StoreName { get; set; }
|
||||||
|
public string UriScheme { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class WalletSettingsAccountKeyViewModel
|
public class WalletSettingsAccountKeyViewModel
|
||||||
|
|||||||
@@ -30,7 +30,7 @@
|
|||||||
<th>Store Name</th>
|
<th>Store Name</th>
|
||||||
<th>Crypto Code</th>
|
<th>Crypto Code</th>
|
||||||
<th>Balance</th>
|
<th>Balance</th>
|
||||||
<th style="text-align:right">Actions</th>
|
<th class="text-right">Actions</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
@@ -47,7 +47,7 @@
|
|||||||
}
|
}
|
||||||
<td>@wallet.CryptoCode</td>
|
<td>@wallet.CryptoCode</td>
|
||||||
<td>@wallet.Balance</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>
|
<a asp-action="WalletTransactions" asp-route-walletId="@wallet.Id">Manage</a>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|||||||
@@ -23,48 +23,50 @@
|
|||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-md-6">
|
<div class="col-md-6">
|
||||||
<form method="post" asp-action="WalletSettings">
|
<form method="post" asp-action="WalletSettings">
|
||||||
|
<input type="hidden" asp-for="StoreName"/>
|
||||||
|
<input type="hidden" asp-for="UriScheme"/>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label asp-for="Label"></label>
|
<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>
|
<span asp-validation-for="Label" class="text-danger"></span>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label asp-for="DerivationScheme"></label>
|
<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>
|
<span asp-validation-for="DerivationScheme" class="text-danger"></span>
|
||||||
</div>
|
</div>
|
||||||
@if (!string.IsNullOrEmpty(Model.DerivationSchemeInput) && Model.DerivationSchemeInput != Model.DerivationScheme)
|
@if (!string.IsNullOrEmpty(Model.DerivationSchemeInput) && Model.DerivationSchemeInput != Model.DerivationScheme)
|
||||||
{
|
{
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label asp-for="DerivationSchemeInput"></label>
|
<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>
|
<span asp-validation-for="DerivationSchemeInput" class="text-danger"></span>
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
@for (int i = 0; i < Model.AccountKeys.Count; i++)
|
@for (int i = 0; i < Model.AccountKeys.Count; i++)
|
||||||
{
|
{
|
||||||
<hr />
|
<hr/>
|
||||||
<h5>Account key @i</h5>
|
<h5>Account key @i</h5>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label asp-for="@Model.AccountKeys[i].AccountKey"></label>
|
<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>
|
<span asp-validation-for="@Model.AccountKeys[i].AccountKey" class="text-danger"></span>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label asp-for="@Model.AccountKeys[i].MasterFingerprint"></label>
|
<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>
|
<span asp-validation-for="@Model.AccountKeys[i].MasterFingerprint" class="text-danger"></span>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label asp-for="@Model.AccountKeys[i].AccountKeyPath"></label>
|
<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>
|
<span asp-validation-for="@Model.AccountKeys[i].AccountKeyPath" class="text-danger"></span>
|
||||||
</div>
|
</div>
|
||||||
@if (Model.IsMultiSig)
|
@if (Model.IsMultiSig)
|
||||||
{
|
{
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label asp-for="SelectedSigningKey"></label>
|
<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>
|
</div>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -80,9 +82,35 @@
|
|||||||
{
|
{
|
||||||
<button name="command" type="submit" class="dropdown-item" value="view-seed">View seed</button>
|
<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>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
</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