mirror of
https://github.com/Qortal/altcoinj.git
synced 2025-11-02 05:27:17 +00:00
Wallet: In toString(), add a flag for including the lookahead keys into the dump.
This commit is contained in:
@@ -1371,7 +1371,7 @@ public class DeterministicKeyChain implements EncryptableKeyChain {
|
||||
return helper.toString();
|
||||
}
|
||||
|
||||
public String toString(boolean includePrivateKeys, @Nullable KeyParameter aesKey, NetworkParameters params) {
|
||||
public String toString(boolean includeLookahead, boolean includePrivateKeys, @Nullable KeyParameter aesKey, NetworkParameters params) {
|
||||
final DeterministicKey watchingKey = getWatchingKey();
|
||||
final StringBuilder builder = new StringBuilder();
|
||||
if (seed != null) {
|
||||
@@ -1396,13 +1396,13 @@ public class DeterministicKeyChain implements EncryptableKeyChain {
|
||||
builder.append("Key to watch: ").append(watchingKey.serializePubB58(params, outputScriptType))
|
||||
.append('\n');
|
||||
builder.append("Lookahead siz/thr: ").append(lookaheadSize).append('/').append(lookaheadThreshold).append('\n');
|
||||
formatAddresses(includePrivateKeys, aesKey, params, builder);
|
||||
formatAddresses(includeLookahead, includePrivateKeys, aesKey, params, builder);
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
protected void formatAddresses(boolean includePrivateKeys, @Nullable KeyParameter aesKey, NetworkParameters params,
|
||||
StringBuilder builder) {
|
||||
for (DeterministicKey key : getKeys(false, true)) {
|
||||
protected void formatAddresses(boolean includeLookahead, boolean includePrivateKeys, @Nullable KeyParameter aesKey,
|
||||
NetworkParameters params, StringBuilder builder) {
|
||||
for (DeterministicKey key : getKeys(includeLookahead, true)) {
|
||||
String comment = null;
|
||||
if (key.equals(rootKey))
|
||||
comment = "root";
|
||||
|
||||
@@ -1006,13 +1006,13 @@ public class KeyChainGroup implements KeyBag {
|
||||
}
|
||||
}
|
||||
|
||||
public String toString(boolean includePrivateKeys, @Nullable KeyParameter aesKey) {
|
||||
public String toString(boolean includeLookahead, boolean includePrivateKeys, @Nullable KeyParameter aesKey) {
|
||||
final StringBuilder builder = new StringBuilder();
|
||||
if (basic != null)
|
||||
builder.append(basic.toString(includePrivateKeys, aesKey, params));
|
||||
if (chains != null)
|
||||
for (DeterministicKeyChain chain : chains)
|
||||
builder.append(chain.toString(includePrivateKeys, aesKey, params)).append('\n');
|
||||
builder.append(chain.toString(includeLookahead, includePrivateKeys, aesKey, params)).append('\n');
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
|
||||
@@ -233,14 +233,14 @@ public class MarriedKeyChain extends DeterministicKeyChain {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void formatAddresses(boolean includePrivateKeys, @Nullable KeyParameter aesKey, NetworkParameters params,
|
||||
StringBuilder builder2) {
|
||||
protected void formatAddresses(boolean includeLookahead, boolean includePrivateKeys, @Nullable KeyParameter aesKey,
|
||||
NetworkParameters params, StringBuilder builder) {
|
||||
for (DeterministicKeyChain followingChain : followingKeyChains)
|
||||
builder2.append("Following chain: ").append(followingChain.getWatchingKey().serializePubB58(params))
|
||||
builder.append("Following chain: ").append(followingChain.getWatchingKey().serializePubB58(params))
|
||||
.append('\n');
|
||||
builder2.append('\n');
|
||||
builder.append('\n');
|
||||
for (RedeemData redeemData : marriedKeysRedeemData.values())
|
||||
formatScript(ScriptBuilder.createP2SHOutputScript(redeemData.redeemScript), builder2, params);
|
||||
formatScript(ScriptBuilder.createP2SHOutputScript(redeemData.redeemScript), builder, params);
|
||||
}
|
||||
|
||||
private void formatScript(Script script, StringBuilder builder, NetworkParameters params) {
|
||||
|
||||
@@ -3335,29 +3335,39 @@ public class Wallet extends BaseTaggableObject
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return toString(false, null, true, true, null);
|
||||
return toString(false, false, null, true, true, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Use {@link #toString(boolean, KeyParameter, boolean, boolean, AbstractBlockChain)} instead.
|
||||
* @deprecated Use {@link #toString(boolean, boolean, KeyParameter, boolean, boolean, AbstractBlockChain)} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
public String toString(boolean includePrivateKeys, boolean includeTransactions, boolean includeExtensions,
|
||||
@Nullable AbstractBlockChain chain) {
|
||||
return toString(includePrivateKeys, null, includeTransactions, includeExtensions, chain);
|
||||
return toString(false, includePrivateKeys, null, includeTransactions, includeExtensions, chain);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Use {@link #toString(boolean, boolean, KeyParameter, boolean, boolean, AbstractBlockChain)} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
public String toString(boolean includePrivateKeys, @Nullable KeyParameter aesKey, boolean includeTransactions,
|
||||
boolean includeExtensions, @Nullable AbstractBlockChain chain) {
|
||||
return toString(false, includePrivateKeys, aesKey, includeTransactions, includeExtensions, chain);
|
||||
}
|
||||
|
||||
/**
|
||||
* Formats the wallet as a human readable piece of text. Intended for debugging, the format is not meant to be
|
||||
* stable or human readable.
|
||||
* @param includeLookahead Wether lookahead keys should be included.
|
||||
* @param includePrivateKeys Whether raw private key data should be included.
|
||||
* @param aesKey for decrypting private key data for if the wallet is encrypted.
|
||||
* @param includeTransactions Whether to print transaction data.
|
||||
* @param includeExtensions Whether to print extension data.
|
||||
* @param chain If set, will be used to estimate lock times for block timelocked transactions.
|
||||
*/
|
||||
public String toString(boolean includePrivateKeys, @Nullable KeyParameter aesKey, boolean includeTransactions,
|
||||
boolean includeExtensions, @Nullable AbstractBlockChain chain) {
|
||||
public String toString(boolean includeLookahead, boolean includePrivateKeys, @Nullable KeyParameter aesKey,
|
||||
boolean includeTransactions, boolean includeExtensions, @Nullable AbstractBlockChain chain) {
|
||||
lock.lock();
|
||||
keyChainGroupLock.lock();
|
||||
try {
|
||||
@@ -3390,7 +3400,7 @@ public class Wallet extends BaseTaggableObject
|
||||
final Date keyRotationTime = getKeyRotationTime();
|
||||
if (keyRotationTime != null)
|
||||
builder.append("Key rotation time: ").append(Utils.dateTimeFormat(keyRotationTime)).append('\n');
|
||||
builder.append(keyChainGroup.toString(includePrivateKeys, aesKey));
|
||||
builder.append(keyChainGroup.toString(includeLookahead, includePrivateKeys, aesKey));
|
||||
|
||||
if (!watchedScripts.isEmpty()) {
|
||||
builder.append("\nWatched scripts:\n");
|
||||
|
||||
Reference in New Issue
Block a user