Skip to content

Commit

Permalink
Wallet: Add printAllPubKeysAsHex()
Browse files Browse the repository at this point in the history
Add tool for manually creating the payout tx. Change shortcuts
Cherry pick bisq-network@97a7350
  • Loading branch information
ManfredKarrer authored and oscarguindzberg committed Dec 20, 2018
1 parent 6ebcdd5 commit ec28f6b
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 0 deletions.
Expand Up @@ -1314,6 +1314,11 @@ public Script freshOutputScript(KeyPurpose purpose) {
throw new UnsupportedOperationException();
}

public void printAllPubKeysAsHex(StringBuilder stringBuilder) {
for (ECKey key : getKeys(false))
stringBuilder.append('"').append(Utils.HEX.encode(key.getPubKey())).append('"').append(",\n");
}

public String toString(boolean includePrivateKeys, NetworkParameters params) {
final DeterministicKey watchingKey = getWatchingKey();
final StringBuilder builder = new StringBuilder();
Expand Down
13 changes: 13 additions & 0 deletions core/src/main/java/org/bitcoinj/wallet/KeyChainGroup.java
Expand Up @@ -786,6 +786,19 @@ private static void extractFollowingKeychains(List<DeterministicKeyChain> chains
}
}

public String printAllPubKeysAsHex() {
StringBuilder stringBuilder = new StringBuilder();
if (basic != null) {
List<ECKey> keys = basic.getKeys();
Collections.sort(keys, ECKey.AGE_COMPARATOR);
for (ECKey key : keys)
stringBuilder.append('"').append(Utils.HEX.encode(key.getPubKey())).append('"').append(",\n");
}
for (DeterministicKeyChain chain : chains)
chain.printAllPubKeysAsHex(stringBuilder);
return stringBuilder.toString();
}

public String toString(boolean includePrivateKeys) {
final StringBuilder builder = new StringBuilder();
if (basic != null) {
Expand Down
3 changes: 3 additions & 0 deletions core/src/main/java/org/bitcoinj/wallet/Wallet.java
Expand Up @@ -3165,6 +3165,9 @@ public String toString() {
return toString(false, true, true, null);
}

public String printAllPubKeysAsHex() {
return keyChainGroup.printAllPubKeysAsHex();
}

/**
* Formats the wallet as a human readable piece of text. Intended for debugging, the format is not meant to be
Expand Down

0 comments on commit ec28f6b

Please sign in to comment.