Merge pull request #1523 from Kukks/sender-payjoin-label

Tag payjoin for sender too
This commit is contained in:
Nicolas Dorier 2020-05-01 05:27:33 +09:00 committed by GitHub
commit 29741f39ac
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 20 additions and 3 deletions

View file

@ -5,6 +5,7 @@ using System.Net.Http;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using BTCPayServer.HostedServices;
using BTCPayServer.ModelBinders;
using BTCPayServer.Models;
using BTCPayServer.Models.WalletViewModels;
@ -329,6 +330,21 @@ namespace BTCPayServer.Controllers
vm.PSBT = proposedPayjoin.ToBase64();
vm.OriginalPSBT = psbt.ToBase64();
proposedPayjoin.Finalize();
var hash = proposedPayjoin.ExtractTransaction().GetHash();
_EventAggregator.Publish(new UpdateTransactionLabel()
{
WalletId = walletId,
TransactionLabels = new Dictionary<uint256, List<(string color, string label)>>()
{
{
hash,
new List<(string color, string label)>
{
UpdateTransactionLabel.PayjoinLabelTemplate()
}
}
}
});
TempData.SetStatusMessageModel(new StatusMessageModel()
{
Severity = StatusMessageModel.StatusSeverity.Success,

View file

@ -43,12 +43,13 @@ namespace BTCPayServer.Services.Labels
throw new ArgumentNullException(nameof(value));
if (color == null)
throw new ArgumentNullException(nameof(color));
if (value.StartsWith("{"))
if (value.StartsWith("{", StringComparison.InvariantCultureIgnoreCase))
{
var jObj = JObject.Parse(value);
if (jObj.ContainsKey("value"))
{
var id = jObj.ContainsKey("id") ? jObj["id"].Value<string>() : string.Empty;
var idInLabel = string.IsNullOrEmpty(id) ? string.Empty : $"({id})";
switch (jObj["value"].Value<string>())
{
case "invoice":
@ -57,7 +58,7 @@ namespace BTCPayServer.Services.Labels
RawValue = value,
Value = "invoice",
Color = color,
Tooltip = $"Received through an invoice ({id})",
Tooltip = $"Received through an invoice {idInLabel}",
Link = string.IsNullOrEmpty(id)
? null
: _linkGenerator.InvoiceLink(id, request.Scheme, request.Host, request.PathBase)
@ -68,7 +69,7 @@ namespace BTCPayServer.Services.Labels
RawValue = value,
Value = "payjoin-exposed",
Color = color,
Tooltip = $"This utxo was exposed through a payjoin proposal for an invoice ({id})",
Tooltip = $"This utxo was exposed through a payjoin proposal for an invoice {idInLabel}",
Link = string.IsNullOrEmpty(id)
? null
: _linkGenerator.InvoiceLink(id, request.Scheme, request.Host, request.PathBase)