mirror of
https://github.com/sparrowwallet/sparrow.git
synced 2024-12-25 05:06:45 +00:00
fix save of address labels on a new wallet
This commit is contained in:
parent
b9e64d42ff
commit
143472bdfc
1 changed files with 14 additions and 2 deletions
|
@ -237,8 +237,20 @@ public class DbPersistence implements Persistence {
|
||||||
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(), entry.getLabel());
|
||||||
} else if(entry instanceof NodeEntry && ((NodeEntry)entry).getNode().getId() != null) {
|
} else if(entry instanceof NodeEntry) {
|
||||||
walletNodeDao.updateNodeLabel(((NodeEntry)entry).getNode().getId(), entry.getLabel());
|
WalletNode addressNode = ((NodeEntry)entry).getNode();
|
||||||
|
if(addressNode.getId() == null) {
|
||||||
|
WalletNode purposeNode = wallet.getNode(addressNode.getKeyPurpose());
|
||||||
|
if(purposeNode.getId() == null) {
|
||||||
|
long purposeNodeId = walletNodeDao.insertWalletNode(purposeNode.getDerivationPath(), purposeNode.getLabel(), wallet.getId(), null);
|
||||||
|
purposeNode.setId(purposeNodeId);
|
||||||
|
}
|
||||||
|
|
||||||
|
long nodeId = walletNodeDao.insertWalletNode(addressNode.getDerivationPath(), addressNode.getLabel(), wallet.getId(), purposeNode.getId());
|
||||||
|
addressNode.setId(nodeId);
|
||||||
|
}
|
||||||
|
|
||||||
|
walletNodeDao.updateNodeLabel(addressNode.getId(), 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(), entry.getLabel());
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue