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

Function main

common/test/run-psbt_diff.c:154–245  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

152}
153
154int main(int argc, const char *argv[])
155{
156 common_setup(argv[0]);
157
158 struct wally_psbt *start, *end;
159 u32 flags = 0;
160
161 chainparams = chainparams_for_network("bitcoin");
162
163 /* Create two psbts! */
164 end = create_psbt(tmpctx, 1, 1, 0);
165 tal_wally_start();
166 if (wally_psbt_clone_alloc(end, flags, &start) != WALLY_OK)
167 abort();
168 tal_wally_end_onto(tmpctx, start, struct wally_psbt);
169 diff_count(start, end, 0, 0);
170 diff_count(end, start, 0, 0);
171
172 /* New input/output added */
173 add_in_out_with_serial(end, 10, 1);
174 diff_count(start, end, 1, 0);
175 diff_count(end, start, 0, 1);
176
177 /* Add another one, before previous */
178 tal_wally_start();
179 if (wally_psbt_clone_alloc(end, flags, &start) != WALLY_OK)
180 abort();
181 tal_wally_end_onto(tmpctx, start, struct wally_psbt);
182 add_in_out_with_serial(end, 5, 2);
183 diff_count(start, end, 1, 0);
184 diff_count(end, start, 0, 1);
185
186 /* Add another, at end */
187 tal_wally_start();
188 if (wally_psbt_clone_alloc(end, flags, &start) != WALLY_OK)
189 abort();
190 tal_wally_end_onto(tmpctx, start, struct wally_psbt);
191 add_in_out_with_serial(end, 15, 3);
192 diff_count(start, end, 1, 0);
193 diff_count(end, start, 0, 1);
194
195 /* Add another, in middle */
196 tal_wally_start();
197 if (wally_psbt_clone_alloc(end, flags, &start) != WALLY_OK)
198 abort();
199 tal_wally_end_onto(tmpctx, start, struct wally_psbt);
200 add_in_out_with_serial(end, 11, 4);
201 diff_count(start, end, 1, 0);
202 diff_count(end, start, 0, 1);
203
204 /* Change existing input/output info
205 * (we accomplish this by removing and then
206 * readding an input/output with the same serial_id
207 * but different value) */
208 tal_wally_start();
209 if (wally_psbt_clone_alloc(end, flags, &start) != WALLY_OK)
210 abort();
211 tal_wally_end_onto(tmpctx, start, struct wally_psbt);

Callers

nothing calls this directly

Calls 15

common_setupFunction · 0.85
chainparams_for_networkFunction · 0.85
create_psbtFunction · 0.85
tal_wally_startFunction · 0.85
abortFunction · 0.85
diff_countFunction · 0.85
add_in_out_with_serialFunction · 0.85
psbt_rm_outputFunction · 0.85
psbt_rm_inputFunction · 0.85
psbt_make_keyFunction · 0.85
psbt_input_set_unknownFunction · 0.85
tal_bytelenFunction · 0.85

Tested by

no test coverage detected