| 838 | } |
| 839 | |
| 840 | static bool is_mutual_close(const struct tx_parts *tx, |
| 841 | const u8 *local_scriptpubkey, |
| 842 | const u8 *remote_scriptpubkey) |
| 843 | { |
| 844 | size_t i; |
| 845 | bool local_matched = false, remote_matched = false; |
| 846 | |
| 847 | for (i = 0; i < tal_count(tx->outputs); i++) { |
| 848 | /* To be paranoid, we only let each one match once. */ |
| 849 | if (chainparams->is_elements && |
| 850 | tx->outputs[i]->script_len == 0) { |
| 851 | /* This is a fee output, ignore please */ |
| 852 | continue; |
| 853 | } else if (wally_tx_output_scripteq(tx->outputs[i], |
| 854 | local_scriptpubkey) |
| 855 | && !local_matched) { |
| 856 | local_matched = true; |
| 857 | } else if (wally_tx_output_scripteq(tx->outputs[i], |
| 858 | remote_scriptpubkey) |
| 859 | && !remote_matched) |
| 860 | remote_matched = true; |
| 861 | else |
| 862 | return false; |
| 863 | } |
| 864 | |
| 865 | return true; |
| 866 | } |
| 867 | |
| 868 | /* We only ever send out one, so matching it is easy. */ |
| 869 | static bool is_local_commitment(const struct bitcoin_txid *txid, |
no test coverage detected