Skip to content

Commit

Permalink
Add missing segwit BSQ keychain path to wallet info
Browse files Browse the repository at this point in the history
Add the new account path "44'/142'/1'" for segwit BSQ to the wallet info
view, which was missed from PR bisq-network#5109 making the wallet & UI changes to
implement segwit BSQ. Also format the paths from the constants defined
in 'BisqKeyChainGroupStructure', instead of using string literals, so
that they are only defined in one place. (Though it is extremely
unlikely the paths would ever change.)
  • Loading branch information
stejbac authored and helixx87 committed May 6, 2023
1 parent d9769fc commit d99c012
Showing 1 changed file with 18 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import bisq.desktop.util.Layout;

import bisq.core.btc.listeners.BalanceListener;
import bisq.core.btc.setup.BisqKeyChainGroupStructure;
import bisq.core.btc.wallet.BsqWalletService;
import bisq.core.btc.wallet.BtcWalletService;
import bisq.core.btc.wallet.WalletService;
Expand All @@ -38,16 +39,21 @@

import org.bitcoinj.core.Coin;
import org.bitcoinj.core.Transaction;
import org.bitcoinj.crypto.ChildNumber;
import org.bitcoinj.script.Script;
import org.bitcoinj.wallet.DeterministicKeyChain;

import javax.inject.Inject;
import javax.inject.Named;

import com.google.common.base.Joiner;

import javafx.scene.control.Button;
import javafx.scene.control.TextField;
import javafx.scene.layout.GridPane;

import java.util.List;

import static bisq.desktop.util.FormBuilder.addButtonAfterGroup;
import static bisq.desktop.util.FormBuilder.addMultilineLabel;
import static bisq.desktop.util.FormBuilder.addTitledGroupBg;
Expand Down Expand Up @@ -104,9 +110,14 @@ public void initialize() {

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);
addTopLabelTextField(root, ++gridRow, Res.get("account.menu.walletInfo.walletSelector", "BTC", "legacy"), "44'/0'/0'", -Layout.FLOATING_LABEL_DISTANCE);
addTopLabelTextField(root, ++gridRow, Res.get("account.menu.walletInfo.walletSelector", "BTC", "segwit"), "44'/0'/1'", -Layout.FLOATING_LABEL_DISTANCE);
addTopLabelTextField(root, ++gridRow, Res.get("account.menu.walletInfo.walletSelector", "BSQ", ""), "44'/142'/0'", -Layout.FLOATING_LABEL_DISTANCE);
addTopLabelTextField(root, ++gridRow, Res.get("account.menu.walletInfo.walletSelector", "BTC", "legacy"),
formatAccountPath(BisqKeyChainGroupStructure.BIP44_BTC_NON_SEGWIT_ACCOUNT_PATH), -Layout.FLOATING_LABEL_DISTANCE);
addTopLabelTextField(root, ++gridRow, Res.get("account.menu.walletInfo.walletSelector", "BTC", "segwit"),
formatAccountPath(BisqKeyChainGroupStructure.BIP44_BTC_SEGWIT_ACCOUNT_PATH), -Layout.FLOATING_LABEL_DISTANCE);
addTopLabelTextField(root, ++gridRow, Res.get("account.menu.walletInfo.walletSelector", "BSQ", "legacy"),
formatAccountPath(BisqKeyChainGroupStructure.BIP44_BSQ_NON_SEGWIT_ACCOUNT_PATH), -Layout.FLOATING_LABEL_DISTANCE);
addTopLabelTextField(root, ++gridRow, Res.get("account.menu.walletInfo.walletSelector", "BSQ", "segwit"),
formatAccountPath(BisqKeyChainGroupStructure.BIP44_BSQ_SEGWIT_ACCOUNT_PATH), -Layout.FLOATING_LABEL_DISTANCE);

openDetailsButton = addButtonAfterGroup(root, ++gridRow, Res.get("account.menu.walletInfo.openDetails"));

Expand All @@ -124,6 +135,10 @@ public void onBalanceChanged(Coin balanceAsCoin, Transaction tx) {
};
}

private String formatAccountPath(List<ChildNumber> path) {
return Joiner.on('/').join(path).replace('H', '\'');
}


@Override
protected void activate() {
Expand Down Expand Up @@ -170,6 +185,4 @@ private void updateBalances(WalletService walletService) {
bsqTextField.setText(bsqFormatter.formatCoinWithCode(walletService.getBalance(ESTIMATED_SPENDABLE)));
}
}

}

0 comments on commit d99c012

Please sign in to comment.