Use v2 API for creating new lndhub accounts
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/pr Build is passing

This commit is contained in:
Râu Cao
2022-12-23 12:22:45 +07:00
parent 6df3d5933c
commit e62bf67262
6 changed files with 15 additions and 15 deletions

View File

@@ -1,11 +1,11 @@
class CreateLndhubWalletJob < ApplicationJob
class CreateLndhubAccountJob < ApplicationJob
queue_as :default
def perform(user)
return if user.ln_login.present? && user.ln_password.present?
lndhub = Lndhub.new
credentials = lndhub.create({ partnerid: user.ou, accounttype: "user" })
lndhub = LndhubV2.new
credentials = lndhub.create_account
user.update! ln_login: credentials["login"],
ln_password: credentials["password"]

View File

@@ -11,7 +11,7 @@ class CreateAccount < ApplicationService
def call
user = create_user_in_database
add_ldap_document
create_lndhub_wallet(user)
create_lndhub_account(user)
if @invitation.present?
update_invitation(user.id)
@@ -49,9 +49,9 @@ class CreateAccount < ApplicationService
ExchangeXmppContactsJob.perform_later(@invitation.user, @username, @domain)
end
def create_lndhub_wallet(user)
def create_lndhub_account(user)
#TODO enable in development when we have a local lndhub (mock?) API
return if Rails.env.development?
CreateLndhubWalletJob.perform_later(user)
CreateLndhubAccountJob.perform_later(user)
end
end

View File

@@ -70,7 +70,7 @@ class LndhubV2
# V2
#
def create_account(payload)
def create_account(payload={})
post "v2/users", payload, admin_token: Rails.application.credentials.lndhub[:admin_token]
end