From d6d2641cad77595fd4a7cbd97eb87b517322e766 Mon Sep 17 00:00:00 2001 From: CalDescent Date: Sun, 31 Jul 2022 12:07:44 +0100 Subject: [PATCH] Added "bitcoinjLookaheadSize" setting (default 50). This replaces the WALLET_KEY_LOOKAHEAD_INCREMENT_BITCOINJ constant. --- src/main/java/org/qortal/crosschain/Bitcoiny.java | 7 +------ src/main/java/org/qortal/settings/Settings.java | 9 ++++++++- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/main/java/org/qortal/crosschain/Bitcoiny.java b/src/main/java/org/qortal/crosschain/Bitcoiny.java index 8bfa0646..6ab7143f 100644 --- a/src/main/java/org/qortal/crosschain/Bitcoiny.java +++ b/src/main/java/org/qortal/crosschain/Bitcoiny.java @@ -62,11 +62,6 @@ public abstract class Bitcoiny implements ForeignBlockchain { /** How many wallet keys to generate in each batch. */ private static final int WALLET_KEY_LOOKAHEAD_INCREMENT = 3; - /** How many wallet keys to generate when using bitcoinj as the data provider. - * We must use a higher value here since we are unable to request multiple batches of keys. - * Without this, the bitcoinj state can be missing transactions, causing errors such as "insufficient balance". */ - private static final int WALLET_KEY_LOOKAHEAD_INCREMENT_BITCOINJ = 50; - /** Byte offset into raw block headers to block timestamp. */ private static final int TIMESTAMP_OFFSET = 4 + 32 + 32; @@ -628,7 +623,7 @@ public abstract class Bitcoiny implements ForeignBlockchain { this.keyChain = this.wallet.getActiveKeyChain(); // Set up wallet's key chain - this.keyChain.setLookaheadSize(Bitcoiny.WALLET_KEY_LOOKAHEAD_INCREMENT_BITCOINJ); + this.keyChain.setLookaheadSize(Settings.getInstance().getBitcoinjLookaheadSize()); this.keyChain.maybeLookAhead(); } diff --git a/src/main/java/org/qortal/settings/Settings.java b/src/main/java/org/qortal/settings/Settings.java index 7851e374..92730b30 100644 --- a/src/main/java/org/qortal/settings/Settings.java +++ b/src/main/java/org/qortal/settings/Settings.java @@ -286,9 +286,12 @@ public class Settings { /* Foreign chains */ - /** Set the number of consecutive empty addresses required before treating a wallet's transaction set as complete */ + /** The number of consecutive empty addresses required before treating a wallet's transaction set as complete */ private int gapLimit = 24; + /** How many wallet keys to generate when using bitcoinj as the blockchain interface (e.g. when sending coins) */ + private int bitcoinjLookaheadSize = 50; + // Data storage (QDN) @@ -883,6 +886,10 @@ public class Settings { return this.gapLimit; } + public int getBitcoinjLookaheadSize() { + return bitcoinjLookaheadSize; + } + public boolean isQdnEnabled() { return this.qdnEnabled;