Skip to content

Commit

Permalink
feat: Add anchor resolutions to closed channels
Browse files Browse the repository at this point in the history
  • Loading branch information
SeverinAlexB committed Jul 12, 2024
1 parent 9a7696d commit 50d1c08
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 1 deletion.
8 changes: 8 additions & 0 deletions lnd_methods/offchain/get_closed_channels.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,14 @@ export type GetClosedChannelsResult = {
transaction_id: string;
/** Channel Funding Output Index */
transaction_vout: number;
/** Anchor CPFP Transaction Id Hex */
anchor_spent_by?: string,
/** Our Close Transaction Anchor Output Index */
anchor_vout?: number,
/** Is Anchor CPFP Transaction Confirmed */
anchor_is_confirmed: boolean,
/** Is Anchor CPFP Transaction Pending */
anchor_is_pending: boolean,
}[];
};

Expand Down
5 changes: 5 additions & 0 deletions lnd_methods/offchain/get_closed_channels.js
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@ module.exports = (args, cbk) => {
const resolutions = chanResolutions.map(rpcResolutionAsResolution);

const {balance} = resolutions.find(n => n.balance) || {balance: {}};
const {anchor} = resolutions.find(n => n.anchor) || {anchor: {}};
const payments = resolutions.map(n => n.payment).filter(n => !!n);

return cbk(null, {
Expand All @@ -201,6 +202,10 @@ module.exports = (args, cbk) => {
close_confirm_height: height,
close_payments: payments,
close_transaction_id: closeTxId,
anchor_spent_by: anchor?.spent_by,
anchor_vout: anchor?.anchor_vout,
anchor_is_confirmed: anchor? anchor.is_confirmed: false,
anchor_is_pending: anchor? anchor.is_pending: false,
final_local_balance: Number(chan.settled_balance),
final_time_locked_balance: finalTimeLock,
id: !chanId ? undefined : chanId.channel,
Expand Down
3 changes: 2 additions & 1 deletion lnd_responses/constants.json
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,8 @@
"resolutionTypes": {
"balance": "COMMIT",
"incoming_payment": "INCOMING_HTLC",
"outgoing_payment": "OUTGOING_HTLC"
"outgoing_payment": "OUTGOING_HTLC",
"anchor": "ANCHOR"
},
"syncTypes": {
"active": "ACTIVE_SYNC",
Expand Down
10 changes: 10 additions & 0 deletions lnd_responses/rpc_resolution_as_resolution.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,16 @@ module.exports = args => {
},
};

case resolutionTypes.anchor:
return {
anchor: {
is_confirmed: args.outcome === resolutionOutcomes.confirmed,
is_pending: args.outcome === resolutionOutcomes.pending,
spent_by: args.sweep_txid || undefined,
vout: args.outpoint.output_index,
}
}

default:
return {};
}
Expand Down

0 comments on commit 50d1c08

Please sign in to comment.