|
|
@ -1,5 +1,6 @@ |
|
|
|
package com.sparrowwallet.sparrow.transaction; |
|
|
|
|
|
|
|
import com.sparrowwallet.drongo.KeyPurpose; |
|
|
|
import com.sparrowwallet.drongo.SecureString; |
|
|
|
import com.sparrowwallet.drongo.Utils; |
|
|
|
import com.sparrowwallet.drongo.protocol.*; |
|
|
@ -14,6 +15,9 @@ import com.sparrowwallet.sparrow.glyphfont.FontAwesome5Brands; |
|
|
|
import com.sparrowwallet.sparrow.io.Device; |
|
|
|
import com.sparrowwallet.sparrow.net.ElectrumServer; |
|
|
|
import com.sparrowwallet.sparrow.io.Storage; |
|
|
|
import com.sparrowwallet.sparrow.wallet.HashIndexEntry; |
|
|
|
import com.sparrowwallet.sparrow.wallet.TransactionEntry; |
|
|
|
import javafx.application.Platform; |
|
|
|
import javafx.collections.FXCollections; |
|
|
|
import javafx.event.ActionEvent; |
|
|
|
import javafx.fxml.FXML; |
|
|
@ -905,13 +909,40 @@ public class HeadersController extends TransactionFormController implements Init |
|
|
|
updateBlockchainForm(blockTransaction, AppController.getCurrentBlockHeight()); |
|
|
|
} |
|
|
|
}); |
|
|
|
transactionReferenceService.setOnSucceeded(failEvent -> { |
|
|
|
transactionReferenceService.setOnFailed(failEvent -> { |
|
|
|
log.error("Could not update block transaction", failEvent.getSource().getException()); |
|
|
|
}); |
|
|
|
transactionReferenceService.start(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@Subscribe |
|
|
|
public void walletHistoryChanged(WalletHistoryChangedEvent event) { |
|
|
|
//Update tx and input/output reference labels on history changed wallet if this txid matches and label is null
|
|
|
|
if(headersForm.getSigningWallet() != null && !(headersForm.getSigningWallet() instanceof FinalizingPSBTWallet)) { |
|
|
|
Sha256Hash txid = headersForm.getTransaction().getTxId(); |
|
|
|
|
|
|
|
BlockTransaction blockTransaction = event.getWallet().getTransactions().get(txid); |
|
|
|
if(blockTransaction != null && blockTransaction.getLabel() == null) { |
|
|
|
blockTransaction.setLabel(headersForm.getName()); |
|
|
|
Platform.runLater(() -> EventManager.get().post(new WalletEntryLabelChangedEvent(event.getWallet(), new TransactionEntry(event.getWallet(), blockTransaction, Collections.emptyMap(), Collections.emptyMap())))); |
|
|
|
} |
|
|
|
|
|
|
|
for(WalletNode walletNode : event.getHistoryChangedNodes()) { |
|
|
|
for(BlockTransactionHashIndex output : walletNode.getTransactionOutputs()) { |
|
|
|
if(output.getHash().equals(txid) && output.getLabel() == null) { //If we send to ourselves, usually change
|
|
|
|
output.setLabel(headersForm.getName() + (walletNode.getKeyPurpose() == KeyPurpose.CHANGE ? " (change)" : " (received)")); |
|
|
|
Platform.runLater(() -> EventManager.get().post(new WalletEntryLabelChangedEvent(event.getWallet(), new HashIndexEntry(event.getWallet(), output, HashIndexEntry.Type.OUTPUT, walletNode.getKeyPurpose())))); |
|
|
|
} |
|
|
|
if(output.getSpentBy() != null && output.getSpentBy().getHash().equals(txid) && output.getSpentBy().getLabel() == null) { //The norm - sending out
|
|
|
|
output.getSpentBy().setLabel(headersForm.getName() + " (input)"); |
|
|
|
Platform.runLater(() -> EventManager.get().post(new WalletEntryLabelChangedEvent(event.getWallet(), new HashIndexEntry(event.getWallet(), output.getSpentBy(), HashIndexEntry.Type.INPUT, walletNode.getKeyPurpose())))); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@Subscribe |
|
|
|
public void newBlock(NewBlockEvent event) { |
|
|
|
if(headersForm.getBlockTransaction() != null) { |
|
|
|