mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-09-05 17:05:50 +02:00
channeldb: save outgoing payments
Add structure for outgoing payments. Saving payment in DB after successful payment send. Add RPC call for listing all payments.
This commit is contained in:
committed by
Olaoluwa Osuntokun
parent
343cd7779f
commit
eb4d0e035e
@@ -98,11 +98,7 @@ type Invoice struct {
|
||||
Terms ContractTerm
|
||||
}
|
||||
|
||||
// AddInvoice inserts the targeted invoice into the database. If the invoice
|
||||
// has *any* payment hashes which already exists within the database, then the
|
||||
// insertion will be aborted and rejected due to the strict policy banning any
|
||||
// duplicate payment hashes.
|
||||
func (d *DB) AddInvoice(i *Invoice) error {
|
||||
func validateInvoice(i *Invoice) error {
|
||||
if len(i.Memo) > MaxMemoSize {
|
||||
return fmt.Errorf("max length a memo is %v, and invoice "+
|
||||
"of length %v was provided", MaxMemoSize, len(i.Memo))
|
||||
@@ -112,7 +108,18 @@ func (d *DB) AddInvoice(i *Invoice) error {
|
||||
"of length %v was provided", MaxReceiptSize,
|
||||
len(i.Receipt))
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// AddInvoice inserts the targeted invoice into the database. If the invoice
|
||||
// has *any* payment hashes which already exists within the database, then the
|
||||
// insertion will be aborted and rejected due to the strict policy banning any
|
||||
// duplicate payment hashes.
|
||||
func (d *DB) AddInvoice(i *Invoice) error {
|
||||
err := validateInvoice(i)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return d.Update(func(tx *bolt.Tx) error {
|
||||
invoices, err := tx.CreateBucketIfNotExists(invoiceBucket)
|
||||
if err != nil {
|
||||
|
Reference in New Issue
Block a user