forked from Qortal/qortal
"Disposable" wallets renamed to "null seed" wallets, as this is a better description of what they are.
This commit is contained in:
parent
9a4ce57001
commit
f14b494bfc
@ -106,8 +106,8 @@ public class PirateChainWalletController extends Thread {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
this.currentWallet = new PirateWallet(entropyBytes, false);
|
this.currentWallet = new PirateWallet(entropyBytes, false);
|
||||||
if (!this.currentWallet.isReady() || this.currentWallet.isDisposable()) {
|
if (!this.currentWallet.isReady() || this.currentWallet.hasNullSeed()) {
|
||||||
// Don't persist wallets that aren't ready or are disposable
|
// Don't persist wallets that aren't ready or are null seed
|
||||||
this.currentWallet = null;
|
this.currentWallet = null;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
@ -118,7 +118,7 @@ public class PirateChainWalletController extends Thread {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public PirateWallet switchToDisposableWallet() {
|
public PirateWallet switchToNullWallet() {
|
||||||
try {
|
try {
|
||||||
this.currentWallet = null;
|
this.currentWallet = null;
|
||||||
return new PirateWallet(null, true);
|
return new PirateWallet(null, true);
|
||||||
@ -160,9 +160,9 @@ public class PirateChainWalletController extends Thread {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ensureNotDisposable() throws ForeignBlockchainException {
|
public void ensureNotNullSeed() throws ForeignBlockchainException {
|
||||||
// Safety check to make sure funds aren't sent to a disposable wallet
|
// Safety check to make sure funds aren't sent to a null seed wallet
|
||||||
if (this.currentWallet == null || this.currentWallet.isDisposable()) {
|
if (this.currentWallet == null || this.currentWallet.hasNullSeed()) {
|
||||||
throw new ForeignBlockchainException("Invalid wallet");
|
throw new ForeignBlockchainException("Invalid wallet");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -263,7 +263,7 @@ public class PirateChain extends Bitcoiny {
|
|||||||
walletController.initWithEntropy58(entropy58);
|
walletController.initWithEntropy58(entropy58);
|
||||||
walletController.ensureInitialized();
|
walletController.ensureInitialized();
|
||||||
walletController.ensureSynchronized();
|
walletController.ensureSynchronized();
|
||||||
walletController.ensureNotDisposable();
|
walletController.ensureNotNullSeed();
|
||||||
|
|
||||||
// Get balance
|
// Get balance
|
||||||
String response = LiteWalletJni.execute("balance", "");
|
String response = LiteWalletJni.execute("balance", "");
|
||||||
@ -282,7 +282,7 @@ public class PirateChain extends Bitcoiny {
|
|||||||
walletController.initWithEntropy58(entropy58);
|
walletController.initWithEntropy58(entropy58);
|
||||||
walletController.ensureInitialized();
|
walletController.ensureInitialized();
|
||||||
walletController.ensureSynchronized();
|
walletController.ensureSynchronized();
|
||||||
walletController.ensureNotDisposable();
|
walletController.ensureNotNullSeed();
|
||||||
|
|
||||||
List<SimpleTransaction> transactions = new ArrayList<>();
|
List<SimpleTransaction> transactions = new ArrayList<>();
|
||||||
|
|
||||||
@ -332,7 +332,7 @@ public class PirateChain extends Bitcoiny {
|
|||||||
PirateChainWalletController walletController = PirateChainWalletController.getInstance();
|
PirateChainWalletController walletController = PirateChainWalletController.getInstance();
|
||||||
walletController.initWithEntropy58(entropy58);
|
walletController.initWithEntropy58(entropy58);
|
||||||
walletController.ensureInitialized();
|
walletController.ensureInitialized();
|
||||||
walletController.ensureNotDisposable();
|
walletController.ensureNotNullSeed();
|
||||||
|
|
||||||
return walletController.getCurrentWallet().getWalletAddress();
|
return walletController.getCurrentWallet().getWalletAddress();
|
||||||
}
|
}
|
||||||
@ -343,7 +343,7 @@ public class PirateChain extends Bitcoiny {
|
|||||||
walletController.initWithEntropy58(pirateChainSendRequest.entropy58);
|
walletController.initWithEntropy58(pirateChainSendRequest.entropy58);
|
||||||
walletController.ensureInitialized();
|
walletController.ensureInitialized();
|
||||||
walletController.ensureSynchronized();
|
walletController.ensureSynchronized();
|
||||||
walletController.ensureNotDisposable();
|
walletController.ensureNotNullSeed();
|
||||||
|
|
||||||
// Unlock wallet
|
// Unlock wallet
|
||||||
walletController.getCurrentWallet().unlock();
|
walletController.getCurrentWallet().unlock();
|
||||||
@ -390,7 +390,7 @@ public class PirateChain extends Bitcoiny {
|
|||||||
walletController.initWithEntropy58(entropy58);
|
walletController.initWithEntropy58(entropy58);
|
||||||
walletController.ensureInitialized();
|
walletController.ensureInitialized();
|
||||||
walletController.ensureSynchronized();
|
walletController.ensureSynchronized();
|
||||||
walletController.ensureNotDisposable();
|
walletController.ensureNotNullSeed();
|
||||||
|
|
||||||
// Unlock wallet
|
// Unlock wallet
|
||||||
walletController.getCurrentWallet().unlock();
|
walletController.getCurrentWallet().unlock();
|
||||||
@ -434,9 +434,9 @@ public class PirateChain extends Bitcoiny {
|
|||||||
public String redeemP2sh(String p2shAddress, String receivingAddress, long amount, String redeemScript58,
|
public String redeemP2sh(String p2shAddress, String receivingAddress, long amount, String redeemScript58,
|
||||||
String fundingTxid58, String secret58, String privateKey58) throws ForeignBlockchainException {
|
String fundingTxid58, String secret58, String privateKey58) throws ForeignBlockchainException {
|
||||||
|
|
||||||
PirateWallet wallet = PirateChainWalletController.getInstance().switchToDisposableWallet();
|
PirateWallet wallet = PirateChainWalletController.getInstance().switchToNullWallet();
|
||||||
if (wallet == null) {
|
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
|
// Build spend
|
||||||
@ -483,9 +483,9 @@ public class PirateChain extends Bitcoiny {
|
|||||||
public String refundP2sh(String p2shAddress, String receivingAddress, long amount, String redeemScript58,
|
public String refundP2sh(String p2shAddress, String receivingAddress, long amount, String redeemScript58,
|
||||||
String fundingTxid58, int lockTime, String privateKey58) throws ForeignBlockchainException {
|
String fundingTxid58, int lockTime, String privateKey58) throws ForeignBlockchainException {
|
||||||
|
|
||||||
PirateWallet wallet = PirateChainWalletController.getInstance().switchToDisposableWallet();
|
PirateWallet wallet = PirateChainWalletController.getInstance().switchToNullWallet();
|
||||||
if (wallet == null) {
|
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
|
// Build spend
|
||||||
|
@ -31,7 +31,7 @@ public class PirateWallet {
|
|||||||
protected static final Logger LOGGER = LogManager.getLogger(PirateWallet.class);
|
protected static final Logger LOGGER = LogManager.getLogger(PirateWallet.class);
|
||||||
|
|
||||||
private byte[] entropyBytes;
|
private byte[] entropyBytes;
|
||||||
private final boolean isDisposable;
|
private final boolean isNullSeedWallet;
|
||||||
private String seedPhrase;
|
private String seedPhrase;
|
||||||
private boolean ready = false;
|
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_OUTPUT_RESOURCE = "piratechain/saplingoutput_base64";
|
||||||
private final static String SAPLING_SPEND_RESOURCE = "piratechain/saplingspend_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.entropyBytes = entropyBytes;
|
||||||
this.isDisposable = isDisposable;
|
this.isNullSeedWallet = isNullSeedWallet;
|
||||||
|
|
||||||
final URL paramsUrl = Resources.getResource(COIN_PARAMS_RESOURCE);
|
final URL paramsUrl = Resources.getResource(COIN_PARAMS_RESOURCE);
|
||||||
this.params = Resources.toString(paramsUrl, StandardCharsets.UTF_8);
|
this.params = Resources.toString(paramsUrl, StandardCharsets.UTF_8);
|
||||||
@ -65,12 +65,12 @@ public class PirateWallet {
|
|||||||
LiteWalletJni.initlogging();
|
LiteWalletJni.initlogging();
|
||||||
|
|
||||||
if (this.entropyBytes == null) {
|
if (this.entropyBytes == null) {
|
||||||
if (this.isDisposable) {
|
if (this.isNullSeedWallet) {
|
||||||
// Generate disposable wallet
|
// Use null seed
|
||||||
this.entropyBytes = new byte[32];
|
this.entropyBytes = new byte[32];
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// Need entropy bytes for a non disposable wallet
|
// Need entropy bytes for a non-null seed wallet
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -91,9 +91,9 @@ public class PirateWallet {
|
|||||||
// Wallet doesn't exist, so create a new one
|
// Wallet doesn't exist, so create a new one
|
||||||
|
|
||||||
int birthday = DEFAULT_BIRTHDAY;
|
int birthday = DEFAULT_BIRTHDAY;
|
||||||
if (this.isDisposable) {
|
if (this.isNullSeedWallet) {
|
||||||
try {
|
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();
|
birthday = PirateChain.getInstance().blockchainProvider.getCurrentHeight();
|
||||||
}
|
}
|
||||||
catch (ForeignBlockchainException e) {
|
catch (ForeignBlockchainException e) {
|
||||||
@ -197,8 +197,8 @@ public class PirateWallet {
|
|||||||
LOGGER.info("Error: can't save wallet, because no wallet it initialized");
|
LOGGER.info("Error: can't save wallet, because no wallet it initialized");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (this.isDisposable) {
|
if (this.isNullSeedWallet) {
|
||||||
LOGGER.info("Error: can't save disposable wallet");
|
LOGGER.info("Error: can't save null wallet");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -229,8 +229,8 @@ public class PirateWallet {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public String load() throws IOException {
|
public String load() throws IOException {
|
||||||
if (this.isDisposable) {
|
if (this.isNullSeedWallet) {
|
||||||
// Can't load disposable wallets
|
// Can't load null seed wallets
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
Path walletPath = this.getCurrentWalletPath();
|
Path walletPath = this.getCurrentWalletPath();
|
||||||
@ -321,8 +321,8 @@ public class PirateWallet {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isDisposable() {
|
public boolean hasNullSeed() {
|
||||||
return this.isDisposable;
|
return this.isNullSeedWallet;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Boolean isEncrypted() {
|
public Boolean isEncrypted() {
|
||||||
|
Loading…
Reference in New Issue
Block a user