diff --git a/src/main/java/com/sparrowwallet/sparrow/io/db/DbPersistence.java b/src/main/java/com/sparrowwallet/sparrow/io/db/DbPersistence.java index 3029e48c..a7d74020 100644 --- a/src/main/java/com/sparrowwallet/sparrow/io/db/DbPersistence.java +++ b/src/main/java/com/sparrowwallet/sparrow/io/db/DbPersistence.java @@ -285,7 +285,7 @@ public class DbPersistence implements Persistence { WalletNodeDao walletNodeDao = handle.attach(WalletNodeDao.class); for(Entry entry : dirtyPersistables.labelEntries) { 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) { WalletNode addressNode = ((NodeEntry)entry).getNode(); if(addressNode.getId() == null) { @@ -301,9 +301,9 @@ public class DbPersistence implements Persistence { 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) { - walletNodeDao.updateTxoLabel(((HashIndexEntry)entry).getHashIndex().getId(), entry.getLabel()); + walletNodeDao.updateTxoLabel(((HashIndexEntry)entry).getHashIndex().getId(), walletNodeDao.truncate(entry.getLabel())); } } } diff --git a/src/main/java/com/sparrowwallet/sparrow/transaction/HeadersController.java b/src/main/java/com/sparrowwallet/sparrow/transaction/HeadersController.java index 06261348..43848f5b 100644 --- a/src/main/java/com/sparrowwallet/sparrow/transaction/HeadersController.java +++ b/src/main/java/com/sparrowwallet/sparrow/transaction/HeadersController.java @@ -235,7 +235,7 @@ public class HeadersController extends TransactionFormController implements Init private ElectrumServer.TransactionMempoolService transactionMempoolService; - private final Map outputIndexLabels = new HashMap<>(); + private final Map outputIndexLabels = new TreeMap<>(); @Override public void initialize(URL location, ResourceBundle resources) { @@ -1502,7 +1502,13 @@ public class HeadersController extends TransactionFormController implements Init List changedLabelEntries = new ArrayList<>(); BlockTransaction blockTransaction = event.getWallet().getWalletTransaction(txid); 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())); }