"Disposable" wallets renamed to "null seed" wallets, as this is a better description of what they are.

This commit is contained in:
CalDescent 2022-05-28 14:28:42 +02:00
parent 9a4ce57001
commit f14b494bfc
3 changed files with 29 additions and 29 deletions

View File

@ -106,8 +106,8 @@ public class PirateChainWalletController extends Thread {
try {
this.currentWallet = new PirateWallet(entropyBytes, false);
if (!this.currentWallet.isReady() || this.currentWallet.isDisposable()) {
// Don't persist wallets that aren't ready or are disposable
if (!this.currentWallet.isReady() || this.currentWallet.hasNullSeed()) {
// Don't persist wallets that aren't ready or are null seed
this.currentWallet = null;
}
return true;
@ -118,7 +118,7 @@ public class PirateChainWalletController extends Thread {
return false;
}
public PirateWallet switchToDisposableWallet() {
public PirateWallet switchToNullWallet() {
try {
this.currentWallet = null;
return new PirateWallet(null, true);
@ -160,9 +160,9 @@ public class PirateChainWalletController extends Thread {
}
}
public void ensureNotDisposable() throws ForeignBlockchainException {
// Safety check to make sure funds aren't sent to a disposable wallet
if (this.currentWallet == null || this.currentWallet.isDisposable()) {
public void ensureNotNullSeed() throws ForeignBlockchainException {
// Safety check to make sure funds aren't sent to a null seed wallet
if (this.currentWallet == null || this.currentWallet.hasNullSeed()) {
throw new ForeignBlockchainException("Invalid wallet");
}
}

View File

@ -263,7 +263,7 @@ public class PirateChain extends Bitcoiny {
walletController.initWithEntropy58(entropy58);
walletController.ensureInitialized();
walletController.ensureSynchronized();
walletController.ensureNotDisposable();
walletController.ensureNotNullSeed();
// Get balance
String response = LiteWalletJni.execute("balance", "");
@ -282,7 +282,7 @@ public class PirateChain extends Bitcoiny {
walletController.initWithEntropy58(entropy58);
walletController.ensureInitialized();
walletController.ensureSynchronized();
walletController.ensureNotDisposable();
walletController.ensureNotNullSeed();
List<SimpleTransaction> transactions = new ArrayList<>();
@ -332,7 +332,7 @@ public class PirateChain extends Bitcoiny {
PirateChainWalletController walletController = PirateChainWalletController.getInstance();
walletController.initWithEntropy58(entropy58);
walletController.ensureInitialized();
walletController.ensureNotDisposable();
walletController.ensureNotNullSeed();
return walletController.getCurrentWallet().getWalletAddress();
}
@ -343,7 +343,7 @@ public class PirateChain extends Bitcoiny {
walletController.initWithEntropy58(pirateChainSendRequest.entropy58);
walletController.ensureInitialized();
walletController.ensureSynchronized();
walletController.ensureNotDisposable();
walletController.ensureNotNullSeed();
// Unlock wallet
walletController.getCurrentWallet().unlock();
@ -390,7 +390,7 @@ public class PirateChain extends Bitcoiny {
walletController.initWithEntropy58(entropy58);
walletController.ensureInitialized();
walletController.ensureSynchronized();
walletController.ensureNotDisposable();
walletController.ensureNotNullSeed();
// Unlock wallet
walletController.getCurrentWallet().unlock();
@ -434,9 +434,9 @@ public class PirateChain extends Bitcoiny {
public String redeemP2sh(String p2shAddress, String receivingAddress, long amount, String redeemScript58,
String fundingTxid58, String secret58, String privateKey58) throws ForeignBlockchainException {
PirateWallet wallet = PirateChainWalletController.getInstance().switchToDisposableWallet();
PirateWallet wallet = PirateChainWalletController.getInstance().switchToNullWallet();
if (wallet == null) {
throw new ForeignBlockchainException("Unable to initialize disposable Pirate Chain wallet");
throw new ForeignBlockchainException("Unable to initialize null seed Pirate Chain wallet");
}
// Build spend
@ -483,9 +483,9 @@ public class PirateChain extends Bitcoiny {
public String refundP2sh(String p2shAddress, String receivingAddress, long amount, String redeemScript58,
String fundingTxid58, int lockTime, String privateKey58) throws ForeignBlockchainException {
PirateWallet wallet = PirateChainWalletController.getInstance().switchToDisposableWallet();
PirateWallet wallet = PirateChainWalletController.getInstance().switchToNullWallet();
if (wallet == null) {
throw new ForeignBlockchainException("Unable to initialize disposable Pirate Chain wallet");
throw new ForeignBlockchainException("Unable to initialize null seed Pirate Chain wallet");
}
// Build spend

View File

@ -31,7 +31,7 @@ public class PirateWallet {
protected static final Logger LOGGER = LogManager.getLogger(PirateWallet.class);
private byte[] entropyBytes;
private final boolean isDisposable;
private final boolean isNullSeedWallet;
private String seedPhrase;
private boolean ready = false;
@ -44,9 +44,9 @@ public class PirateWallet {
private final static String SAPLING_OUTPUT_RESOURCE = "piratechain/saplingoutput_base64";
private final static String SAPLING_SPEND_RESOURCE = "piratechain/saplingspend_base64";
public PirateWallet(byte[] entropyBytes, boolean isDisposable) throws IOException {
public PirateWallet(byte[] entropyBytes, boolean isNullSeedWallet) throws IOException {
this.entropyBytes = entropyBytes;
this.isDisposable = isDisposable;
this.isNullSeedWallet = isNullSeedWallet;
final URL paramsUrl = Resources.getResource(COIN_PARAMS_RESOURCE);
this.params = Resources.toString(paramsUrl, StandardCharsets.UTF_8);
@ -65,12 +65,12 @@ public class PirateWallet {
LiteWalletJni.initlogging();
if (this.entropyBytes == null) {
if (this.isDisposable) {
// Generate disposable wallet
if (this.isNullSeedWallet) {
// Use null seed
this.entropyBytes = new byte[32];
}
else {
// Need entropy bytes for a non disposable wallet
// Need entropy bytes for a non-null seed wallet
return false;
}
}
@ -91,9 +91,9 @@ public class PirateWallet {
// Wallet doesn't exist, so create a new one
int birthday = DEFAULT_BIRTHDAY;
if (this.isDisposable) {
if (this.isNullSeedWallet) {
try {
// Attempt to set birthday to the current block for disposable wallets
// Attempt to set birthday to the current block for null wallets
birthday = PirateChain.getInstance().blockchainProvider.getCurrentHeight();
}
catch (ForeignBlockchainException e) {
@ -197,8 +197,8 @@ public class PirateWallet {
LOGGER.info("Error: can't save wallet, because no wallet it initialized");
return false;
}
if (this.isDisposable) {
LOGGER.info("Error: can't save disposable wallet");
if (this.isNullSeedWallet) {
LOGGER.info("Error: can't save null wallet");
return false;
}
@ -229,8 +229,8 @@ public class PirateWallet {
}
public String load() throws IOException {
if (this.isDisposable) {
// Can't load disposable wallets
if (this.isNullSeedWallet) {
// Can't load null seed wallets
return null;
}
Path walletPath = this.getCurrentWalletPath();
@ -321,8 +321,8 @@ public class PirateWallet {
return null;
}
public boolean isDisposable() {
return this.isDisposable;
public boolean hasNullSeed() {
return this.isNullSeedWallet;
}
public Boolean isEncrypted() {