|
19 | 19 | #include <string.h> |
20 | 20 | #include <unistd.h> |
21 | 21 |
|
| 22 | +static bool simpleout = false; |
| 23 | + |
22 | 24 | /* Tal wrappers for opt. */ |
23 | 25 | static void *opt_allocfn(size_t size) |
24 | 26 | { |
@@ -99,6 +101,8 @@ int main(int argc, char **argv) |
99 | 101 | "Show this message"); |
100 | 102 | opt_register_noarg("--first-node", opt_set_bool, &first, |
101 | 103 | "Don't try to tweak key to unwrap onion"); |
| 104 | + opt_register_noarg("--simple-output", opt_set_bool, &simpleout, |
| 105 | + "Output values without prefixes, one per line"); |
102 | 106 | opt_register_version(); |
103 | 107 |
|
104 | 108 | opt_parse(&argc, argv, opt_log_stderr_exit); |
@@ -158,8 +162,12 @@ int main(int argc, char **argv) |
158 | 162 | } |
159 | 163 |
|
160 | 164 | /* Print initial blinding factor */ |
161 | | - printf("Blinding: %s\n", |
162 | | - type_to_string(tmpctx, struct pubkey, &pk_e[0])); |
| 165 | + if (simpleout) |
| 166 | + printf("%s\n", |
| 167 | + type_to_string(tmpctx, struct pubkey, &pk_e[0])); |
| 168 | + else |
| 169 | + printf("Blinding: %s\n", |
| 170 | + type_to_string(tmpctx, struct pubkey, &pk_e[0])); |
163 | 171 |
|
164 | 172 | for (size_t i = 0; i < num - 1; i++) { |
165 | 173 | u8 *p; |
@@ -192,16 +200,28 @@ int main(int argc, char **argv) |
192 | 200 | towire_onionmsg_payload(&p, outer); |
193 | 201 | ret = bigsize_put(buf, tal_bytelen(p)); |
194 | 202 |
|
195 | | - /* devtools/onion wants length explicitly prepended */ |
196 | | - printf("%s/%.*s%s ", |
197 | | - type_to_string(tmpctx, struct pubkey, &b[i]), |
198 | | - ret * 2, |
199 | | - tal_hexstr(tmpctx, buf, ret), |
200 | | - tal_hex(tmpctx, p)); |
| 203 | + if (simpleout) { |
| 204 | + printf("%s\n%s\n", |
| 205 | + type_to_string(tmpctx, struct pubkey, |
| 206 | + &b[i]), |
| 207 | + tal_hex(tmpctx, outer->enctlv->enctlv)); |
| 208 | + } else { |
| 209 | + /* devtools/onion wants length explicitly prepended */ |
| 210 | + printf("%s/%.*s%s ", |
| 211 | + type_to_string(tmpctx, struct pubkey, |
| 212 | + &b[i]), |
| 213 | + ret * 2, |
| 214 | + tal_hexstr(tmpctx, buf, ret), |
| 215 | + tal_hex(tmpctx, p)); |
| 216 | + } |
201 | 217 | } |
202 | 218 | /* No payload for last node */ |
203 | | - printf("%s/00\n", |
204 | | - type_to_string(tmpctx, struct pubkey, &b[num-1])); |
| 219 | + if (simpleout) |
| 220 | + printf("%s\n", |
| 221 | + type_to_string(tmpctx, struct pubkey, &b[num-1])); |
| 222 | + else |
| 223 | + printf("%s/00\n", |
| 224 | + type_to_string(tmpctx, struct pubkey, &b[num-1])); |
205 | 225 | } else if (streq(argv[1], "unwrap")) { |
206 | 226 | struct privkey privkey; |
207 | 227 | struct pubkey blinding; |
|
0 commit comments