mirror of
https://github.com/sparrowwallet/sparrow.git
synced 2024-12-25 05:06:45 +00:00
create psbt tab from send
This commit is contained in:
parent
e79f5ba977
commit
907062ffa0
5 changed files with 61 additions and 8 deletions
2
drongo
2
drongo
|
@ -1 +1 @@
|
||||||
Subproject commit f00754b15779e94faa65c3de5c0a977cc51d865b
|
Subproject commit 9b117cd7f90caba5e280034dee5865a1a42d82c1
|
|
@ -861,6 +861,12 @@ public class AppController implements Initializable {
|
||||||
tabs.getSelectionModel().select(tab);
|
tabs.getSelectionModel().select(tab);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Subscribe
|
||||||
|
public void viewPSBT(ViewPSBTEvent event) {
|
||||||
|
Tab tab = addTransactionTab(event.getLabel(), event.getPsbt());
|
||||||
|
tabs.getSelectionModel().select(tab);
|
||||||
|
}
|
||||||
|
|
||||||
@Subscribe
|
@Subscribe
|
||||||
public void bitcoinUnitChanged(BitcoinUnitChangedEvent event) {
|
public void bitcoinUnitChanged(BitcoinUnitChangedEvent event) {
|
||||||
Optional<Toggle> selectedToggle = bitcoinUnit.getToggles().stream().filter(toggle -> event.getBitcoinUnit().equals(toggle.getUserData())).findFirst();
|
Optional<Toggle> selectedToggle = bitcoinUnit.getToggles().stream().filter(toggle -> event.getBitcoinUnit().equals(toggle.getUserData())).findFirst();
|
||||||
|
|
|
@ -0,0 +1,38 @@
|
||||||
|
package com.sparrowwallet.sparrow.event;
|
||||||
|
|
||||||
|
import com.sparrowwallet.drongo.psbt.PSBT;
|
||||||
|
import com.sparrowwallet.sparrow.transaction.TransactionView;
|
||||||
|
|
||||||
|
public class ViewPSBTEvent {
|
||||||
|
private final String label;
|
||||||
|
private final PSBT psbt;
|
||||||
|
private final TransactionView initialView;
|
||||||
|
private final Integer initialIndex;
|
||||||
|
|
||||||
|
public ViewPSBTEvent(String label, PSBT psbt) {
|
||||||
|
this(label, psbt, TransactionView.HEADERS, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ViewPSBTEvent(String label, PSBT psbt, TransactionView initialView, Integer initialIndex) {
|
||||||
|
this.label = label;
|
||||||
|
this.psbt = psbt;
|
||||||
|
this.initialView = initialView;
|
||||||
|
this.initialIndex = initialIndex;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getLabel() {
|
||||||
|
return label;
|
||||||
|
}
|
||||||
|
|
||||||
|
public PSBT getPsbt() {
|
||||||
|
return psbt;
|
||||||
|
}
|
||||||
|
|
||||||
|
public TransactionView getInitialView() {
|
||||||
|
return initialView;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getInitialIndex() {
|
||||||
|
return initialIndex;
|
||||||
|
}
|
||||||
|
}
|
|
@ -5,9 +5,9 @@ import com.sparrowwallet.sparrow.transaction.TransactionView;
|
||||||
import com.sparrowwallet.sparrow.wallet.HashIndexEntry;
|
import com.sparrowwallet.sparrow.wallet.HashIndexEntry;
|
||||||
|
|
||||||
public class ViewTransactionEvent {
|
public class ViewTransactionEvent {
|
||||||
public final BlockTransaction blockTransaction;
|
private final BlockTransaction blockTransaction;
|
||||||
public final TransactionView initialView;
|
private final TransactionView initialView;
|
||||||
public final Integer initialIndex;
|
private final Integer initialIndex;
|
||||||
|
|
||||||
public ViewTransactionEvent(BlockTransaction blockTransaction) {
|
public ViewTransactionEvent(BlockTransaction blockTransaction) {
|
||||||
this(blockTransaction, TransactionView.HEADERS, null);
|
this(blockTransaction, TransactionView.HEADERS, null);
|
||||||
|
|
|
@ -7,6 +7,7 @@ import com.sparrowwallet.drongo.address.InvalidAddressException;
|
||||||
import com.sparrowwallet.drongo.address.P2PKHAddress;
|
import com.sparrowwallet.drongo.address.P2PKHAddress;
|
||||||
import com.sparrowwallet.drongo.protocol.Transaction;
|
import com.sparrowwallet.drongo.protocol.Transaction;
|
||||||
import com.sparrowwallet.drongo.protocol.TransactionOutput;
|
import com.sparrowwallet.drongo.protocol.TransactionOutput;
|
||||||
|
import com.sparrowwallet.drongo.psbt.PSBT;
|
||||||
import com.sparrowwallet.drongo.wallet.*;
|
import com.sparrowwallet.drongo.wallet.*;
|
||||||
import com.sparrowwallet.sparrow.AppController;
|
import com.sparrowwallet.sparrow.AppController;
|
||||||
import com.sparrowwallet.sparrow.CurrencyRate;
|
import com.sparrowwallet.sparrow.CurrencyRate;
|
||||||
|
@ -147,14 +148,16 @@ public class SendController extends WalletFormController implements Initializabl
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void initializeView() {
|
public void initializeView() {
|
||||||
addValidation();
|
|
||||||
|
|
||||||
address.textProperty().addListener((observable, oldValue, newValue) -> {
|
address.textProperty().addListener((observable, oldValue, newValue) -> {
|
||||||
revalidate(amount, amountListener);
|
revalidate(amount, amountListener);
|
||||||
maxButton.setDisable(!isValidRecipientAddress());
|
maxButton.setDisable(!isValidRecipientAddress());
|
||||||
updateTransaction();
|
updateTransaction();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
label.textProperty().addListener((observable, oldValue, newValue) -> {
|
||||||
|
createButton.setDisable(walletTransactionProperty.get() == null || newValue == null || newValue.isEmpty());
|
||||||
|
});
|
||||||
|
|
||||||
amount.setTextFormatter(new CoinTextFormatter());
|
amount.setTextFormatter(new CoinTextFormatter());
|
||||||
amount.textProperty().addListener(amountListener);
|
amount.textProperty().addListener(amountListener);
|
||||||
|
|
||||||
|
@ -265,10 +268,12 @@ public class SendController extends WalletFormController implements Initializabl
|
||||||
}
|
}
|
||||||
|
|
||||||
transactionDiagram.update(walletTransaction);
|
transactionDiagram.update(walletTransaction);
|
||||||
createButton.setDisable(walletTransaction == null);
|
createButton.setDisable(walletTransaction == null || label.getText().isEmpty());
|
||||||
});
|
});
|
||||||
|
|
||||||
address.setText("32YSPMaUePf511u5adEckiNq8QLec9ksXX");
|
address.setText("32YSPMaUePf511u5adEckiNq8QLec9ksXX");
|
||||||
|
|
||||||
|
addValidation();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addValidation() {
|
private void addValidation() {
|
||||||
|
@ -276,6 +281,9 @@ public class SendController extends WalletFormController implements Initializabl
|
||||||
validationSupport.registerValidator(address, Validator.combine(
|
validationSupport.registerValidator(address, Validator.combine(
|
||||||
(Control c, String newValue) -> ValidationResult.fromErrorIf( c, "Invalid Address", !newValue.isEmpty() && !isValidRecipientAddress())
|
(Control c, String newValue) -> ValidationResult.fromErrorIf( c, "Invalid Address", !newValue.isEmpty() && !isValidRecipientAddress())
|
||||||
));
|
));
|
||||||
|
validationSupport.registerValidator(label, Validator.combine(
|
||||||
|
Validator.createEmptyValidator("Label is required")
|
||||||
|
));
|
||||||
validationSupport.registerValidator(amount, Validator.combine(
|
validationSupport.registerValidator(amount, Validator.combine(
|
||||||
(Control c, String newValue) -> ValidationResult.fromErrorIf( c, "Insufficient Inputs", insufficientInputsProperty.get()),
|
(Control c, String newValue) -> ValidationResult.fromErrorIf( c, "Insufficient Inputs", insufficientInputsProperty.get()),
|
||||||
(Control c, String newValue) -> ValidationResult.fromErrorIf( c, "Insufficient Value", getRecipientValueSats() != null && getRecipientValueSats() <= getRecipientDustThreshold())
|
(Control c, String newValue) -> ValidationResult.fromErrorIf( c, "Insufficient Value", getRecipientValueSats() != null && getRecipientValueSats() <= getRecipientDustThreshold())
|
||||||
|
@ -499,7 +507,8 @@ public class SendController extends WalletFormController implements Initializabl
|
||||||
}
|
}
|
||||||
|
|
||||||
public void createTransaction(ActionEvent event) {
|
public void createTransaction(ActionEvent event) {
|
||||||
|
PSBT psbt = walletTransactionProperty.get().createPSBT();
|
||||||
|
EventManager.get().post(new ViewPSBTEvent(label.getText(), psbt));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Subscribe
|
@Subscribe
|
||||||
|
|
Loading…
Reference in a new issue