clean up duplicated code

This commit is contained in:
kiwiidb
2023-02-04 14:47:55 +01:00
parent 32feb2c824
commit 3ebcd9cd1d

View File

@@ -59,6 +59,28 @@ func (svc *LndhubService) postToWebhook(invoice models.Invoice, url string) {
}
}
type WebhookInvoicePayload struct {
ID int64 `json:"id"`
Type string `json:"type"`
UserLogin string `json:"user_login"`
Amount int64 `json:"amount"`
Fee int64 `json:"fee"`
Memo string `json:"memo"`
DescriptionHash string `json:"description_hash,omitempty"`
PaymentRequest string `json:"payment_request"`
DestinationPubkeyHex string `json:"destination_pubkey_hex"`
DestinationCustomRecords map[uint64][]byte `json:"custom_records,omitempty"`
RHash string `json:"r_hash"`
Preimage string `json:"preimage"`
Keysend bool `json:"keysend"`
State string `json:"state"`
ErrorMessage string `json:"error_message,omitempty"`
CreatedAt time.Time `json:"created_at"`
ExpiresAt time.Time `json:"expires_at"`
UpdatedAt time.Time `json:"updated_at"`
SettledAt time.Time `json:"settled_at"`
}
func (svc *LndhubService) subscribeIncomingOutgoingInvoices() (incoming, outgoing chan models.Invoice, err error) {
incomingInvoices := make(chan models.Invoice)
outgoingInvoices := make(chan models.Invoice)
@@ -96,25 +118,3 @@ func convertPayload(invoice models.Invoice, user *models.User) (result WebhookIn
SettledAt: invoice.SettledAt.Time,
}
}
type WebhookInvoicePayload struct {
ID int64 `json:"id"`
Type string `json:"type"`
UserLogin string `json:"user_login"`
Amount int64 `json:"amount"`
Fee int64 `json:"fee"`
Memo string `json:"memo"`
DescriptionHash string `json:"description_hash,omitempty"`
PaymentRequest string `json:"payment_request"`
DestinationPubkeyHex string `json:"destination_pubkey_hex"`
DestinationCustomRecords map[uint64][]byte `json:"custom_records,omitempty"`
RHash string `json:"r_hash"`
Preimage string `json:"preimage"`
Keysend bool `json:"keysend"`
State string `json:"state"`
ErrorMessage string `json:"error_message,omitempty"`
CreatedAt time.Time `json:"created_at"`
ExpiresAt time.Time `json:"expires_at"`
UpdatedAt time.Time `json:"updated_at"`
SettledAt time.Time `json:"settled_at"`
}