Skip to content

Commit

Permalink
fix: pass metadata in keysend self payments
Browse files Browse the repository at this point in the history
  • Loading branch information
rolznz committed Aug 20, 2024
1 parent d68aaa4 commit 15e9bbf
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
9 changes: 9 additions & 0 deletions transactions/keysend_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -470,6 +470,10 @@ func TestSendKeysend_IsolatedAppToIsolatedApp(t *testing.T) {
Type: 696969,
Value: hex.EncodeToString([]byte(strconv.FormatUint(uint64(app2.ID), 10))),
},
{
Type: 7629169,
Value: "7b22616374696f6e223a22626f6f7374222c2276616c75655f6d736174223a313030302c2276616c75655f6d7361745f746f74616c223a313030302c226170705f6e616d65223a22e29aa1205765624c4e2044656d6f222c226170705f76657273696f6e223a22312e30222c22666565644944223a2268747470733a2f2f66656564732e706f6463617374696e6465782e6f72672f706332302e786d6c222c22706f6463617374223a22506f6463617374696e6720322e30222c22657069736f6465223a22457069736f6465203130343a2041204e65772044756d70222c227473223a32312c226e616d65223a22e29aa1205765624c4e2044656d6f222c2273656e6465725f6e616d65223a225361746f736869204e616b616d6f746f222c226d657373616765223a22476f20706f6463617374696e6721227d",
},
}

mockEventConsumer := tests.NewMockEventConsumer()
Expand All @@ -496,6 +500,11 @@ func TestSendKeysend_IsolatedAppToIsolatedApp(t *testing.T) {
assert.Equal(t, app2.ID, *incomingTransaction.AppId)
assert.True(t, incomingTransaction.SelfPayment)

// receiving app should have the same data as what was sent
assert.Equal(t, transaction.Description, incomingTransaction.Description)
assert.Equal(t, transaction.Metadata, incomingTransaction.Metadata)
assert.Equal(t, transaction.Boostagram, incomingTransaction.Boostagram)

transactions := []db.Transaction{}
result := svc.DB.Find(&transactions)
assert.Equal(t, int64(3), result.RowsAffected)
Expand Down
6 changes: 5 additions & 1 deletion transactions/transactions_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -340,12 +340,16 @@ func (svc *transactionsService) SendKeysend(ctx context.Context, amount uint64,
recipientAppId := svc.getAppIdFromCustomRecords(customRecords)
dbTransaction := db.Transaction{
AppId: recipientAppId,
RequestEventId: nil,
RequestEventId: nil, // it is related to this request but for a different app
Type: constants.TRANSACTION_TYPE_INCOMING,
State: constants.TRANSACTION_STATE_PENDING,
AmountMsat: amount,
PaymentHash: paymentHash,
Preimage: &preimage,
Description: svc.getDescriptionFromCustomRecords(customRecords),
Metadata: datatypes.JSON(metadataBytes),
Boostagram: datatypes.JSON(boostagramBytes),
SelfPayment: true,
}
err = svc.db.Create(&dbTransaction).Error
if err != nil {
Expand Down

0 comments on commit 15e9bbf

Please sign in to comment.