mirror of
https://github.com/bitcoinj/bitcoinj.git
synced 2025-02-22 14:22:45 +01:00
Wallet: remove deprecated methods
Remove all deprecated methods except one deprecated constructor that is used in a unit test and marked as @VisibleForTesting.
This commit is contained in:
parent
4e8a19997d
commit
8f3ac79030
3 changed files with 4 additions and 102 deletions
|
@ -364,18 +364,6 @@ public class Wallet extends BaseTaggableObject
|
|||
return new Wallet(params, KeyChainGroup.builder(params, structure).fromSeed(seed, outputScriptType).build());
|
||||
}
|
||||
|
||||
/**
|
||||
* @param params network parameters
|
||||
* @param seed deterministic seed
|
||||
* @return a wallet from a deterministic seed with a
|
||||
* {@link DeterministicKeyChain#ACCOUNT_ZERO_PATH 0 hardened path}
|
||||
* @deprecated Use {@link #fromSeed(NetworkParameters, DeterministicSeed, ScriptType, KeyChainGroupStructure)}
|
||||
*/
|
||||
@Deprecated
|
||||
public static Wallet fromSeed(NetworkParameters params, DeterministicSeed seed) {
|
||||
return fromSeed(params, seed, Script.ScriptType.P2PKH);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param params network parameters
|
||||
* @param seed deterministic seed
|
||||
|
@ -390,18 +378,6 @@ public class Wallet extends BaseTaggableObject
|
|||
return new Wallet(params, KeyChainGroup.builder(params).addChain(chain).build());
|
||||
}
|
||||
|
||||
/**
|
||||
* @param params network parameters
|
||||
* @param seed deterministic seed
|
||||
* @param accountPath account path
|
||||
* @return an instance of a wallet from a deterministic seed.
|
||||
* @deprecated Use {@link #fromSeed(NetworkParameters, DeterministicSeed, ScriptType, List)}
|
||||
*/
|
||||
@Deprecated
|
||||
public static Wallet fromSeed(NetworkParameters params, DeterministicSeed seed, List<ChildNumber> accountPath) {
|
||||
return fromSeed(params, seed, Script.ScriptType.P2PKH, accountPath);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a wallet that tracks payments to and from the HD key hierarchy rooted by the given watching key. This HAS
|
||||
* to be an account key as returned by {@link DeterministicKeyChain#getWatchingKey()}.
|
||||
|
@ -413,16 +389,6 @@ public class Wallet extends BaseTaggableObject
|
|||
return new Wallet(params, KeyChainGroup.builder(params).addChain(chain).build());
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a wallet that tracks payments to and from the HD key hierarchy rooted by the given watching key. This HAS
|
||||
* to be an account key as returned by {@link DeterministicKeyChain#getWatchingKey()}.
|
||||
* @deprecated Use {@link #fromWatchingKey(NetworkParameters, DeterministicKey, ScriptType)}
|
||||
*/
|
||||
@Deprecated
|
||||
public static Wallet fromWatchingKey(NetworkParameters params, DeterministicKey watchKey) {
|
||||
return fromWatchingKey(params, watchKey, Script.ScriptType.P2PKH);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a wallet that tracks payments to and from the HD key hierarchy rooted by the given watching key. The
|
||||
* account path is specified. The key is specified in base58 notation and the creation time of the key. If you don't
|
||||
|
@ -445,16 +411,6 @@ public class Wallet extends BaseTaggableObject
|
|||
return new Wallet(params, KeyChainGroup.builder(params).addChain(chain).build());
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a wallet that tracks payments to and from the HD key hierarchy rooted by the given spending key. This HAS
|
||||
* to be an account key as returned by {@link DeterministicKeyChain#getWatchingKey()}. This wallet can also spend.
|
||||
* @deprecated Use {@link #fromSpendingKey(NetworkParameters, DeterministicKey, ScriptType)}
|
||||
*/
|
||||
@Deprecated
|
||||
public static Wallet fromSpendingKey(NetworkParameters params, DeterministicKey spendKey) {
|
||||
return fromSpendingKey(params, spendKey, Script.ScriptType.P2PKH);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a wallet that tracks payments to and from the HD key hierarchy rooted by the given spending key.
|
||||
* The key is specified in base58 notation and the creation time of the key. If you don't know the creation time,
|
||||
|
@ -480,19 +436,6 @@ public class Wallet extends BaseTaggableObject
|
|||
return new Wallet(params, KeyChainGroup.builder(params).addChain(chain).build());
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Use {@link #createBasic(NetworkParameters)}, then {@link #importKeys(List)}.
|
||||
*/
|
||||
@Deprecated
|
||||
public static Wallet fromKeys(NetworkParameters params, List<ECKey> keys) {
|
||||
for (ECKey key : keys)
|
||||
checkArgument(!(key instanceof DeterministicKey));
|
||||
|
||||
KeyChainGroup group = KeyChainGroup.builder(params).build();
|
||||
group.importKeys(keys);
|
||||
return new Wallet(params, group);
|
||||
}
|
||||
|
||||
private static Script.ScriptType outputScriptTypeFromB58(NetworkParameters params, String base58) {
|
||||
int header = ByteBuffer.wrap(Base58.decodeChecked(base58)).getInt();
|
||||
if (header == params.getBip32HeaderP2PKHpub() || header == params.getBip32HeaderP2PKHpriv())
|
||||
|
@ -774,12 +717,6 @@ public class Wallet extends BaseTaggableObject
|
|||
}
|
||||
}
|
||||
|
||||
/** @deprecated Use {@link #upgradeToDeterministic(ScriptType, KeyParameter)} */
|
||||
@Deprecated
|
||||
public void upgradeToDeterministic(@Nullable KeyParameter aesKey) {
|
||||
upgradeToDeterministic(Script.ScriptType.P2PKH, aesKey);
|
||||
}
|
||||
|
||||
/**
|
||||
* Upgrades the wallet to be deterministic (BIP32). You should call this, possibly providing the users encryption
|
||||
* key, after loading a wallet produced by previous versions of bitcoinj. If the wallet is encrypted the key
|
||||
|
@ -810,12 +747,6 @@ public class Wallet extends BaseTaggableObject
|
|||
}
|
||||
}
|
||||
|
||||
/** @deprecated Use {@link #isDeterministicUpgradeRequired(ScriptType)} */
|
||||
@Deprecated
|
||||
public boolean isDeterministicUpgradeRequired() {
|
||||
return isDeterministicUpgradeRequired(Script.ScriptType.P2PKH);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the wallet contains random keys and no HD chains, in which case you should call
|
||||
* {@link #upgradeToDeterministic(ScriptType, KeyParameter)} before attempting to do anything
|
||||
|
@ -1168,12 +1099,6 @@ public class Wallet extends BaseTaggableObject
|
|||
}
|
||||
}
|
||||
|
||||
/** @deprecated Use {@link #findKeyFromPubKeyHash(byte[], ScriptType)} */
|
||||
@Deprecated
|
||||
public ECKey findKeyFromPubHash(byte[] pubKeyHash) {
|
||||
return findKeyFromPubKeyHash(pubKeyHash, Script.ScriptType.P2PKH);
|
||||
}
|
||||
|
||||
/**
|
||||
* Locates a keypair from the basicKeyChain given the hash of the public key. This is needed when finding out which
|
||||
* key we need to use to redeem a transaction output.
|
||||
|
@ -1216,12 +1141,6 @@ public class Wallet extends BaseTaggableObject
|
|||
throw new IllegalArgumentException(address.toString());
|
||||
}
|
||||
|
||||
/** @deprecated Use {@link #isPubKeyHashMine(byte[], ScriptType)} */
|
||||
@Deprecated
|
||||
public boolean isPubKeyHashMine(byte[] pubKeyHash) {
|
||||
return isPubKeyHashMine(pubKeyHash, Script.ScriptType.P2PKH);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPubKeyHashMine(byte[] pubKeyHash, @Nullable Script.ScriptType scriptType) {
|
||||
return findKeyFromPubKeyHash(pubKeyHash, scriptType) != null;
|
||||
|
@ -3406,24 +3325,6 @@ public class Wallet extends BaseTaggableObject
|
|||
return toString(false, false, null, true, true, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* @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(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.
|
||||
|
|
|
@ -43,7 +43,7 @@ public class DefaultRiskAnalysisTest {
|
|||
|
||||
@Before
|
||||
public void setup() {
|
||||
wallet = new Wallet(new Context(MAINNET));
|
||||
wallet = Wallet.createDeterministic(new Context(MAINNET), Script.ScriptType.P2PKH);
|
||||
wallet.setLastBlockSeenHeight(1000);
|
||||
wallet.setLastBlockSeenTimeSecs(TIMESTAMP);
|
||||
}
|
||||
|
|
|
@ -3333,9 +3333,10 @@ public class WalletTest extends TestWithWallet {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void fromKeys() {
|
||||
public void createBasicWithKeys() {
|
||||
ECKey key = ECKey.fromPrivate(Utils.HEX.decode("00905b93f990267f4104f316261fc10f9f983551f9ef160854f40102eb71cffdcc"));
|
||||
Wallet wallet = Wallet.fromKeys(UNITTEST, Arrays.asList(key));
|
||||
Wallet wallet = Wallet.createBasic(UNITTEST);
|
||||
wallet.importKey(key);
|
||||
assertEquals(1, wallet.getImportedKeys().size());
|
||||
assertEquals(key, wallet.getImportedKeys().get(0));
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue