Skip to content

Commit 53260b8

Browse files
committed
main.patch:todo output valid json
1 parent 20de459 commit 53260b8

1 file changed

Lines changed: 36 additions & 0 deletions

File tree

main.patch

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
diff --git a/main.cpp b/main.cpp
2+
index 32dfc67..e94fa9c 100644
3+
--- a/main.cpp
4+
+++ b/main.cpp
5+
@@ -23,7 +23,17 @@ static bool run(std::string&& line, int64_t count) {
6+
} else if ((ret = miniscript::FromString(Expand(line), COMPILER_CTX))) {
7+
auto ms = ret->ToString(COMPILER_CTX);
8+
assert(ms);
9+
- printf("%7li scriptlen=%i maxops=%i type=%s safe=%s nonmal=%s dissat=%s input=%s output=%s timelock_mix=%s miniscript=%s\n", (long)count, (int)ret->ScriptSize(), (int)ret->GetOps(), ret->GetType() << "B"_mst ? "B" : ret->GetType() << "V"_mst ? "V" : ret->GetType() << "W"_mst ? "W" : ret->GetType() << "K"_mst ? "K" : "(invalid)", ret->GetType() << "s"_mst ? "yes" : "no", ret->GetType() << "m"_mst ? "yes" : "no", ret->GetType() << "f"_mst ? "no" : ret->GetType() << "e"_mst ? "unique" : ret->GetType() << "d"_mst ? "yes" : "unknown", ret->GetType() << "z"_mst ? "0" : ret->GetType() << "o"_mst ? (ret->GetType() << "n"_mst ? "1n" : "1") : ret->GetType() << "n"_mst ? "n" : "-", ret->GetType() << "u"_mst ? "1" : "nonzero", ret->GetType() << "k"_mst ? "no": "yes", Abbreviate(*ms).c_str());
10+
+ printf("%7li scriptlen=%i maxops=%i type=%s safe=%s nonmal=%s dissat=%s input=%s output=%s timelock_mix=%s\n miniscript=%s\n",
11+
+ (long)count,
12+
+ (int)ret->ScriptSize(),
13+
+ (int)ret->GetOps(),
14+
+ ret->GetType() << "B"_mst ? "B" : ret->GetType() << "V"_mst ? "V" : ret->GetType() << "W"_mst ? "W" : ret->GetType() << "K"_mst ? "K" : "(invalid)",
15+
+ ret->GetType() << "s"_mst ? "yes" : "no",
16+
+ ret->GetType() << "m"_mst ? "yes" : "no",
17+
+ ret->GetType() << "f"_mst ? "no" : ret->GetType() << "e"_mst ? "unique" : ret->GetType() << "d"_mst ? "yes" : "unknown",
18+
+ ret->GetType() << "z"_mst ? "0" : ret->GetType() << "o"_mst ? (ret->GetType() << "n"_mst ? "1n" : "1") : ret->GetType() << "n"_mst ? "n" : "-",
19+
+ ret->GetType() << "u"_mst ? "1" : "nonzero", ret->GetType() << "k"_mst ? "no": "yes",
20+
+ Abbreviate(*ms).c_str());
21+
} else {
22+
printf("Failed to parse as policy or miniscript '%s'\n", line.c_str());
23+
}
24+
@@ -33,8 +43,10 @@ static bool run(std::string&& line, int64_t count) {
25+
int main(void) {
26+
int64_t count = 0;
27+
do {
28+
+ // printf("start:test\n");
29+
std::string line;
30+
std::getline(std::cin, line);
31+
- if (!run(std::move(line), count++)) break;
32+
- } while(true);
33+
+ // printf("loop:test\n");
34+
+ if (!run(std::move(line), count++)) { /* printf("end:test\n");*/ break; }
35+
+ } while(true);
36+
}

0 commit comments

Comments
 (0)