We consider two PSBTs *equivalent* if they have the same inputs and outputs */
| 1116 | |
| 1117 | /* We consider two PSBTs *equivalent* if they have the same inputs and outputs */ |
| 1118 | static bool psbt_equivalent(const struct wally_psbt *a, |
| 1119 | const struct wally_psbt *b) |
| 1120 | { |
| 1121 | if (a->num_inputs != b->num_inputs) |
| 1122 | return false; |
| 1123 | if (a->num_outputs != b->num_outputs) |
| 1124 | return false; |
| 1125 | |
| 1126 | for (size_t i = 0; i < a->num_inputs; i++) { |
| 1127 | if (!memeq(psbt_input_txid(a, i), WALLY_TXHASH_LEN, |
| 1128 | psbt_input_txid(b, i), WALLY_TXHASH_LEN)) |
| 1129 | return false; |
| 1130 | |
| 1131 | if (psbt_input_index(a, i) != psbt_input_index(b, i)) |
| 1132 | return false; |
| 1133 | |
| 1134 | if (psbt_input_sequence(a, i) != psbt_input_sequence(b, i)) |
| 1135 | return false; |
| 1136 | } |
| 1137 | |
| 1138 | for (size_t i = 0; i < a->num_outputs; i++) { |
| 1139 | size_t a_scriptlen, b_scriptlen; |
| 1140 | |
| 1141 | if (psbt_output_amount(a, i) != psbt_output_amount(b, i)) |
| 1142 | return false; |
| 1143 | a_scriptlen = psbt_output_scriptlen(a, i); |
| 1144 | b_scriptlen = psbt_output_scriptlen(b, i); |
| 1145 | if (!memeq(psbt_output_script(a, i), a_scriptlen, |
| 1146 | psbt_output_script(b, i), b_scriptlen)) |
| 1147 | return false; |
| 1148 | } |
| 1149 | |
| 1150 | return true; |
| 1151 | } |
| 1152 | |
| 1153 | static struct command_result *json_sendpsbt(struct command *cmd, |
| 1154 | const char *buffer, |
no test coverage detected