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 notifyOnPreRelease;
private MoneroNodeSettings moneroNodeSettings;
private MoneroNodeSettings moneroNodeSettings = new MoneroNodeSettings();
///////////////////////////////////////////////////////////////////////////////////////////
// Constructor

View File

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