mirror of
https://github.com/bisq-network/bisq.git
synced 2025-02-23 23:06:39 +01:00
Merge pull request #6604 from stejbac/add-missing-keychain-path-to-wallet-info
Add missing segwit BSQ keychain path to wallet info
This commit is contained in:
commit
324f5ef179
1 changed files with 28 additions and 17 deletions
|
@ -38,16 +38,21 @@ import bisq.common.config.Config;
|
||||||
|
|
||||||
import org.bitcoinj.core.Coin;
|
import org.bitcoinj.core.Coin;
|
||||||
import org.bitcoinj.core.Transaction;
|
import org.bitcoinj.core.Transaction;
|
||||||
|
import org.bitcoinj.crypto.ChildNumber;
|
||||||
import org.bitcoinj.script.Script;
|
import org.bitcoinj.script.Script;
|
||||||
import org.bitcoinj.wallet.DeterministicKeyChain;
|
import org.bitcoinj.wallet.DeterministicKeyChain;
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
import javax.inject.Named;
|
import javax.inject.Named;
|
||||||
|
|
||||||
|
import com.google.common.base.Joiner;
|
||||||
|
|
||||||
import javafx.scene.control.Button;
|
import javafx.scene.control.Button;
|
||||||
import javafx.scene.control.TextField;
|
import javafx.scene.control.TextField;
|
||||||
import javafx.scene.layout.GridPane;
|
import javafx.scene.layout.GridPane;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import static bisq.desktop.util.FormBuilder.addButtonAfterGroup;
|
import static bisq.desktop.util.FormBuilder.addButtonAfterGroup;
|
||||||
import static bisq.desktop.util.FormBuilder.addMultilineLabel;
|
import static bisq.desktop.util.FormBuilder.addMultilineLabel;
|
||||||
import static bisq.desktop.util.FormBuilder.addTitledGroupBg;
|
import static bisq.desktop.util.FormBuilder.addTitledGroupBg;
|
||||||
|
@ -97,18 +102,15 @@ public class WalletInfoView extends ActivatableView<GridPane, Void> {
|
||||||
bsqTextField = addTopLabelTextField(root, ++gridRow, "BSQ", -Layout.FLOATING_LABEL_DISTANCE).second;
|
bsqTextField = addTopLabelTextField(root, ++gridRow, "BSQ", -Layout.FLOATING_LABEL_DISTANCE).second;
|
||||||
|
|
||||||
addTitledGroupBg(root, ++gridRow, 4, Res.get("account.menu.walletInfo.xpub.headLine"), Layout.GROUP_DISTANCE);
|
addTitledGroupBg(root, ++gridRow, 4, Res.get("account.menu.walletInfo.xpub.headLine"), Layout.GROUP_DISTANCE);
|
||||||
addXpubKeys(btcWalletService, "BTC", gridRow, Layout.FIRST_ROW_AND_GROUP_DISTANCE);
|
addXpubKeys(btcWalletService, "BTC", Layout.FIRST_ROW_AND_GROUP_DISTANCE);
|
||||||
++gridRow; // update gridRow
|
addXpubKeys(bsqWalletService, "BSQ", -Layout.FLOATING_LABEL_DISTANCE);
|
||||||
addXpubKeys(bsqWalletService, "BSQ", ++gridRow, -Layout.FLOATING_LABEL_DISTANCE);
|
|
||||||
++gridRow; // update gridRow
|
|
||||||
|
|
||||||
addTitledGroupBg(root, ++gridRow, 4, Res.get("account.menu.walletInfo.path.headLine"), Layout.GROUP_DISTANCE);
|
addTitledGroupBg(root, gridRow, 4, Res.get("account.menu.walletInfo.path.headLine"), Layout.GROUP_DISTANCE);
|
||||||
addMultilineLabel(root, gridRow, Res.get("account.menu.walletInfo.path.info"), Layout.FIRST_ROW_AND_GROUP_DISTANCE, Double.MAX_VALUE);
|
addMultilineLabel(root, gridRow++, Res.get("account.menu.walletInfo.path.info"), Layout.FIRST_ROW_AND_GROUP_DISTANCE, Double.MAX_VALUE);
|
||||||
addTopLabelTextField(root, ++gridRow, Res.get("account.menu.walletInfo.walletSelector", "BTC", "legacy"), "44'/0'/0'", -Layout.FLOATING_LABEL_DISTANCE);
|
addAccountPaths(btcWalletService, "BTC");
|
||||||
addTopLabelTextField(root, ++gridRow, Res.get("account.menu.walletInfo.walletSelector", "BTC", "segwit"), "44'/0'/1'", -Layout.FLOATING_LABEL_DISTANCE);
|
addAccountPaths(bsqWalletService, "BSQ");
|
||||||
addTopLabelTextField(root, ++gridRow, Res.get("account.menu.walletInfo.walletSelector", "BSQ", ""), "44'/142'/0'", -Layout.FLOATING_LABEL_DISTANCE);
|
|
||||||
|
|
||||||
openDetailsButton = addButtonAfterGroup(root, ++gridRow, Res.get("account.menu.walletInfo.openDetails"));
|
openDetailsButton = addButtonAfterGroup(root, gridRow, Res.get("account.menu.walletInfo.openDetails"));
|
||||||
|
|
||||||
btcWalletBalanceListener = new BalanceListener() {
|
btcWalletBalanceListener = new BalanceListener() {
|
||||||
@Override
|
@Override
|
||||||
|
@ -148,21 +150,32 @@ public class WalletInfoView extends ActivatableView<GridPane, Void> {
|
||||||
openDetailsButton.setOnAction(null);
|
openDetailsButton.setOnAction(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addXpubKeys(WalletService walletService, String currency, int gridRow, double top) {
|
private void addXpubKeys(WalletService walletService, String currency, double top) {
|
||||||
int row = gridRow;
|
|
||||||
double topDist = top;
|
double topDist = top;
|
||||||
for (DeterministicKeyChain chain : walletService.getWallet().getActiveKeyChains()) {
|
for (DeterministicKeyChain chain : walletService.getWallet().getActiveKeyChains()) {
|
||||||
Script.ScriptType outputScriptType = chain.getOutputScriptType();
|
Script.ScriptType outputScriptType = chain.getOutputScriptType();
|
||||||
String type = outputScriptType == Script.ScriptType.P2WPKH ? "segwit" : "legacy";
|
String type = outputScriptType == Script.ScriptType.P2WPKH ? "segwit" : "legacy";
|
||||||
String key = chain.getWatchingKey().serializePubB58(Config.baseCurrencyNetworkParameters(), outputScriptType);
|
String key = chain.getWatchingKey().serializePubB58(Config.baseCurrencyNetworkParameters(), outputScriptType);
|
||||||
addTopLabelTextField(root, row,
|
addTopLabelTextField(root, gridRow++, Res.get("account.menu.walletInfo.walletSelector", currency, type),
|
||||||
Res.get("account.menu.walletInfo.walletSelector", currency, type),
|
|
||||||
key, topDist);
|
key, topDist);
|
||||||
row++;
|
|
||||||
topDist = -Layout.FLOATING_LABEL_DISTANCE;
|
topDist = -Layout.FLOATING_LABEL_DISTANCE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void addAccountPaths(WalletService walletService, String currency) {
|
||||||
|
for (DeterministicKeyChain chain : walletService.getWallet().getActiveKeyChains()) {
|
||||||
|
Script.ScriptType outputScriptType = chain.getOutputScriptType();
|
||||||
|
String type = outputScriptType == Script.ScriptType.P2WPKH ? "segwit" : "legacy";
|
||||||
|
String path = formatAccountPath(chain.getAccountPath());
|
||||||
|
addTopLabelTextField(root, gridRow++, Res.get("account.menu.walletInfo.walletSelector", currency, type),
|
||||||
|
path, -Layout.FLOATING_LABEL_DISTANCE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private String formatAccountPath(List<ChildNumber> path) {
|
||||||
|
return Joiner.on('/').join(path).replace('H', '\'');
|
||||||
|
}
|
||||||
|
|
||||||
private void updateBalances(WalletService walletService) {
|
private void updateBalances(WalletService walletService) {
|
||||||
if (walletService instanceof BtcWalletService) {
|
if (walletService instanceof BtcWalletService) {
|
||||||
btcTextField.setText(btcFormatter.formatCoinWithCode(walletService.getBalance(ESTIMATED_SPENDABLE)));
|
btcTextField.setText(btcFormatter.formatCoinWithCode(walletService.getBalance(ESTIMATED_SPENDABLE)));
|
||||||
|
@ -170,6 +183,4 @@ public class WalletInfoView extends ActivatableView<GridPane, Void> {
|
||||||
bsqTextField.setText(bsqFormatter.formatCoinWithCode(walletService.getBalance(ESTIMATED_SPENDABLE)));
|
bsqTextField.setText(bsqFormatter.formatCoinWithCode(walletService.getBalance(ESTIMATED_SPENDABLE)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue