diff --git a/src/main/java/org/qortal/controller/PirateChainWalletController.java b/src/main/java/org/qortal/controller/PirateChainWalletController.java index d12660e6..46b209ae 100644 --- a/src/main/java/org/qortal/controller/PirateChainWalletController.java +++ b/src/main/java/org/qortal/controller/PirateChainWalletController.java @@ -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"); } } diff --git a/src/main/java/org/qortal/crosschain/PirateChain.java b/src/main/java/org/qortal/crosschain/PirateChain.java index 44029e21..32c50cda 100644 --- a/src/main/java/org/qortal/crosschain/PirateChain.java +++ b/src/main/java/org/qortal/crosschain/PirateChain.java @@ -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 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 diff --git a/src/main/java/org/qortal/crosschain/PirateWallet.java b/src/main/java/org/qortal/crosschain/PirateWallet.java index 89014338..985f2f64 100644 --- a/src/main/java/org/qortal/crosschain/PirateWallet.java +++ b/src/main/java/org/qortal/crosschain/PirateWallet.java @@ -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() {