fix npe on first start with offline --xmrNode

This commit is contained in:
woodser 2023-11-12 18:13:30 -05:00
parent 606b2cef23
commit fd0bf23867
2 changed files with 14 additions and 6 deletions

View file

@ -131,7 +131,7 @@ public final class PreferencesPayload implements PersistableEnvelope {
private boolean denyApiTaker; private boolean denyApiTaker;
private boolean notifyOnPreRelease; private boolean notifyOnPreRelease;
private MoneroNodeSettings moneroNodeSettings; private MoneroNodeSettings moneroNodeSettings = new MoneroNodeSettings();
/////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////
// Constructor // Constructor

View file

@ -20,18 +20,25 @@ import haveno.common.proto.persistable.PersistableEnvelope;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.Data; import lombok.Data;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import java.util.List; import java.util.List;
import java.util.Optional;
import javax.annotation.Nullable;
@Slf4j @Slf4j
@Data @Data
@AllArgsConstructor @AllArgsConstructor
public class MoneroNodeSettings implements PersistableEnvelope { public class MoneroNodeSettings implements PersistableEnvelope {
@Nullable
String blockchainPath; String blockchainPath;
@Nullable
String bootstrapUrl; String bootstrapUrl;
@Nullable
List<String> startupFlags; List<String> startupFlags;
public MoneroNodeSettings() {
}
public static MoneroNodeSettings fromProto(protobuf.MoneroNodeSettings proto) { public static MoneroNodeSettings fromProto(protobuf.MoneroNodeSettings proto) {
return new MoneroNodeSettings( return new MoneroNodeSettings(
proto.getBlockchainPath(), proto.getBlockchainPath(),
@ -41,9 +48,10 @@ public class MoneroNodeSettings implements PersistableEnvelope {
@Override @Override
public protobuf.MoneroNodeSettings toProtoMessage() { public protobuf.MoneroNodeSettings toProtoMessage() {
return protobuf.MoneroNodeSettings.newBuilder() protobuf.MoneroNodeSettings.Builder builder = protobuf.MoneroNodeSettings.newBuilder();
.setBlockchainPath(blockchainPath) Optional.ofNullable(blockchainPath).ifPresent(e -> builder.setBlockchainPath(blockchainPath));
.setBootstrapUrl(bootstrapUrl) Optional.ofNullable(bootstrapUrl).ifPresent(e -> builder.setBlockchainPath(bootstrapUrl));
.addAllStartupFlags(startupFlags).build(); Optional.ofNullable(startupFlags).ifPresent(e -> builder.addAllStartupFlags(startupFlags));
return builder.build();
} }
} }