mirror of
https://github.com/sparrowwallet/sparrow.git
synced 2024-11-05 05:46:44 +00:00
set transaction label to comma separated list of payment labels when multiple payments are made
This commit is contained in:
parent
9bcb34e7d1
commit
5105b503ea
2 changed files with 11 additions and 5 deletions
|
@ -285,7 +285,7 @@ public class DbPersistence implements Persistence {
|
||||||
WalletNodeDao walletNodeDao = handle.attach(WalletNodeDao.class);
|
WalletNodeDao walletNodeDao = handle.attach(WalletNodeDao.class);
|
||||||
for(Entry entry : dirtyPersistables.labelEntries) {
|
for(Entry entry : dirtyPersistables.labelEntries) {
|
||||||
if(entry instanceof TransactionEntry && ((TransactionEntry)entry).getBlockTransaction().getId() != null) {
|
if(entry instanceof TransactionEntry && ((TransactionEntry)entry).getBlockTransaction().getId() != null) {
|
||||||
blockTransactionDao.updateLabel(((TransactionEntry)entry).getBlockTransaction().getId(), entry.getLabel());
|
blockTransactionDao.updateLabel(((TransactionEntry)entry).getBlockTransaction().getId(), blockTransactionDao.truncate(entry.getLabel()));
|
||||||
} else if(entry instanceof NodeEntry) {
|
} else if(entry instanceof NodeEntry) {
|
||||||
WalletNode addressNode = ((NodeEntry)entry).getNode();
|
WalletNode addressNode = ((NodeEntry)entry).getNode();
|
||||||
if(addressNode.getId() == null) {
|
if(addressNode.getId() == null) {
|
||||||
|
@ -301,9 +301,9 @@ public class DbPersistence implements Persistence {
|
||||||
walletNodeDao.updateNodeAddressData(addressNode.getId(), addressNode.getAddressData());
|
walletNodeDao.updateNodeAddressData(addressNode.getId(), addressNode.getAddressData());
|
||||||
}
|
}
|
||||||
|
|
||||||
walletNodeDao.updateNodeLabel(addressNode.getId(), entry.getLabel());
|
walletNodeDao.updateNodeLabel(addressNode.getId(), walletNodeDao.truncate(entry.getLabel()));
|
||||||
} else if(entry instanceof HashIndexEntry && ((HashIndexEntry)entry).getHashIndex().getId() != null) {
|
} else if(entry instanceof HashIndexEntry && ((HashIndexEntry)entry).getHashIndex().getId() != null) {
|
||||||
walletNodeDao.updateTxoLabel(((HashIndexEntry)entry).getHashIndex().getId(), entry.getLabel());
|
walletNodeDao.updateTxoLabel(((HashIndexEntry)entry).getHashIndex().getId(), walletNodeDao.truncate(entry.getLabel()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -235,7 +235,7 @@ public class HeadersController extends TransactionFormController implements Init
|
||||||
|
|
||||||
private ElectrumServer.TransactionMempoolService transactionMempoolService;
|
private ElectrumServer.TransactionMempoolService transactionMempoolService;
|
||||||
|
|
||||||
private final Map<Integer, String> outputIndexLabels = new HashMap<>();
|
private final Map<Integer, String> outputIndexLabels = new TreeMap<>();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void initialize(URL location, ResourceBundle resources) {
|
public void initialize(URL location, ResourceBundle resources) {
|
||||||
|
@ -1502,7 +1502,13 @@ public class HeadersController extends TransactionFormController implements Init
|
||||||
List<Entry> changedLabelEntries = new ArrayList<>();
|
List<Entry> changedLabelEntries = new ArrayList<>();
|
||||||
BlockTransaction blockTransaction = event.getWallet().getWalletTransaction(txid);
|
BlockTransaction blockTransaction = event.getWallet().getWalletTransaction(txid);
|
||||||
if(blockTransaction != null && blockTransaction.getLabel() == null) {
|
if(blockTransaction != null && blockTransaction.getLabel() == null) {
|
||||||
blockTransaction.setLabel(headersForm.getName());
|
String name = headersForm.getName();
|
||||||
|
if(outputIndexLabels.size() > 1) {
|
||||||
|
StringJoiner joiner = new StringJoiner(", ");
|
||||||
|
outputIndexLabels.values().forEach(joiner::add);
|
||||||
|
name = joiner.toString();
|
||||||
|
}
|
||||||
|
blockTransaction.setLabel(name != null && name.length() > 255 ? name.substring(0, 255) : name);
|
||||||
changedLabelEntries.add(new TransactionEntry(event.getWallet(), blockTransaction, Collections.emptyMap(), Collections.emptyMap()));
|
changedLabelEntries.add(new TransactionEntry(event.getWallet(), blockTransaction, Collections.emptyMap(), Collections.emptyMap()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue