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

Function psbt_equivalent

wallet/walletrpc.c:1154–1187  ·  view source on GitHub ↗

We consider two PSBTs *equivalent* if they have the same inputs and outputs */

Source from the content-addressed store, hash-verified

1152
1153/* We consider two PSBTs *equivalent* if they have the same inputs and outputs */
1154static bool psbt_equivalent(const struct wally_psbt *a,
1155 const struct wally_psbt *b)
1156{
1157 if (a->num_inputs != b->num_inputs)
1158 return false;
1159 if (a->num_outputs != b->num_outputs)
1160 return false;
1161
1162 for (size_t i = 0; i < a->num_inputs; i++) {
1163 if (!memeq(psbt_input_txid(a, i), WALLY_TXHASH_LEN,
1164 psbt_input_txid(b, i), WALLY_TXHASH_LEN))
1165 return false;
1166
1167 if (psbt_input_index(a, i) != psbt_input_index(b, i))
1168 return false;
1169
1170 if (psbt_input_sequence(a, i) != psbt_input_sequence(b, i))
1171 return false;
1172 }
1173
1174 for (size_t i = 0; i < a->num_outputs; i++) {
1175 size_t a_scriptlen, b_scriptlen;
1176
1177 if (psbt_output_amount(a, i) != psbt_output_amount(b, i))
1178 return false;
1179 a_scriptlen = psbt_output_scriptlen(a, i);
1180 b_scriptlen = psbt_output_scriptlen(b, i);
1181 if (!memeq(psbt_output_script(a, i), a_scriptlen,
1182 psbt_output_script(b, i), b_scriptlen))
1183 return false;
1184 }
1185
1186 return true;
1187}
1188
1189static struct command_result *json_sendpsbt(struct command *cmd,
1190 const char *buffer,

Callers 1

json_sendpsbtFunction · 0.85

Calls 7

memeqFunction · 0.85
psbt_input_txidFunction · 0.85
psbt_input_indexFunction · 0.85
psbt_input_sequenceFunction · 0.85
psbt_output_amountFunction · 0.85
psbt_output_scriptlenFunction · 0.85
psbt_output_scriptFunction · 0.85

Tested by

no test coverage detected