MCPcopy Create free account
hub / github.com/ElementsProject/lightning / main

Function main

common/test/run-bolt11.c:135–711  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

133}
134
135int main(int argc, char *argv[])
136{
137 struct bolt11 *b11;
138 struct node_id node;
139 struct amount_msat msatoshi;
140 const char *badstr;
141 struct bolt11_field *extra;
142 char *fail;
143 struct feature_set *fset;
144
145 common_setup(argv[0]);
146
147 /* BOLT #11:
148 *
149 * # Examples
150 *
151 * NB: all the following examples are signed with `priv_key`=`e126f68f7eafcc8b74f54d269fe206be715000f94dac067d1c04a8ca3b2db734`.
152 */
153 if (!hex_decode("e126f68f7eafcc8b74f54d269fe206be715000f94dac067d1c04a8ca3b2db734",
154 strlen("e126f68f7eafcc8b74f54d269fe206be715000f94dac067d1c04a8ca3b2db734"),
155 &privkey, sizeof(privkey)))
156 abort();
157
158 /* BOLT #11:
159 *
160 * > ### Please make a donation of any amount using payment_hash 0001020304050607080900010203040506070809000102030405060708090102 to me @03e7156ae33b0a208d0744199163177e909e80176e55d97a2f221ede0f934dd9ad
161 * > lnbc1pvjluezsp5zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zygspp5qqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqypqdpl2pkx2ctnv5sxxmmwwd5kgetjypeh2ursdae8g6twvus8g6rfwvs8qun0dfjkxaq9qrsgq357wnc5r2ueh7ck6q93dj32dlqnls087fxdwk8qakdyafkq3yap9us6v52vjjsrvywa6rt52cm9r9zqt8r2t7mlcwspyetp5h2tztugp9lfyql
162 */
163 if (!node_id_from_hexstr("03e7156ae33b0a208d0744199163177e909e80176e55d97a2f221ede0f934dd9ad", strlen("03e7156ae33b0a208d0744199163177e909e80176e55d97a2f221ede0f934dd9ad"), &node))
164 abort();
165
166 /* BOLT #11:
167 *
168 * Breakdown:
169 *
170 * * `lnbc`: prefix, Lightning on Bitcoin mainnet
171 * * `1`: Bech32 separator
172 * * `pvjluez`: timestamp (1496314658)
173 * * `s`: payment secret
174 * * `p5`: `data_length` (`p` = 1, `5` = 20; 1 * 32 + 20 == 52)
175 * * `zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zygs`: payment secret 1111111111111111111111111111111111111111111111111111111111111111
176 * * `p`: payment hash
177 * * `p5`: `data_length` (`p` = 1, `5` = 20; 1 * 32 + 20 == 52)
178 * * `qqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqypq`: payment hash 0001020304050607080900010203040506070809000102030405060708090102
179 * * `d`: short description
180 * * `pl`: `data_length` (`p` = 1, `l` = 31; 1 * 32 + 31 == 63)
181 * * `2pkx2ctnv5sxxmmwwd5kgetjypeh2ursdae8g6twvus8g6rfwvs8qun0dfjkxaq`: 'Please consider supporting this project'
182 * * `9`: features
183 * * `qr`: `data_length` (`q` = 0, `r` = 3; 0 * 32 + 3 == 3)
184 * * `sgq`: b100000100000000
185 * * `357wnc5r2ueh7ck6q93dj32dlqnls087fxdwk8qakdyafkq3yap9us6v52vjjsrvywa6rt52cm9r9zqt8r2t7mlcwspyetp5h2tztugp`: signature
186 */
187 b11 = new_bolt11(tmpctx, NULL);
188 b11->chain = chainparams_for_network("bitcoin");
189 b11->timestamp = 1496314658;
190 if (!hex_decode("0001020304050607080900010203040506070809000102030405060708090102",
191 strlen("0001020304050607080900010203040506070809000102030405060708090102"),
192 &b11->payment_hash, sizeof(b11->payment_hash)))

Callers

nothing calls this directly

Calls 14

common_setupFunction · 0.85
hex_decodeFunction · 0.85
abortFunction · 0.85
chainparams_for_networkFunction · 0.85
set_feature_bitFunction · 0.85
test_b11Function · 0.85
list_head_initFunction · 0.85
clear_feature_bitFunction · 0.85
tal_hexdataFunction · 0.85
common_shutdownFunction · 0.85
node_id_from_hexstrFunction · 0.70

Tested by

no test coverage detected