Skip to content

Commit

Permalink
fix: prevent NPE in CoinJoinExtension.addUnusedKey
Browse files Browse the repository at this point in the history
  • Loading branch information
HashEngineering committed Nov 21, 2023
1 parent 81d987c commit 90193fa
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions core/src/main/java/org/bitcoinj/wallet/CoinJoinExtension.java
Original file line number Diff line number Diff line change
Expand Up @@ -337,9 +337,13 @@ public void addUnusedKey(KeyId keyId) {
unusedKeysLock.lock();
try {
DeterministicKey key = (DeterministicKey) findKeyFromPubKey(keyId.getBytes());
unusedKeys.put(KeyId.fromBytes(key.getPubKeyHash()), key);
keyUsage.put(key, false);
log.info("adding unused key: {} / {}", HEX.encode(key.getPubKeyHash()), key.getPath());
if (key != null) {
unusedKeys.put(KeyId.fromBytes(key.getPubKeyHash()), key);
keyUsage.put(key, false);
log.info("adding unused key: {} / {}", HEX.encode(key.getPubKeyHash()), key.getPath());
} else {
log.warn("cannot find {}", keyId);
}
} finally {
unusedKeysLock.unlock();
}
Expand Down

0 comments on commit 90193fa

Please sign in to comment.