| 127 | } |
| 128 | |
| 129 | void audit_psbt(const tal_t *ctx, const struct wally_psbt *psbt) |
| 130 | { |
| 131 | assert(psbt); |
| 132 | assert(NULL_OR_MATCH_P(psbt->tx, ctx)); |
| 133 | assert(NULL_OR_MATCH_P(psbt->inputs, ctx)); |
| 134 | assert(NULL_OR_MATCH_P(psbt->outputs, ctx)); |
| 135 | audit_map(ctx, &psbt->unknowns); |
| 136 | audit_map(ctx, &psbt->global_xpubs); |
| 137 | #ifndef WALLY_ABI_NO_ELEMENTS |
| 138 | audit_map(ctx, &psbt->global_scalars); |
| 139 | #endif |
| 140 | for (size_t i = 0; i < psbt->num_inputs; i++) { |
| 141 | assert(NULL_OR_MATCH_P(psbt->inputs[i].utxo, ctx)); |
| 142 | assert(NULL_OR_MATCH_P(psbt->inputs[i].witness_utxo, ctx)); |
| 143 | assert(NULL_OR_MATCH_P(psbt->inputs[i].final_witness, ctx)); |
| 144 | audit_map(ctx, &psbt->inputs[i].keypaths); |
| 145 | audit_map(ctx, &psbt->inputs[i].signatures); |
| 146 | audit_map(ctx, &psbt->inputs[i].unknowns); |
| 147 | audit_map(ctx, &psbt->inputs[i].preimages); |
| 148 | audit_map(ctx, &psbt->inputs[i].psbt_fields); |
| 149 | audit_map(ctx, &psbt->inputs[i].taproot_leaf_signatures); |
| 150 | audit_map(ctx, &psbt->inputs[i].taproot_leaf_scripts); |
| 151 | audit_map(ctx, &psbt->inputs[i].taproot_leaf_hashes); |
| 152 | audit_map(ctx, &psbt->inputs[i].taproot_leaf_paths); |
| 153 | /* DTODO: Investigate if taproot wally maps have child maps */ |
| 154 | #ifndef WALLY_ABI_NO_ELEMENTS |
| 155 | assert(NULL_OR_MATCH_P(psbt->inputs[i].pegin_tx, ctx)); |
| 156 | assert(NULL_OR_MATCH_P(psbt->inputs[i].pegin_witness, ctx)); |
| 157 | audit_map(ctx, &psbt->inputs[i].pset_fields); |
| 158 | #endif |
| 159 | } |
| 160 | for (size_t i = 0; i < psbt->num_outputs; i++) { |
| 161 | assert(NULL_OR_MATCH_P(psbt->outputs[i].script, ctx)); |
| 162 | assert(psbt->outputs[i].script_len |
| 163 | == tal_bytelen(psbt->outputs[i].script)); |
| 164 | audit_map(ctx, &psbt->outputs[i].keypaths); |
| 165 | audit_map(ctx, &psbt->outputs[i].unknowns); |
| 166 | audit_map(ctx, &psbt->outputs[i].psbt_fields); |
| 167 | audit_map(ctx, &psbt->outputs[i].taproot_tree); |
| 168 | audit_map(ctx, &psbt->outputs[i].taproot_leaf_hashes); |
| 169 | audit_map(ctx, &psbt->outputs[i].taproot_leaf_paths); |
| 170 | #ifndef WALLY_ABI_NO_ELEMENTS |
| 171 | audit_map(ctx, &psbt->outputs[i].pset_fields); |
| 172 | #endif |
| 173 | } |
| 174 | } |
| 175 | |
| 176 | bool psbt_is_finalized(const struct wally_psbt *psbt) |
| 177 | { |