diff --git a/src/main/java/com/sparrowwallet/sparrow/AppController.java b/src/main/java/com/sparrowwallet/sparrow/AppController.java index 32d142b0..df2286ab 100644 --- a/src/main/java/com/sparrowwallet/sparrow/AppController.java +++ b/src/main/java/com/sparrowwallet/sparrow/AppController.java @@ -556,7 +556,7 @@ public class AppController implements Initializable { stage.initOwner(tabs.getScene().getWindow()); JoinstrController controller = loader.getController(); - JoinstrForm joinstrForm = new JoinstrForm(getSelectedWalletForm().getStorage(), getSelectedWalletForm().getWallet()); + JoinstrForm joinstrForm = new JoinstrForm(getSelectedWalletForm()); controller.setJoinstrForm(joinstrForm); Scene scene = new Scene(root); diff --git a/src/main/java/com/sparrowwallet/sparrow/joinstr/JoinstrController.java b/src/main/java/com/sparrowwallet/sparrow/joinstr/JoinstrController.java index 35a60a25..522ba5c5 100644 --- a/src/main/java/com/sparrowwallet/sparrow/joinstr/JoinstrController.java +++ b/src/main/java/com/sparrowwallet/sparrow/joinstr/JoinstrController.java @@ -57,26 +57,21 @@ public class JoinstrController extends JoinstrFormController { } try { - URL url = AppServices.class.getResource("joinstr/" + display.toString().toLowerCase(Locale.ROOT) + ".fxml"); - if(url == null) { - throw new IllegalStateException("Cannot find joinstr/" + display.toString().toLowerCase(Locale.ROOT) + ".fxml"); - } - - FXMLLoader displayLoader = new FXMLLoader(url); - Node joinstrDisplay = displayLoader.load(); - - if(!existing) { - - joinstrDisplay.setUserData(display); - joinstrDisplay.setViewOrder(1); - - joinstrPane.getChildren().add(joinstrDisplay); - } - - JoinstrFormController controller = displayLoader.getController(); - JoinstrForm joinstrForm = getJoinstrForm(); - controller.setJoinstrForm(joinstrForm); - controller.initializeView(); + URL url = AppServices.class.getResource("joinstr/" + display.toString().toLowerCase(Locale.ROOT) + ".fxml"); + if(url == null) { + throw new IllegalStateException("Cannot find joinstr/" + display.toString().toLowerCase(Locale.ROOT) + ".fxml"); + } + FXMLLoader displayLoader = new FXMLLoader(url); + Node joinstrDisplay = displayLoader.load(); + if(!existing) { + joinstrDisplay.setUserData(display); + joinstrDisplay.setViewOrder(1); + joinstrPane.getChildren().add(joinstrDisplay); + } + JoinstrFormController controller = displayLoader.getController(); + JoinstrForm joinstrForm = getJoinstrForm(); + controller.setJoinstrForm(joinstrForm); + controller.initializeView(); } catch (IOException e) { throw new IllegalStateException("Can't find pane", e); diff --git a/src/main/java/com/sparrowwallet/sparrow/joinstr/JoinstrForm.java b/src/main/java/com/sparrowwallet/sparrow/joinstr/JoinstrForm.java index 03807dfd..019ec6f1 100644 --- a/src/main/java/com/sparrowwallet/sparrow/joinstr/JoinstrForm.java +++ b/src/main/java/com/sparrowwallet/sparrow/joinstr/JoinstrForm.java @@ -2,6 +2,7 @@ package com.sparrowwallet.sparrow.joinstr; import com.sparrowwallet.drongo.wallet.Wallet; import com.sparrowwallet.sparrow.io.Storage; +import com.sparrowwallet.sparrow.wallet.WalletForm; import javafx.beans.property.BooleanProperty; import javafx.beans.property.SimpleBooleanProperty; @@ -10,20 +11,22 @@ public class JoinstrForm { private final BooleanProperty lockedProperty = new SimpleBooleanProperty(false); - private final Storage storage; - protected Wallet wallet; + private final WalletForm walletForm; - public JoinstrForm(Storage storage, Wallet currentWallet) { - this.storage = storage; - this.wallet = currentWallet; + public JoinstrForm(WalletForm walletForm) { + this.walletForm = walletForm; + } + + public WalletForm getWalletForm() { + return walletForm; } public Wallet getWallet() { - return wallet; + return walletForm.getWallet(); } public Storage getStorage() { - return storage; + return walletForm.getStorage(); } public BooleanProperty lockedProperty() { diff --git a/src/main/java/com/sparrowwallet/sparrow/joinstr/JoinstrFormController.java b/src/main/java/com/sparrowwallet/sparrow/joinstr/JoinstrFormController.java index 9e631e55..bdd3c3a7 100644 --- a/src/main/java/com/sparrowwallet/sparrow/joinstr/JoinstrFormController.java +++ b/src/main/java/com/sparrowwallet/sparrow/joinstr/JoinstrFormController.java @@ -1,10 +1,15 @@ package com.sparrowwallet.sparrow.joinstr; import com.sparrowwallet.sparrow.BaseController; +import com.sparrowwallet.sparrow.wallet.WalletForm; public abstract class JoinstrFormController extends BaseController { - public JoinstrForm joinstrForm; + private JoinstrForm joinstrForm; + + public WalletForm getWalletForm() { + return joinstrForm.getWalletForm(); + } public JoinstrForm getJoinstrForm() { return joinstrForm; diff --git a/src/main/java/com/sparrowwallet/sparrow/joinstr/JoinstrPool.java b/src/main/java/com/sparrowwallet/sparrow/joinstr/JoinstrPool.java index ca1515d3..2385be7d 100644 --- a/src/main/java/com/sparrowwallet/sparrow/joinstr/JoinstrPool.java +++ b/src/main/java/com/sparrowwallet/sparrow/joinstr/JoinstrPool.java @@ -1,23 +1,44 @@ package com.sparrowwallet.sparrow.joinstr; +import com.sparrowwallet.drongo.address.Address; +import com.sparrowwallet.drongo.protocol.Transaction; +import com.sparrowwallet.drongo.protocol.TransactionOutput; +import com.sparrowwallet.drongo.psbt.PSBT; +import com.sparrowwallet.drongo.wallet.BlockTransactionHashIndex; +import com.sparrowwallet.drongo.wallet.BnBUtxoSelector; +import com.sparrowwallet.drongo.wallet.CoinbaseTxoFilter; +import com.sparrowwallet.drongo.wallet.FrozenTxoFilter; +import com.sparrowwallet.drongo.wallet.InsufficientFundsException; +import com.sparrowwallet.drongo.wallet.KnapsackUtxoSelector; +import com.sparrowwallet.drongo.wallet.Payment; +import com.sparrowwallet.drongo.wallet.SpentTxoFilter; +import com.sparrowwallet.drongo.wallet.TxoFilter; +import com.sparrowwallet.drongo.wallet.UtxoSelector; +import com.sparrowwallet.drongo.wallet.Wallet; +import com.sparrowwallet.drongo.wallet.WalletNode; +import com.sparrowwallet.drongo.wallet.WalletTransaction; +import com.sparrowwallet.sparrow.AppServices; +import com.sparrowwallet.sparrow.io.Config; +import com.sparrowwallet.sparrow.net.Tor; + +import java.util.*; + public class JoinstrPool { - private final String relay; - private final Integer port; + private final Integer port; // Nostr Port ? private final String pubkey; - private final Double denomination; + private final long denomination; // Should be in sats, like transaction amounts - public JoinstrPool(String relay_, Integer port_, String pubkey_, Double denomination_) { + public JoinstrPool(Integer port, String pubkey, long denomination) { - relay = relay_; - port = port_; - pubkey = pubkey_; - denomination = denomination_; + this.port = port; + this.pubkey = pubkey; + this.denomination = denomination; } - public String getRelay() { - return relay; + private String getNostrRelay() { + return Config.get().getNostrRelay(); } public Integer getPort() { @@ -28,8 +49,24 @@ public class JoinstrPool { return pubkey; } - public Double getDenomination() { + public long getDenomination() { return denomination; } + public void getNewTorRoute() { + + Tor tor = Tor.getDefault(); + tor.changeIdentity(); + + } + + public void publicNostrEvent() { + // TODO: Publish a nostr event with pool info + } + + public void waitForPeers() { + // TODO: Wait for others to join + } + + } diff --git a/src/main/java/com/sparrowwallet/sparrow/joinstr/SettingsController.java b/src/main/java/com/sparrowwallet/sparrow/joinstr/SettingsController.java index 45e5ada1..89eb6741 100644 --- a/src/main/java/com/sparrowwallet/sparrow/joinstr/SettingsController.java +++ b/src/main/java/com/sparrowwallet/sparrow/joinstr/SettingsController.java @@ -24,16 +24,21 @@ public class SettingsController extends JoinstrFormController { @Override public void changed(ObservableValue observable, String oldValue, String newValue) { - if(nostrRelayTextField.getText().isEmpty()) { - nostrRelayTextField.setText("wss://nostr.fmt.wiz.biz"); - } + setDefaultNostrRelayIfEmpty(); Config.get().setNostrRelay(nostrRelayTextField.getText()); } }); + setDefaultNostrRelayIfEmpty(); } catch(Exception e) { e.printStackTrace(); } } + public void setDefaultNostrRelayIfEmpty() { + if(nostrRelayTextField.getText().isEmpty()) { + nostrRelayTextField.setText("wss://nostr.fmt.wiz.biz"); + } + } + } diff --git a/src/main/resources/com/sparrowwallet/sparrow/joinstr/new_pool.fxml b/src/main/resources/com/sparrowwallet/sparrow/joinstr/new_pool.fxml index d6868a09..36972b09 100644 --- a/src/main/resources/com/sparrowwallet/sparrow/joinstr/new_pool.fxml +++ b/src/main/resources/com/sparrowwallet/sparrow/joinstr/new_pool.fxml @@ -3,36 +3,62 @@ + - + + + + + + + + +
- +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
- - - - - - -
\ No newline at end of file