From 110da9691195f47b376872f95d81476e10b0e902 Mon Sep 17 00:00:00 2001 From: Sean Gilligan Date: Thu, 7 Sep 2023 08:41:37 -0700 Subject: [PATCH] Wallet: use `getAbsoluteFile()` when checking if parent directory exists This fixes a NPE when using wallet-tool to create a new wallet on a path without directory, e.g. `wallet-tool create --wallet=test.wallet`. --- core/src/main/java/org/bitcoinj/wallet/Wallet.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/src/main/java/org/bitcoinj/wallet/Wallet.java b/core/src/main/java/org/bitcoinj/wallet/Wallet.java index e4362be14..d95c92d5a 100644 --- a/core/src/main/java/org/bitcoinj/wallet/Wallet.java +++ b/core/src/main/java/org/bitcoinj/wallet/Wallet.java @@ -1700,11 +1700,11 @@ public class Wallet extends BaseTaggableObject * @throws IOException if an error occurs while saving */ public void saveToFile(File tempFile, File destFile) throws IOException { - File tempParentFile = tempFile.getParentFile(); + File tempParentFile = tempFile.getAbsoluteFile().getParentFile(); if (!tempParentFile.exists()) { throw new FileNotFoundException(tempParentFile.getPath() + " (wallet directory not found)"); } - File destParentFile = destFile.getParentFile(); + File destParentFile = destFile.getAbsoluteFile().getParentFile(); if (!destParentFile.exists()) { throw new FileNotFoundException(destParentFile.getPath() + " (wallet directory not found)"); }