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

Function is_mutual_close

onchaind/onchaind.c:840–866  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

838}
839
840static 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. */
869static bool is_local_commitment(const struct bitcoin_txid *txid,

Callers 1

mainFunction · 0.85

Calls 1

wally_tx_output_scripteqFunction · 0.85

Tested by

no test coverage detected