mirror of
https://github.com/sparrowwallet/sparrow.git
synced 2024-12-25 05:06:45 +00:00
add payment labels to transaction tabs for received outputs where available from open wallets
This commit is contained in:
parent
c8a5c1fb86
commit
14689dd256
1 changed files with 14 additions and 1 deletions
|
@ -54,6 +54,7 @@ import tornadofx.control.Fieldset;
|
||||||
import com.google.common.eventbus.Subscribe;
|
import com.google.common.eventbus.Subscribe;
|
||||||
import tornadofx.control.Form;
|
import tornadofx.control.Form;
|
||||||
|
|
||||||
|
import javax.swing.text.html.Option;
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.net.*;
|
import java.net.*;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
|
@ -674,7 +675,8 @@ public class HeadersController extends TransactionFormController implements Init
|
||||||
List<Payment> payments = new ArrayList<>();
|
List<Payment> payments = new ArrayList<>();
|
||||||
for(TransactionOutput txOutput : headersForm.getTransaction().getOutputs()) {
|
for(TransactionOutput txOutput : headersForm.getTransaction().getOutputs()) {
|
||||||
try {
|
try {
|
||||||
payments.add(new Payment(txOutput.getScript().getToAddresses()[0], null, txOutput.getValue(), false));
|
BlockTransactionHashIndex receivedTxo = getBlockTransactionOutput(txOutput);
|
||||||
|
payments.add(new Payment(txOutput.getScript().getToAddresses()[0], receivedTxo != null ? receivedTxo.getLabel() : null, txOutput.getValue(), false));
|
||||||
} catch(Exception e) {
|
} catch(Exception e) {
|
||||||
//ignore
|
//ignore
|
||||||
}
|
}
|
||||||
|
@ -708,6 +710,17 @@ public class HeadersController extends TransactionFormController implements Init
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private BlockTransactionHashIndex getBlockTransactionOutput(TransactionOutput txOutput) {
|
||||||
|
for(Wallet openWallet : AppServices.get().getOpenWallets().keySet()) {
|
||||||
|
Optional<BlockTransactionHashIndex> output = openWallet.getWalletTxos().keySet().stream().filter(ref -> ref.getHash().equals(txOutput.getHash()) && ref.getIndex() == txOutput.getIndex()).findFirst();
|
||||||
|
if(output.isPresent()) {
|
||||||
|
return output.get();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
private void updateBlockchainForm(BlockTransaction blockTransaction, Integer currentHeight) {
|
private void updateBlockchainForm(BlockTransaction blockTransaction, Integer currentHeight) {
|
||||||
signaturesForm.setVisible(false);
|
signaturesForm.setVisible(false);
|
||||||
blockchainForm.setVisible(true);
|
blockchainForm.setVisible(true);
|
||||||
|
|
Loading…
Reference in a new issue