mirror of
https://github.com/sparrowwallet/sparrow.git
synced 2026-08-10 08:37:05 +00:00
add tests for descriptor import and export, and handle multiline descriptor
This commit is contained in:
@@ -114,26 +114,14 @@ public class Descriptor implements WalletImport, WalletExport {
|
||||
|
||||
private static List<String> getParagraphs(InputStream inputStream) {
|
||||
List<String> paragraphs = new ArrayList<>();
|
||||
StringBuilder paragraph = new StringBuilder();
|
||||
|
||||
BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream, StandardCharsets.UTF_8));
|
||||
for(String line : reader.lines().map(String::trim).toArray(String[]::new)) {
|
||||
if(line.isEmpty()) {
|
||||
if(!paragraph.isEmpty()) {
|
||||
paragraphs.add(paragraph.toString());
|
||||
paragraph.setLength(0);
|
||||
}
|
||||
} else if(line.startsWith("#")) {
|
||||
continue;
|
||||
} else {
|
||||
paragraph.append(line.replaceFirst("^.+:", "").trim());
|
||||
if(!line.isEmpty() && !line.startsWith("#")) {
|
||||
paragraphs.add(line.replaceFirst("^.+:", "").trim());
|
||||
}
|
||||
}
|
||||
|
||||
if(!paragraph.isEmpty()) {
|
||||
paragraphs.add(paragraph.toString());
|
||||
}
|
||||
|
||||
return paragraphs;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user