mirror of
https://github.com/aljazceru/btcpayserver.git
synced 2025-12-18 14:34:23 +01:00
Coin Selection: Confirmed filter (#2467)
Allows provides confirmation count to Greenfield UTXO GET api
This commit is contained in:
@@ -21,5 +21,6 @@ namespace BTCPayServer.Client.Models
|
||||
[JsonConverter(typeof(KeyPathJsonConverter))]
|
||||
public KeyPath KeyPath { get; set; }
|
||||
public string Address { get; set; }
|
||||
public int Confirmations { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -239,6 +239,7 @@ namespace BTCPayServer.Controllers.GreenField
|
||||
coin.OutPoint.Hash.ToString()),
|
||||
Timestamp = coin.Timestamp,
|
||||
KeyPath = coin.KeyPath,
|
||||
Confirmations = coin.Confirmations,
|
||||
Address = network.NBXplorerNetwork.CreateAddress(derivationScheme.AccountDerivation, coin.KeyPath, coin.ScriptPubKey).ToString()
|
||||
};
|
||||
}).ToList()
|
||||
|
||||
@@ -576,7 +576,8 @@ namespace BTCPayServer.Controllers
|
||||
Amount = coin.Value.GetValue(network),
|
||||
Comment = info?.Comment,
|
||||
Labels = info == null ? null : _labelFactory.ColorizeTransactionLabels(walletBlobAsync, info, Request),
|
||||
Link = string.Format(CultureInfo.InvariantCulture, network.BlockExplorerLink, coin.OutPoint.Hash.ToString())
|
||||
Link = string.Format(CultureInfo.InvariantCulture, network.BlockExplorerLink, coin.OutPoint.Hash.ToString()),
|
||||
Confirmations = coin.Confirmations
|
||||
};
|
||||
}).ToArray();
|
||||
}
|
||||
|
||||
@@ -73,6 +73,7 @@ namespace BTCPayServer.Models.WalletViewModels
|
||||
public decimal Amount { get; set; }
|
||||
public string Outpoint { get; set; }
|
||||
public string Link { get; set; }
|
||||
public int Confirmations { get; set; }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@ namespace BTCPayServer.Services.Wallets
|
||||
public KeyPath KeyPath { get; set; }
|
||||
public IMoney Value { get; set; }
|
||||
public Coin Coin { get; set; }
|
||||
public int Confirmations { get; set; }
|
||||
}
|
||||
public class NetworkCoins
|
||||
{
|
||||
@@ -259,7 +260,8 @@ namespace BTCPayServer.Services.Wallets
|
||||
Timestamp = c.Timestamp,
|
||||
OutPoint = c.Outpoint,
|
||||
ScriptPubKey = c.ScriptPubKey,
|
||||
Coin = c.AsCoin(derivationStrategy)
|
||||
Coin = c.AsCoin(derivationStrategy),
|
||||
Confirmations = c.Confirmations
|
||||
}).ToArray();
|
||||
}
|
||||
|
||||
|
||||
@@ -42,6 +42,11 @@
|
||||
</a>
|
||||
</label>
|
||||
<div>
|
||||
|
||||
<span v-bind:class="{' badge-success' : item.confirmations > 0, ' badge-warning' : item.confirmations <= 0}" data-toggle="tooltip" v-tooltip="item.confirmations +' confirmations'" class="badge ">
|
||||
{{item.confirmations}}<span class=" ml-1 fa fa-cube"></span>
|
||||
</span>
|
||||
|
||||
<span v-if="item.comment" data-toggle="tooltip" v-tooltip="item.comment" class="badge badge-info badge-pill" style="font-style: italic">i</span>
|
||||
<span
|
||||
v-if="item.labels"
|
||||
@@ -78,10 +83,16 @@
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<a href="#" v-on:click="showSelectedOnly = !showSelectedOnly" class="btn btn-secondary" v-bind:class="{'disabled' : selectedInputs.length === 0}">
|
||||
<div class="btn-group btn-group-sm">
|
||||
<a href="#" v-on:click="showSelectedOnly = !showSelectedOnly" class="btn btn-sm btn-secondary" v-bind:class="{'disabled' : selectedInputs.length === 0}">
|
||||
<template v-if="showSelectedOnly">Show all</template>
|
||||
<template v-else>Show selected only</template>
|
||||
</a>
|
||||
<a href="#" v-show="!showSelectedOnly" v-on:click="showUnconfirmedOnly = !showUnconfirmedOnly" class="btn btn-sm btn-secondary">
|
||||
<template v-if="showUnconfirmedOnly">Show unconfirmed coins</template>
|
||||
<template v-else>Hide unconfirmed coins</template>
|
||||
</a>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
@@ -109,7 +120,8 @@ $(function() {
|
||||
selectedInputs: $("#SelectedInputs").val(),
|
||||
page: 0,
|
||||
pageSize: 10,
|
||||
showSelectedOnly: false
|
||||
showSelectedOnly: false,
|
||||
showUnconfirmedOnly: false
|
||||
},
|
||||
watch: {
|
||||
filter: function() {
|
||||
@@ -121,11 +133,14 @@ $(function() {
|
||||
},
|
||||
selectedInputs: function() {
|
||||
this.handle();
|
||||
},
|
||||
showUnconfirmedOnly: function() {
|
||||
this.handle();
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
currentItems: function() {
|
||||
return this.showSelectedOnly ? this.selectedItems : this.items;
|
||||
return this.showSelectedOnly ? this.selectedItems : this.items.filter(i=> (!this.showUnconfirmedOnly || i.confirmations ));
|
||||
},
|
||||
pageStart: function() {
|
||||
return this.page == 0 ? 0 : this.page * this.pageSize;
|
||||
@@ -139,7 +154,7 @@ $(function() {
|
||||
},
|
||||
filteredItems: function() {
|
||||
var result = [];
|
||||
if (!this.filter) {
|
||||
if (!this.filter && !this.showUnconfirmedOnly) {
|
||||
var self = this;
|
||||
result = this.currentItems.map(function(currentItem) {
|
||||
return {...currentItem, selected: self.selectedInputs.indexOf(currentItem.outpoint) != -1
|
||||
@@ -149,7 +164,8 @@ $(function() {
|
||||
var f = this.filter.toLowerCase();
|
||||
for (var i = 0; i < this.currentItems.length; i++) {
|
||||
var currentItem = this.currentItems[i];
|
||||
if (currentItem.outpoint.indexOf(f) != -1 ||
|
||||
if
|
||||
(currentItem.outpoint.indexOf(f) != -1 ||
|
||||
currentItem.amount.toString().indexOf(f) != -1 ||
|
||||
(currentItem.comment && currentItem.comment.toLowerCase().indexOf(f) != -1) ||
|
||||
(currentItem.labels && currentItem.labels.filter(function(l) {
|
||||
|
||||
@@ -683,6 +683,10 @@
|
||||
"type": "string",
|
||||
"description": "The wallet address of this utxo"
|
||||
},
|
||||
"confirmations": {
|
||||
"type": "number",
|
||||
"description": "The number of confirmations of this utxo"
|
||||
},
|
||||
"labels": {
|
||||
"description": "Labels linked to this transaction",
|
||||
"type": "object",
|
||||
|
||||
Reference in New Issue
Block a user