Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix opening transaction details in Core Lightning #1868

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions models/Transaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,11 +118,11 @@ export default class Transaction extends BaseModel {
}

@computed public get getOutpoint(): string {
let outpoint = '';
this.output_details.map((output: OutputDetail) => {
if (output.is_our_address)
outpoint = `${this.tx}:${output.output_index}`;
});
return outpoint;
const lastOutputWithOurAddress = this.output_details
?.filter((d) => d.is_our_address)
Copy link
Contributor

@kaloudis kaloudis Nov 23, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think is_our_address is CLN only so this will break for LND

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nevermind, looks like that's an LND property

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I figured this would have used txid and output from CLN-rest (see https://github.com/Ride-The-Lightning/c-lightning-REST/blob/master/controllers/listfunds.js#L25) if there was going to be a re-write like this

Otherwise, I would have just added some optional chaining (?.) to prevent the crash.

Maybe I'm missing something

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need the is_our_address or an equivalent property for this and listfunds does not provide this. Do you have an idea how to implement this for CLN?

The reason we did not just add a ? is because we think the code is more descriptive now as the last output with is_our_address is used (first we thought the first one would be used).

The question is: Is the last output really the one that should be used? Or maybe rather the one with the biggest amount?

.at(-1);
return lastOutputWithOurAddress != null
? `${this.tx}:${lastOutputWithOurAddress.output_index}`
: '';
}
}