Merge remote-tracking branch 'origin/master'

# Conflicts:
#	src/main/java/com/sparrowwallet/sparrow/joinstr/NewPoolController.java
This commit is contained in:
/dev/fd0 2025-06-04 05:21:30 +05:30
commit e6dcd4a549
7 changed files with 137 additions and 66 deletions

View file

@ -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);

View file

@ -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);

View file

@ -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() {

View file

@ -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;

View file

@ -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
}
}

View file

@ -24,16 +24,21 @@ public class SettingsController extends JoinstrFormController {
@Override
public void changed(ObservableValue<? extends String> 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");
}
}
}

View file

@ -3,36 +3,62 @@
<?import javafx.scene.control.*?>
<?import javafx.scene.layout.*?>
<?import javafx.geometry.Insets?>
<?import javafx.collections.FXCollections?>
<BorderPane stylesheets="@joinstr.css, @../wallet/wallet.css, @../general.css" styleClass="wallet-pane" xmlns="http://javafx.com/javafx" xmlns:fx="http://javafx.com/fxml" fx:controller="com.sparrowwallet.sparrow.joinstr.NewPoolController">
<?import com.sparrowwallet.sparrow.control.FiatLabel?>
<?import com.sparrowwallet.drongo.BitcoinUnit?>
<?import org.controlsfx.glyphfont.Glyph?>
<?import tornadofx.control.Form?>
<?import tornadofx.control.Fieldset?>
<?import tornadofx.control.Field?>
<BorderPane stylesheets="@joinstr.css, @../wallet/wallet.css, @../general.css" styleClass="send-form" xmlns="http://javafx.com/javafx" xmlns:fx="http://javafx.com/fxml" fx:controller="com.sparrowwallet.sparrow.joinstr.NewPoolController">
<padding>
<Insets top="30" right="30" bottom="30" left="30"/>
</padding>
<center>
<VBox maxWidth="Infinity" fx:id="contentVBox" spacing="20">
<VBox maxWidth="Infinity" HBox.hgrow="ALWAYS">
<Label styleClass="sub-title">Create a new pool</Label>
<Form maxWidth="Infinity" style="-fx-max-width: 600px;">
<Fieldset inputGrow="ALWAYS">
<Field text="Pay to:">
<Label fx:id="addressLabel" />
</Field>
<Field text="Label:">
<TextField fx:id="labelField" promptText="Required" style="-fx-max-width: 250px;">
<tooltip>
<Tooltip text="Required to label the transaction (privately in this wallet)"/>
</tooltip>
</TextField>
</Field>
<Field text="UTXO:">
<ComboBox fx:id="utxosComboBox" styleClass="amount-unit" style="-fx-max-width: 150px;" onAction="#setUtxoAmount" />
<TextField fx:id="amountField" disable="true" style="-fx-max-width: 100px;-fx-text-fill: white;" />
</Field>
<Field text="Denomination:" style="-fx-text-fill: #aaaaaa;">
<TextField fx:id="denominationField" promptText="Required" style="-fx-max-width: 100px;-fx-background-color: #444444; -fx-text-fill: white; -fx-prompt-text-fill: #888888;">
<tooltip>
<Tooltip text="Required to create coinjoin pool"/>
</tooltip>
</TextField>
<ComboBox fx:id="denominationUnit" styleClass="amount-unit" style="-fx-min-width: 60px;" onAction="#handleDenominationUnitChange">
<items>
<FXCollections fx:factory="observableArrayList">
<BitcoinUnit fx:constant="BTC" />
<BitcoinUnit fx:constant="SATOSHIS" />
</FXCollections>
</items>
</ComboBox>
</Field>
<Field text="Number of Peers:" style="-fx-text-fill: #aaaaaa;">
<TextField fx:id="peersField" promptText="Req." style="-fx-max-width: 50px;-fx-background-color: #444444; -fx-text-fill: white; -fx-prompt-text-fill: #888888;" />
</Field>
<Field>
<ToggleButton fx:id="createButton" text="Create" onAction="#handleCreateButton" style="-fx-background-color: #2196F3; -fx-text-fill: white; -fx-cursor: hand;" />
</Field>
</Fieldset>
</Form>
</VBox>
<GridPane hgap="10" vgap="15" maxWidth="600">
<padding>
<Insets top="20"/>
</padding>
<Label text="Denomination (BTC):" GridPane.rowIndex="0" GridPane.columnIndex="0" style="-fx-text-fill: #aaaaaa;"/>
<TextField fx:id="denominationField" GridPane.rowIndex="0" GridPane.columnIndex="1"
style="-fx-background-color: #444444; -fx-text-fill: white; -fx-prompt-text-fill: #888888;"
promptText="Enter denomination"/>
<Label text="Number of Peers:" GridPane.rowIndex="1" GridPane.columnIndex="0" style="-fx-text-fill: #aaaaaa;"/>
<TextField fx:id="peersField" GridPane.rowIndex="1" GridPane.columnIndex="1"
style="-fx-background-color: #444444; -fx-text-fill: white; -fx-prompt-text-fill: #888888;"
promptText="Enter number of peers"/>
<Button fx:id="createButton" text="Create" GridPane.rowIndex="2" GridPane.columnIndex="1"
onAction="#handleCreateButton"
style="-fx-background-color: #2196F3; -fx-text-fill: white; -fx-cursor: hand;"/>
</GridPane>
</VBox>
</center>
</BorderPane>