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

Function main

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

Source from the content-addressed store, hash-verified

136}
137
138int main(int argc, const char *argv[])
139{
140 common_setup(argv[0]);
141
142 struct wally_psbt *start, *end;
143 u32 flags = 0;
144
145 chainparams = chainparams_for_network("bitcoin");
146
147 /* Create two psbts! */
148 end = create_psbt(tmpctx, 1, 1, 0);
149 tal_wally_start();
150 if (wally_psbt_clone_alloc(end, flags, &start) != WALLY_OK)
151 abort();
152 tal_wally_end(tmpctx);
153 diff_count(start, end, 0, 0);
154 diff_count(end, start, 0, 0);
155
156 /* New input/output added */
157 add_in_out_with_serial(end, 10, 1);
158 diff_count(start, end, 1, 0);
159 diff_count(end, start, 0, 1);
160
161 /* Add another one, before previous */
162 tal_wally_start();
163 if (wally_psbt_clone_alloc(end, flags, &start) != WALLY_OK)
164 abort();
165 tal_wally_end(tmpctx);
166 add_in_out_with_serial(end, 5, 2);
167 diff_count(start, end, 1, 0);
168 diff_count(end, start, 0, 1);
169
170 /* Add another, at end */
171 tal_wally_start();
172 if (wally_psbt_clone_alloc(end, flags, &start) != WALLY_OK)
173 abort();
174 tal_wally_end(tmpctx);
175 add_in_out_with_serial(end, 15, 3);
176 diff_count(start, end, 1, 0);
177 diff_count(end, start, 0, 1);
178
179 /* Add another, in middle */
180 tal_wally_start();
181 if (wally_psbt_clone_alloc(end, flags, &start) != WALLY_OK)
182 abort();
183 tal_wally_end(tmpctx);
184 add_in_out_with_serial(end, 11, 4);
185 diff_count(start, end, 1, 0);
186 diff_count(end, start, 0, 1);
187
188 /* Change existing input/output info
189 * (we accomplish this by removing and then
190 * readding an input/output with the same serial_id
191 * but different value) */
192 tal_wally_start();
193 if (wally_psbt_clone_alloc(end, flags, &start) != WALLY_OK)
194 abort();
195 tal_wally_end(tmpctx);

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
tal_wally_endFunction · 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

Tested by

no test coverage detected