diff --git a/app/jobs/create_lndhub_account_job.rb b/app/jobs/create_lndhub_account_job.rb index 9cf33b1..52d2a2c 100644 --- a/app/jobs/create_lndhub_account_job.rb +++ b/app/jobs/create_lndhub_account_job.rb @@ -7,7 +7,8 @@ class CreateLndhubAccountJob < ApplicationJob lndhub = LndhubV2.new credentials = lndhub.create_account - user.update! ln_login: credentials["login"], + user.update! ln_account: credentials["login"], + ln_login: credentials["login"], # TODO remove when production is migrated ln_password: credentials["password"] end end diff --git a/db/migrate/20230111113139_add_ln_account_to_users.rb b/db/migrate/20230111113139_add_ln_account_to_users.rb new file mode 100644 index 0000000..d625344 --- /dev/null +++ b/db/migrate/20230111113139_add_ln_account_to_users.rb @@ -0,0 +1,9 @@ +class AddLnAccountToUsers < ActiveRecord::Migration[7.0] + def change + add_column :users, :ln_account, :string + + User.all.each do |user| + user.update! ln_account: user.ln_login + end + end +end diff --git a/db/schema.rb b/db/schema.rb index 773ba10..486c465 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema[7.0].define(version: 2021_11_20_010540) do +ActiveRecord::Schema[7.0].define(version: 2023_01_11_113139) do create_table "donations", force: :cascade do |t| t.integer "user_id" t.integer "amount_sats" @@ -48,6 +48,7 @@ ActiveRecord::Schema[7.0].define(version: 2021_11_20_010540) do t.string "unconfirmed_email" t.text "ln_login_ciphertext" t.text "ln_password_ciphertext" + t.string "ln_account" t.index ["email"], name: "index_users_on_email", unique: true t.index ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true end diff --git a/spec/fixtures/lndhub/incoming.json b/spec/fixtures/lndhub/incoming.json new file mode 100644 index 0000000..fca7c8f --- /dev/null +++ b/spec/fixtures/lndhub/incoming.json @@ -0,0 +1,19 @@ +{ + "id": 58, + "type": "incoming", + "user_login": "689e27b237798b41d123", + "amount": 100, + "fee": 0, + "memo": "Sats for jimmy@kosmos.org: \"Buy you some beers\"", + "description_hash": "106af234beebd478206535486051b4f212bd31d2ed0f93e3efce7b5e7603d743", + "payment_request": "lnbc1u1p3mull3pp5qw4x46ew6kjknudypyjsg8maw935tr5kkuz7t6h7pugp3pt4msyqhp5zp40yd97a028sgr9x4yxq5d57gft6vwja58e8cl0eea4uasr6apscqzpgxqyz5vqsp53m2n8h6yeflgukv5fhwm802kur6un9w8nvycl7auk67w5g2u008q9qyyssqml8rfmxyvp32qd5939qx7uu0w6ppjuujlpwsrz28m9u0dzp799hz5j72w0xm8pg97hd4hdvwh9zxaw2hewnnmzewvc550f9y3qsfaegphmk0mu", + "destination_pubkey_hex": "024cd3be18617f39cf645851e3ba63f51fc13f0bb09e3bb25e6fd4de556486d946", + "r_hash": "03aa6aeb2ed5a569f1a40925041f7d7163458e96b705e5eafe0f10188575dc08", + "preimage": "3539663535656537343331663432653165396430623966633664656664646563", + "keysend": false, + "state": "settled", + "created_at": "2023-01-11T09:22:57.546364Z", + "expires_at": "2023-01-12T09:22:57.547209Z", + "updated_at": "2023-01-11T09:22:58.046236131Z", + "settled_at": "2023-01-11T09:22:58.046232174Z" +}