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

Function is_closed_channel_txid

plugins/bkpr/recorder.c:1635–1681  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1633}
1634
1635static char *is_closed_channel_txid(const tal_t *ctx, struct db *db,
1636 struct chain_event *ev,
1637 struct bitcoin_txid *txid,
1638 bool *is_channel_close_tx)
1639{
1640 struct account *acct;
1641 struct chain_event *closed;
1642 u8 *inner_ctx = tal(NULL, u8);
1643
1644 /* Figure out if this is a channel close tx */
1645 acct = find_account(inner_ctx, db, ev->acct_name);
1646 assert(acct);
1647
1648 /* There's a separate process for figuring out
1649 * our onchain fees for channel closures */
1650 if (!acct->closed_event_db_id) {
1651 *is_channel_close_tx = false;
1652 tal_free(inner_ctx);
1653 return NULL;
1654 }
1655
1656 /* is the closed utxo the same as the one
1657 * we're trying to find fees for now */
1658 closed = find_chain_event_by_id(inner_ctx, db,
1659 *acct->closed_event_db_id);
1660 if (!closed) {
1661 *is_channel_close_tx = false;
1662 tal_free(inner_ctx);
1663 return tal_fmt(ctx, "Unable to find"
1664 " db record (chain_evt)"
1665 " with id %"PRIu64,
1666 *acct->closed_event_db_id);
1667 }
1668
1669 if (!closed->spending_txid) {
1670 *is_channel_close_tx = false;
1671 tal_free(inner_ctx);
1672 return tal_fmt(ctx, "Marked a closing"
1673 " event that's not"
1674 " actually a spend");
1675 }
1676
1677 *is_channel_close_tx =
1678 bitcoin_txid_eq(txid, closed->spending_txid);
1679 tal_free(inner_ctx);
1680 return NULL;
1681}
1682
1683void maybe_record_rebalance(struct db *db,
1684 struct channel_event *out)

Callers 1

Calls 3

find_accountFunction · 0.85
tal_freeFunction · 0.85
find_chain_event_by_idFunction · 0.85

Tested by

no test coverage detected