-
Notifications
You must be signed in to change notification settings - Fork 23
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/add fee provision 2 #395
Changes from all commits
000177f
1313e08
dc54877
3660db3
6b149af
f0237fa
1c841b4
4bd2613
1677a97
9ba016b
c20f02e
a22ab04
c3bd3bc
da3912f
c0c2f3e
809a6f9
61132a7
ef2f267
ec0493c
59ee273
c09554a
3527f44
d8a9201
9a6f9ab
3497d53
8831541
1f2ffb9
24428b3
5a264de
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
alter table transaction_entries | ||
add column entry_type character varying; | ||
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
alter table transaction_entries drop constraint unique_tx_entry_tuple, | ||
add constraint unique_tx_entry_tuple UNIQUE(user_id, invoice_id, debit_account_id, credit_account_id, entry_type); |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,15 @@ import ( | |
"time" | ||
) | ||
|
||
const ( | ||
EntryTypeIncoming = "incoming" | ||
EntryTypeOutgoing = "outgoing" | ||
EntryTypeFee = "fee" | ||
EntryTypeFeeReserve = "fee_reserve" | ||
EntryTypeFeeReserveReversal = "fee_reserve_reversal" | ||
EntryTypeOutgoingReversal = "outgoing_reversal" | ||
) | ||
|
||
// TransactionEntry : Transaction Entries Model | ||
type TransactionEntry struct { | ||
ID int64 `bun:",pk,autoincrement"` | ||
|
@@ -14,9 +23,11 @@ type TransactionEntry struct { | |
ParentID int64 `bun:",nullzero"` | ||
Parent *TransactionEntry `bun:"rel:belongs-to"` | ||
CreditAccountID int64 `bun:",notnull"` | ||
FeeReserve *TransactionEntry `bun:"rel:belongs-to"` | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. how does this reference work? where is the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's added there in https://github.com/getAlby/lndhub.go/blob/main/lib/service/checkpayments.go#L68. We're looking it up with its invoice id and entry_type = There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. so you say this which then can be used in here: https://github.com/getAlby/lndhub.go/blob/main/lib/service/invoices.go#L311-L316 (if moved down) by SQL it should be possible There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. if bun does not do that automatically then I think we can use with that we at least should have the inserted ID in the result: https://pkg.go.dev/database/sql#Result so we save the fee reserve, get the ID of that entry and save that in the tx and all this in a transaction. |
||
CreditAccount *Account `bun:"rel:belongs-to,join:credit_account_id=id"` | ||
DebitAccountID int64 `bun:",notnull"` | ||
DebitAccount *Account `bun:"rel:belongs-to,join:debit_account_id=id"` | ||
Amount int64 `bun:",notnull"` | ||
CreatedAt time.Time `bun:",nullzero,notnull,default:current_timestamp"` | ||
EntryType string | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what's with old payments? I guess we can update that entry for those?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think they can just be kept as they are, it seems a lot of work and not very useful to update.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's inconsitent data that also requires special handling.
currently we only have
incoming
outgoing
andfee
transactions so the migration should be possible, e.g by iterating through the entries and checking the accounts.I'd prefer not having old/inconsistent data if possible