Skip to content

Commit

Permalink
routing: use Identifier in place of PaymentHash
Browse files Browse the repository at this point in the history
Since we want to support AMP payment using a different unique payment
identifier (AMP payments don't go to one specific hash), we change the
nomenclature to be Identifier instead of PaymentHash.
  • Loading branch information
halseth committed Apr 27, 2021
1 parent 6104d12 commit f07c9d0
Show file tree
Hide file tree
Showing 17 changed files with 296 additions and 245 deletions.
2 changes: 1 addition & 1 deletion channeldb/duplicate_payments.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ func deserializeDuplicatePaymentCreationInfo(r io.Reader) (

c := &PaymentCreationInfo{}

if _, err := io.ReadFull(r, c.PaymentHash[:]); err != nil {
if _, err := io.ReadFull(r, c.PaymentIdentifier[:]); err != nil {
return nil, err
}

Expand Down
12 changes: 7 additions & 5 deletions channeldb/payment_control.go
Original file line number Diff line number Diff line change
Expand Up @@ -173,8 +173,10 @@ func (p *PaymentControl) InitPayment(paymentHash lntypes.Hash,

// Once we have obtained a sequence number, we add an entry
// to our index bucket which will map the sequence number to
// our payment hash.
err = createPaymentIndexEntry(tx, sequenceNum, info.PaymentHash)
// our payment identifier.
err = createPaymentIndexEntry(
tx, sequenceNum, info.PaymentIdentifier,
)
if err != nil {
return err
}
Expand Down Expand Up @@ -220,12 +222,12 @@ const paymentIndexTypeHash paymentIndexType = 0

// createPaymentIndexEntry creates a payment hash typed index for a payment. The
// index produced contains a payment index type (which can be used in future to
// signal different payment index types) and the payment hash.
// signal different payment index types) and the payment identifier.
func createPaymentIndexEntry(tx kvdb.RwTx, sequenceNumber []byte,
hash lntypes.Hash) error {
id lntypes.Hash) error {

var b bytes.Buffer
if err := WriteElements(&b, paymentIndexTypeHash, hash[:]); err != nil {
if err := WriteElements(&b, paymentIndexTypeHash, id[:]); err != nil {
return err
}

Expand Down
Loading

0 comments on commit f07c9d0

Please sign in to comment.