Add Transaction Hex as copyable content (#13508)

This commit is contained in:
Turbolay 2024-10-20 22:18:28 +02:00 коммит произвёл GitHub
Родитель 04667a8584
Коммит e2d27e6daa
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: B5690EEEBB952194
14 изменённых файлов: 52 добавлений и 10 удалений

Просмотреть файл

@ -169,7 +169,7 @@ public class BlockchainController : ControllerBase
return BadRequest($"{ex.Message}");
}
return Ok("Transaction is successfully broadcasted.");
return Ok("Transaction is successfully broadcast.");
}
/// <summary>

Просмотреть файл

@ -218,6 +218,7 @@
<StreamGeometry x:Key="input_count">M7.5 9C9.15685 9 10.5 7.65685 10.5 6C10.5 4.34315 9.15685 3 7.5 3C5.84315 3 4.5 4.34315 4.5 6C4.5 7.65685 5.84315 9 7.5 9ZM7.5 7.5C6.67157 7.5 6 6.82843 6 6C6 5.17157 6.67157 4.5 7.5 4.5C8.32843 4.5 9 5.17157 9 6C9 6.82843 8.32843 7.5 7.5 7.5ZM3 11.75C3 10.7835 3.7835 10 4.75 10H10.25C11.2165 10 12 10.7835 12 11.75V16.5C12 18.9853 9.98528 21 7.5 21C5.01472 21 3 18.9853 3 16.5V11.75ZM4.75 11.5C4.61193 11.5 4.5 11.6119 4.5 11.75V16.5C4.5 18.1569 5.84315 19.5 7.5 19.5C9.15685 19.5 10.5 18.1569 10.5 16.5V11.75C10.5 11.6119 10.3881 11.5 10.25 11.5H4.75ZM10.5273 8.61436C10.9623 8.85989 11.4647 9 11.9999 9C13.6567 9 14.9999 7.65685 14.9999 6C14.9999 4.34315 13.6567 3 11.9999 3C11.4647 3 10.9623 3.14011 10.5273 3.38564C10.8539 3.76346 11.1109 4.20305 11.2785 4.68452C11.4925 4.5669 11.7384 4.5 11.9999 4.5C12.8283 4.5 13.4999 5.17157 13.4999 6C13.4999 6.82843 12.8283 7.5 11.9999 7.5C11.7384 7.5 11.4925 7.4331 11.2785 7.31548C11.1109 7.79695 10.8539 8.23654 10.5273 8.61436ZM10.8602 20.8544C11.2242 20.9494 11.6061 21 11.9999 21C14.4851 21 16.4999 18.9853 16.4999 16.5V11.75C16.4999 10.7835 15.7164 10 14.7499 10H12.3713C12.7142 10.4152 12.9375 10.9328 12.9887 11.5H14.7499C14.8879 11.5 14.9999 11.6119 14.9999 11.75V16.5C14.9999 18.1194 13.7168 19.4391 12.1117 19.4979C11.7733 20.0175 11.3495 20.4763 10.8602 20.8544ZM15.0273 8.61436C15.4623 8.85989 15.9647 9 16.4999 9C18.1567 9 19.4999 7.65685 19.4999 6C19.4999 4.34315 18.1567 3 16.4999 3C15.9647 3 15.4623 3.14011 15.0273 3.38564C15.3539 3.76346 15.6109 4.20305 15.7785 4.68452C15.9925 4.5669 16.2384 4.5 16.4999 4.5C17.3283 4.5 17.9999 5.17157 17.9999 6C17.9999 6.82843 17.3283 7.5 16.4999 7.5C16.2384 7.5 15.9925 7.4331 15.7785 7.31548C15.6109 7.79695 15.3539 8.23654 15.0273 8.61436ZM15.3602 20.8544C15.7242 20.9494 16.1061 21 16.4999 21C18.9851 21 20.9999 18.9853 20.9999 16.5V11.75C20.9999 10.7835 20.2164 10 19.2499 10H16.8713C17.2142 10.4152 17.4375 10.9328 17.4887 11.5H19.2499C19.3879 11.5 19.4999 11.6119 19.4999 11.75V16.5C19.4999 18.1194 18.2168 19.4391 16.6117 19.4979C16.2733 20.0175 15.8495 20.4763 15.3602 20.8544Z</StreamGeometry>
<StreamGeometry x:Key="segwit_short">M3.47161 0.790119C1.96222 0.790119 0.738617 1.87657 0.738617 3.21678C0.738617 4.55699 0.738617 13.7901 0.738617 13.7901C0.738617 15.1303 1.96222 16.2168 3.47161 16.2168L19.5 16.2168C21.0093 16.2168 22.233 14.4086 22.233 13.0684V3.21678C22.233 1.87657 21.0093 0.790115 19.5 0.790115L3.47161 0.790119ZM2 3.21678C2 2.49512 2.65886 1.91012 3.47161 1.91012L19.5 1.91011C20.3128 1.91011 20.9716 2.49512 20.9716 3.21678V13.7901C20.9716 14.5118 20.3128 15.0968 19.5 15.0968C13.8241 15.0968 9.1475 15.0968 3.47161 15.0968C2.65886 15.0968 2 14.5118 2 13.7901V3.21678Z M9.00076 6.87769C8.74675 6.87769 8.54894 6.67439 8.42029 6.45537C8.34992 6.33558 8.25346 6.23307 8.13089 6.14784C7.88281 5.97311 7.57058 5.88575 7.19419 5.88575C6.92473 5.88575 6.69162 5.92998 6.49487 6.01845C6.29812 6.10471 6.14521 6.22414 6.03614 6.37675C5.92921 6.52715 5.87575 6.69854 5.87575 6.89096C5.87575 7.05242 5.91211 7.19175 5.98482 7.30897C6.05967 7.4262 6.15697 7.52461 6.27674 7.60424C6.39863 7.68165 6.52909 7.74689 6.6681 7.79997C6.8071 7.85084 6.94077 7.89286 7.06908 7.92604L7.71066 8.09855C7.92024 8.15163 8.13517 8.22351 8.35544 8.31419C8.57572 8.40487 8.77995 8.52429 8.96815 8.67248C9.15634 8.82067 9.30818 9.00423 9.42367 9.22319C9.54129 9.44216 9.6001 9.70423 9.6001 10.0094C9.6001 10.3943 9.50386 10.736 9.31139 11.0346C9.12106 11.3332 8.84411 11.5687 8.48055 11.7412C8.11913 11.9137 7.68179 12 7.16853 12C6.67665 12 6.25107 11.9192 5.89179 11.7578C5.53251 11.5963 5.25128 11.3674 5.04812 11.0711C4.9364 10.9069 4.85217 10.726 4.79542 10.5284C4.71636 10.2531 4.95453 10.0094 5.24092 10.0094C5.50191 10.0094 5.70548 10.2209 5.82485 10.453C5.85619 10.514 5.89347 10.5707 5.9367 10.6232C6.07357 10.7846 6.24786 10.9052 6.45958 10.9848C6.67344 11.0622 6.90762 11.1009 7.16211 11.1009C7.44227 11.1009 7.69141 11.0556 7.90955 10.9649C8.12982 10.872 8.30305 10.7437 8.42922 10.5801C8.5554 10.4142 8.61849 10.2207 8.61849 9.9995C8.61849 9.79823 8.56289 9.63346 8.45168 9.50518C8.34261 9.3769 8.19398 9.27075 8.00578 9.1867C7.81973 9.10265 7.60908 9.02857 7.37383 8.96443L6.59752 8.74547C6.07143 8.59728 5.65441 8.37944 5.34645 8.09191C5.04063 7.80439 4.88772 7.42399 4.88772 6.95068C4.88772 6.5592 4.99037 6.21751 5.19568 5.92556C5.40098 5.63361 5.679 5.40692 6.02973 5.24547C6.38046 5.0818 6.7761 4.99997 7.21664 4.99997C7.66147 4.99997 8.0539 5.08069 8.39394 5.24215C8.73611 5.40361 9.00557 5.62587 9.20232 5.90897C9.30357 6.05351 9.37989 6.20917 9.4313 6.37596C9.51362 6.64301 9.28021 6.87769 9.00076 6.87769Z M12.5323 11.9404C12.306 11.9404 12.108 11.7885 12.0493 11.57L10.4951 5.77435C10.4101 5.45741 10.6489 5.14613 10.977 5.14613C11.2072 5.14613 11.4075 5.30353 11.4619 5.52716L12.6419 10.378C12.6461 10.3954 12.6618 10.4077 12.6798 10.4077C12.6976 10.4077 12.7131 10.3956 12.7175 10.3783L13.9459 5.52348C14.002 5.30157 14.2017 5.14613 14.4306 5.14613H14.685C14.9139 5.14613 15.1136 5.30161 15.1697 5.52356L16.3981 10.3817C16.4025 10.3989 16.4181 10.4111 16.4359 10.4111C16.4539 10.4111 16.4695 10.3988 16.4737 10.3813L17.6506 5.52829C17.705 5.30404 17.9059 5.14613 18.1367 5.14613C18.4656 5.14613 18.7052 5.45821 18.6198 5.77585L17.0632 11.5702C17.0045 11.7886 16.8065 11.9404 16.5803 11.9404H16.3484C16.1227 11.9404 15.925 11.7893 15.8659 11.5715L14.5902 6.87611C14.5862 6.86149 14.573 6.85134 14.5578 6.85134C14.5427 6.85134 14.5294 6.86149 14.5254 6.87611L13.2498 11.5715C13.1906 11.7893 12.9929 11.9404 12.7673 11.9404H12.5323Z</StreamGeometry>
<StreamGeometry x:Key="taproot_short">M3.47161 0.790119C1.96222 0.790119 0.738617 1.87657 0.738617 3.21678C0.738617 4.55699 0.738617 13.7901 0.738617 13.7901C0.738617 15.1303 1.96222 16.2168 3.47161 16.2168L19.5 16.2168C21.0093 16.2168 22.233 14.4086 22.233 13.0684V3.21678C22.233 1.87657 21.0093 0.790115 19.5 0.790115L3.47161 0.790119ZM2 3.21678C2 2.49512 2.65886 1.91012 3.47161 1.91012L19.5 1.91011C20.3128 1.91011 20.9716 2.49512 20.9716 3.21678V13.7901C20.9716 14.5118 20.3128 15.0968 19.5 15.0968C13.8241 15.0968 9.1475 15.0968 3.47161 15.0968C2.65886 15.0968 2 14.5118 2 13.7901V3.21678Z M5.95459 5.90918C5.70352 5.90918 5.5 5.70565 5.5 5.45459C5.5 5.20353 5.70352 5 5.95459 5H10.5549C10.8059 5 11.0094 5.20353 11.0094 5.45459C11.0094 5.70565 10.8059 5.90918 10.5549 5.90918H9.28829C9.01215 5.90918 8.78829 6.13304 8.78829 6.40918V11.5C8.78829 11.7761 8.56443 12 8.28829 12H8.21768C7.94154 12 7.71768 11.7761 7.71768 11.5V6.40918C7.71768 6.13304 7.49382 5.90918 7.21768 5.90918H5.95459Z M12.7269 12C12.4508 12 12.2269 11.7761 12.2269 11.5V5.5C12.2269 5.22386 12.4508 5 12.7269 5H14.7644C15.3159 5 15.7736 5.09342 16.1374 5.28027C16.5035 5.46712 16.777 5.72575 16.9577 6.05615C17.1385 6.38428 17.2289 6.76367 17.2289 7.19434C17.2289 7.62272 17.1373 7.99984 16.9543 8.32568C16.7735 8.64925 16.5001 8.90104 16.1339 9.08105C15.7701 9.26107 15.3124 9.35107 14.7609 9.35107H13.2933C13.0422 9.35107 12.8387 9.14755 12.8387 8.89648C12.8387 8.64542 13.0422 8.4419 13.2933 8.4419H14.6636C15.0112 8.4419 15.2939 8.3929 15.5117 8.29492C15.7319 8.19694 15.8929 8.05453 15.9949 7.86768C16.0969 7.68083 16.1478 7.45638 16.1478 7.19434C16.1478 6.93001 16.0957 6.70101 15.9914 6.50733C15.8895 6.31364 15.7284 6.16553 15.5083 6.06299C15.2904 5.95817 15.0042 5.90576 14.6497 5.90576H13.801C13.5249 5.90576 13.301 6.12962 13.301 6.40576V11.5C13.301 11.7761 13.0771 12 12.801 12H12.7269ZM15.4473 8.8418C15.6287 8.8418 15.7959 8.94004 15.8841 9.09852L17.0861 11.2567C17.2717 11.59 17.0307 12 16.6492 12H16.5731C16.3902 12 16.2219 11.9001 16.1343 11.7396L14.9561 9.58138C14.7742 9.24818 15.0154 8.8418 15.395 8.8418H15.4473Z</StreamGeometry>
<StreamGeometry x:Key="binary_file">m10.57 1.14l3.28 3.3l.15.36v9.7l-.5.5h-11l-.5-.5v-13l.5-.5h7.72zM3 2v12h10V5l-3-3zm1.46 4.052q0 1.93 1.374 1.93q.686 0 1.05-.52q.369-.521.368-1.499Q7.252 4 5.91 4q-.707 0-1.08.526q-.37.524-.37 1.526m.862-.022q0-1.383.55-1.383q.516 0 .516 1.343c0 1.343-.176 1.343-.527 1.343q-.54 0-.54-1.303zm3.187 1.886h2.435v-.672h-.792V4l-1.665.336v.687l.82-.177v2.398h-.798zm-1.337 5H4.736v-.672h.798V9.846l-.82.177v-.687L6.38 9v3.244h.792v.671zm1.035-1.931q0 1.93 1.375 1.93q.686 0 1.05-.52q.368-.521.368-1.499q0-1.963-1.343-1.963q-.705 0-1.08.526q-.37.524-.37 1.526m.862-.022q0-1.383.55-1.383q.516 0 .516 1.343c0 1.343-.175 1.343-.526 1.343q-.54 0-.54-1.303</StreamGeometry>
<ControlTemplate x:Key="wasabi_logo_text_dynamic">
<StackPanel Margin="0,0,0,-5" TextElement.FontFamily="{StaticResource WasabiLogoTextFont}"

Просмотреть файл

@ -36,6 +36,9 @@ public partial class TransactionModel : ReactiveObject
public bool IsChild { get; set; }
public required Func<string> HexFunction { get; set; }
public Lazy<string> Hex => new(HexFunction());
public required Func<IReadOnlyCollection<OutPoint>> ForeignInputsFunction{ get; set; }
public Lazy<IReadOnlyCollection<OutPoint>> ForeignInputs => new(ForeignInputsFunction());
public required IReadOnlyCollection<SmartCoin> WalletInputs { get; set; }

Просмотреть файл

@ -138,6 +138,7 @@ public class TransactionTreeBuilder
Confirmations = confirmations,
BlockHeight = transactionSummary.Height.Type == HeightType.Chain ? transactionSummary.Height.Value : 0,
BlockHash = transactionSummary.BlockHash,
HexFunction = transactionSummary.Hex,
WalletInputs = transactionSummary.WalletInputs,
ForeignInputsFunction = transactionSummary.ForeignInputs,
WalletOutputs = transactionSummary.WalletOutputs,
@ -165,6 +166,7 @@ public class TransactionTreeBuilder
DateString = date.ToUserFacingFriendlyString(),
DateToolTipString = date.ToUserFacingString(),
OrderIndex = index,
HexFunction = transactionSummary.Hex,
WalletInputs = transactionSummary.WalletInputs,
ForeignInputsFunction = transactionSummary.ForeignInputs,
WalletOutputs = transactionSummary.WalletOutputs,
@ -189,6 +191,7 @@ public class TransactionTreeBuilder
Confirmations = parent.Confirmations,
BlockHeight = parent.BlockHeight,
BlockHash = parent.BlockHash,
HexFunction = transactionSummary.Hex,
WalletInputs = transactionSummary.WalletInputs,
ForeignInputsFunction = transactionSummary.ForeignInputs,
WalletOutputs = transactionSummary.WalletOutputs,
@ -289,6 +292,7 @@ public class TransactionTreeBuilder
Confirmations = confirmations,
BlockHeight = transactionSummary.Height.Type == HeightType.Chain ? transactionSummary.Height.Value : 0,
BlockHash = transactionSummary.BlockHash,
HexFunction = transactionSummary.Hex,
WalletInputs = transactionSummary.WalletInputs,
ForeignInputsFunction = transactionSummary.ForeignInputs,
WalletOutputs = transactionSummary.WalletOutputs,

Просмотреть файл

@ -34,6 +34,8 @@ public partial class CoinJoinDetailsViewModel : RoutableViewModel
_wallet = wallet;
_transaction = transaction;
TransactionHex = transaction.Hex.Value;
UiContext = uiContext;
SetupCancel(enableCancel: false, enableCancelOnEscape: true, enableCancelOnPressed: true);
@ -42,6 +44,7 @@ public partial class CoinJoinDetailsViewModel : RoutableViewModel
public CoinjoinCoinListViewModel InputList { get; }
public CoinjoinCoinListViewModel OutputList { get; }
public string TransactionHex { get; }
protected override void OnNavigatedTo(bool isInHistory, CompositeDisposable disposables)
{

Просмотреть файл

@ -49,6 +49,7 @@ public partial class TransactionDetailsViewModel : RoutableViewModel
Fee = wallet.AmountProvider.Create(model.Fee);
IsFeeVisible = model.Fee != null;
TransactionId = model.Id;
TransactionHex = model.Hex.Value;
DestinationAddresses = wallet.Transactions.GetDestinationAddresses(model.Id).ToArray();
SingleAddress = DestinationAddresses.Count == 1 ? DestinationAddresses.First() : null;
@ -63,7 +64,7 @@ public partial class TransactionDetailsViewModel : RoutableViewModel
public BitcoinAddress? SingleAddress { get; set; }
public uint256 TransactionId { get; }
public string TransactionHex { get; }
public Amount? Fee { get; }
public ICollection<BitcoinAddress> DestinationAddresses { get; }

Просмотреть файл

@ -96,6 +96,14 @@
</PrivacyContentControl>
</PreviewItem>
<Separator />
<!-- Hex -->
<PreviewItem Icon="{StaticResource binary_file}"
Label="Hex"
CopyableContent="{Binding TransactionHex}">
<TextBlock Text="Copy" />
</PreviewItem>
<Separator IsVisible="{Binding IsConfirmationTimeVisible}" />
</StackPanel>
</ContentArea>

Просмотреть файл

@ -160,6 +160,14 @@
<LabelsItemsPresenter ItemsSource="{Binding Labels}" />
</PrivacyContentControl>
</PreviewItem>
<!-- Hex -->
<Separator />
<PreviewItem Icon="{StaticResource binary_file}"
Label="Hex"
CopyableContent="{Binding TransactionHex}">
<TextBlock Text="Copy" />
</PreviewItem>
</StackPanel>
</ContentArea>
</UserControl>

Просмотреть файл

@ -22,6 +22,13 @@
<PathIcon Data="{StaticResource transaction_id}" />
</MenuItem.Icon>
</MenuItem>
<MenuItem Header="Copy Transaction Hex"
Command="{Binding ClipboardCopyCommand}"
CommandParameter="{Binding Transaction.Hex.Value, StringFormat={}{0}}">
<MenuItem.Icon>
<PathIcon Data="{StaticResource binary_file}" />
</MenuItem.Icon>
</MenuItem>
<MenuItem Header="Copy Label"
Command="{Binding ClipboardCopyCommand}"
CommandParameter="{Binding Transaction.Labels, StringFormat={}{0}}">
@ -78,6 +85,13 @@
<PathIcon Data="{StaticResource transaction_id}" />
</MenuItem.Icon>
</MenuItem>
<MenuItem Header="Copy Transaction Hex"
Command="{Binding ClipboardCopyCommand}"
CommandParameter="{Binding Transaction.Hex.Value, StringFormat={}{0}}">
<MenuItem.Icon>
<PathIcon Data="{StaticResource binary_file}" />
</MenuItem.Icon>
</MenuItem>
<Separator />
<MenuItem Header="Show Details"
Command="{Binding ShowDetailsCommand}">

Просмотреть файл

@ -19,7 +19,7 @@ public static class RpcErrorTools
[SpentError2] = SpentErrorTranslation,
[SpentError3] = SpentErrorTranslation,
["bad-txns-inputs-duplicate"] = "The transaction contains duplicated inputs.",
["bad-txns-nonfinal"] = "The transaction is not final and cannot be broadcasted.",
["bad-txns-nonfinal"] = "The transaction is not final and cannot be broadcast.",
["bad-txns-oversize"] = "The transaction is too big.",
["invalid password"] = "Wrong passphrase.",

Просмотреть файл

@ -150,7 +150,7 @@ public class NetworkBroadcaster(MempoolService mempoolService, NodesGroup nodes)
return BroadcastingResult.Fail(new BroadcastError.Unknown($"Timed out to broadcast to {node.RemoteSocketEndpoint} node"));
}
node.DisconnectAsync("Thank you!");
Logger.LogInfo($"Disconnected node: {node.RemoteSocketAddress}. Successfully broadcasted transaction: {txId}.");
Logger.LogInfo($"Disconnected node: {node.RemoteSocketAddress}. Successfully broadcast transaction: {txId}.");
var propagationTimeoutTask = Task.Delay(7000);
var propagationTask = entry.PropagationConfirmed.Task;
@ -197,15 +197,15 @@ public class TransactionBroadcaster(IBroadcaster[] broadcasters, MempoolService
switch (ok)
{
case BroadcastOk.BroadcastedByBackend:
Logger.LogInfo($"Transaction is successfully broadcasted {tx.GetHash()} by backend.");
Logger.LogInfo($"Transaction is successfully broadcast {tx.GetHash()} by backend.");
break;
case BroadcastOk.BroadcastedByRpc:
Logger.LogInfo($"Transaction is successfully broadcasted {tx.GetHash()} by local node RPC interface.");
Logger.LogInfo($"Transaction is successfully broadcast {tx.GetHash()} by local node RPC interface.");
break;
case BroadcastOk.BroadcastedByNetwork n:
foreach (var confirmedPropagators in n.Nodes)
{
Logger.LogInfo($"Transaction is successfully broadcasted {tx.GetHash()} and propagated by {confirmedPropagators}.");
Logger.LogInfo($"Transaction is successfully broadcast {tx.GetHash()} and propagated by {confirmedPropagators}.");
}
break;

Просмотреть файл

@ -19,7 +19,7 @@ public class TransactionSummary
public SmartTransaction Transaction { get; }
public Money Amount { get; set; }
public FeeRate? EffectiveFeeRate { get; }
public Func<string> Hex => () => Transaction.Transaction.ToHex();
public Func<IReadOnlyCollection<OutPoint>> ForeignInputs => () => Transaction.ForeignInputs.Select(x => x.PrevOut).ToArray();
public IReadOnlyCollection<SmartCoin> WalletInputs => Transaction.WalletInputs;
public Func<IReadOnlyCollection<IndexedTxOut>> ForeignOutputs => () => Transaction.ForeignOutputs;

Просмотреть файл

@ -81,7 +81,7 @@ public class CoinJoinProcessor : IDisposable
throw new InvalidOperationException("RpcClient is not available");
}
await RpcClient.SendRawTransactionAsync(transaction.Transaction).ConfigureAwait(false);
Logger.LogInfo($"Transaction is successfully broadcasted with RPC: {transaction.GetHash()}.");
Logger.LogInfo($"Transaction is successfully broadcast with RPC: {transaction.GetHash()}.");
return true;
}

Просмотреть файл

@ -307,7 +307,7 @@ public class CoinJoinClient
var msg = roundState.EndRoundState switch
{
EndRoundState.TransactionBroadcasted => $"Broadcasted. Coinjoin TxId: ({hash})",
EndRoundState.TransactionBroadcasted => $"Broadcast. Coinjoin TxId: ({hash})",
EndRoundState.TransactionBroadcastFailed => $"Failed to broadcast. Coinjoin TxId: ({hash})",
EndRoundState.AbortedWithError => "Round abnormally finished.",
EndRoundState.AbortedNotEnoughAlices => "Aborted. Not enough participants.",