multi: rename key_send, key-send and key send to keysend

This commit is contained in:
Conner Fromknecht committed 2020-01-16 18:37:16 -08:00
1 parent 3aba0f1eaf
commit 51dbdd3b38
13 files changed
+638 -637

No files matched your search

+9 -9
View File
@@ -695,12 +695,12 @@ func (i *InvoiceRegistry) cancelSingleHtlc(hash lntypes.Hash,
return nil
}
// processKeySend just-in-time inserts an invoice if this htlc is a key send
// processKeySend just-in-time inserts an invoice if this htlc is a keysend
// htlc.
func (i *InvoiceRegistry) processKeySend(ctx invoiceUpdateCtx,
hash lntypes.Hash) error {
// Retrieve key send record if present.
// Retrieve keysend record if present.
preimageSlice, ok := ctx.customRecords[record.KeySendType]
if !ok {
return nil
@@ -709,25 +709,25 @@ func (i *InvoiceRegistry) processKeySend(ctx invoiceUpdateCtx,
// Cancel htlc is preimage is invalid.
preimage, err := lntypes.MakePreimage(preimageSlice)
if err != nil || preimage.Hash() != hash {
return errors.New("invalid key send preimage")
return errors.New("invalid keysend preimage")
}
// Don't accept zero preimages as those have a special meaning in our
// database for hodl invoices.
if preimage == channeldb.UnknownPreimage {
return errors.New("invalid key send preimage")
return errors.New("invalid keysend preimage")
}
// Only allow key send for non-mpp payments.
// Only allow keysend for non-mpp payments.
if ctx.mpp != nil {
return errors.New("no mpp key send supported")
return errors.New("no mpp keysend supported")
}
// Create an invoice for the htlc amount.
amt := ctx.amtPaid
// Set tlv optional feature vector on the invoice. Otherwise we wouldn't
// be able to pay to it with key send.
// be able to pay to it with keysend.
rawFeatures := lnwire.NewRawFeatureVector(
lnwire.TLVOnionPayloadOptional,
)
@@ -802,13 +802,13 @@ func (i *InvoiceRegistry) NotifyExitHopHtlc(rHash lntypes.Hash,
mpp: mpp,
}
// Process key send if present. Do this outside of the lock, because
// Process keysend if present. Do this outside of the lock, because
// AddInvoice obtains its own lock. This is no problem, because the
// operation is idempotent.
if i.cfg.AcceptKeySend {
err := i.processKeySend(updateCtx, rHash)
if err != nil {
debugLog(fmt.Sprintf("key send error: %v", err))
debugLog(fmt.Sprintf("keysend error: %v", err))
return NewFailureResolution(
circuitKey, currentHeight, ResultKeySendError,
+8 -8
View File
@@ -598,7 +598,7 @@ func TestUnknownInvoice(t *testing.T) {
}
}
// TestKeySend tests receiving a spontaneous payment with and without key send
// TestKeySend tests receiving a spontaneous payment with and without keysend
// enabled.
func TestKeySend(t *testing.T) {
t.Run("enabled", func(t *testing.T) {
@@ -609,7 +609,7 @@ func TestKeySend(t *testing.T) {
})
}
// testKeySend is the inner test function that tests key send for a particular
// testKeySend is the inner test function that tests keysend for a particular
// enabled state on the receiver end.
func testKeySend(t *testing.T, keySendEnabled bool) {
defer timeout()()
@@ -627,11 +627,11 @@ func testKeySend(t *testing.T, keySendEnabled bool) {
amt := lnwire.MilliSatoshi(1000)
expiry := uint32(testCurrentHeight + 20)
// Create key for key send.
// Create key for keysend.
preimage := lntypes.Preimage{1, 2, 3}
hash := preimage.Hash()
// Try to settle invoice with an invalid key send htlc.
// Try to settle invoice with an invalid keysend htlc.
invalidKeySendPayload := &mockPayload{
customRecords: map[uint64][]byte{
record.KeySendType: {1, 2, 3},
@@ -656,10 +656,10 @@ func testKeySend(t *testing.T, keySendEnabled bool) {
t.Fatal("expected invoice not found outcome")
case keySendEnabled && resolution.Outcome != ResultKeySendError:
t.Fatal("expected key send error")
t.Fatal("expected keysend error")
}
// Try to settle invoice with a valid key send htlc.
// Try to settle invoice with a valid keysend htlc.
keySendPayload := &mockPayload{
customRecords: map[uint64][]byte{
record.KeySendType: preimage[:],
@@ -674,10 +674,10 @@ func testKeySend(t *testing.T, keySendEnabled bool) {
t.Fatal(err)
}
// Expect a cancel resolution if key send is disabled.
// Expect a cancel resolution if keysend is disabled.
if !keySendEnabled {
if resolution.Outcome != ResultInvoiceNotFound {
t.Fatal("expected key send payment not to be accepted")
t.Fatal("expected keysend payment not to be accepted")
}
return
}
+2 -2
View File
@@ -86,7 +86,7 @@ const (
// invoice that is unknown to us.
ResultInvoiceNotFound
// ResultKeySendError is returned when we receive invalid key send
// ResultKeySendError is returned when we receive invalid keysend
// parameters.
ResultKeySendError
)
@@ -150,7 +150,7 @@ func (u ResolutionResult) String() string {
return "mpp is overpaying set total"
case ResultKeySendError:
return "invalid key send parameters"
return "invalid keysend parameters"
default:
return "unknown"