diff --git a/.env.test b/.env.test index 03daa76..9a1c70f 100644 --- a/.env.test +++ b/.env.test @@ -2,7 +2,6 @@ EJABBERD_API_URL='http://xmpp.example.com/api' BTCPAY_API_URL='http://btcpay.example.com/api/v1' -LNDHUB_LEGACY_API_URL='http://localhost:3023' LNDHUB_API_URL='http://localhost:3026' LNDHUB_PUBLIC_URL='https://lndhub.kosmos.org' diff --git a/app/controllers/wallet_controller.rb b/app/controllers/wallet_controller.rb index 535eed1..a7920d4 100644 --- a/app/controllers/wallet_controller.rb +++ b/app/controllers/wallet_controller.rb @@ -7,7 +7,7 @@ class WalletController < ApplicationController before_action :fetch_balance def index - @wallet_url = "lndhub://#{current_user.ln_login}:#{current_user.ln_password}@#{ENV['LNDHUB_PUBLIC_URL']}" + @wallet_url = "lndhub://#{current_user.ln_account}:#{current_user.ln_password}@#{ENV['LNDHUB_PUBLIC_URL']}" qrcode = RQRCode::QRCode.new(@wallet_url) @svg = qrcode.as_svg( diff --git a/app/jobs/create_lndhub_account_job.rb b/app/jobs/create_lndhub_account_job.rb index 52d2a2c..6569bcf 100644 --- a/app/jobs/create_lndhub_account_job.rb +++ b/app/jobs/create_lndhub_account_job.rb @@ -2,13 +2,12 @@ class CreateLndhubAccountJob < ApplicationJob queue_as :default def perform(user) - return if user.ln_login.present? && user.ln_password.present? + return if user.ln_account.present? && user.ln_password.present? lndhub = LndhubV2.new credentials = lndhub.create_account 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/app/services/lndhub.rb b/app/services/lndhub.rb index c9547d3..9febebf 100644 --- a/app/services/lndhub.rb +++ b/app/services/lndhub.rb @@ -2,7 +2,7 @@ class Lndhub attr_accessor :auth_token def initialize - @base_url = ENV["LNDHUB_LEGACY_API_URL"] + @base_url = ENV["LNDHUB_API_URL"] end def post(endpoint, payload) @@ -42,7 +42,7 @@ class Lndhub end def authenticate(user) - credentials = post "auth?type=auth", { login: user.ln_login, password: user.ln_password } + credentials = post "auth?type=auth", { login: user.ln_account, password: user.ln_password } self.auth_token = credentials["access_token"] self.auth_token end diff --git a/app/services/lndhub_v2.rb b/app/services/lndhub_v2.rb index bb4c4b9..693f812 100644 --- a/app/services/lndhub_v2.rb +++ b/app/services/lndhub_v2.rb @@ -39,7 +39,7 @@ class LndhubV2 end def authenticate(user) - credentials = post "auth?type=auth", { login: user.ln_login, password: user.ln_password } + credentials = post "auth?type=auth", { login: user.ln_account, password: user.ln_password } self.auth_token = credentials["access_token"] self.auth_token end diff --git a/db/migrate/20230223115536_remove_ln_login_from_users.rb b/db/migrate/20230223115536_remove_ln_login_from_users.rb new file mode 100644 index 0000000..82ab8f1 --- /dev/null +++ b/db/migrate/20230223115536_remove_ln_login_from_users.rb @@ -0,0 +1,5 @@ +class RemoveLnLoginFromUsers < ActiveRecord::Migration[7.0] + def change + remove_column :users, :ln_login_cyphertext + end +end diff --git a/db/schema.rb b/db/schema.rb index 6b3cf56..f87e1b0 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: 2023_02_17_084310) do +ActiveRecord::Schema[7.0].define(version: 2023_02_23_115536) do create_table "donations", force: :cascade do |t| t.integer "user_id" t.integer "amount_sats" diff --git a/spec/jobs/create_lndhub_account_job_spec.rb b/spec/jobs/create_lndhub_account_job_spec.rb index aa2d179..51ffe2d 100644 --- a/spec/jobs/create_lndhub_account_job_spec.rb +++ b/spec/jobs/create_lndhub_account_job_spec.rb @@ -19,7 +19,7 @@ RSpec.describe CreateLndhubAccountJob, type: :job do .with { |req| req.body == '{}' } user.reload - expect(user.ln_login).to eq("abc123") + expect(user.ln_account).to eq("abc123") expect(user.ln_password).to eq("def456") end