Create LndHub accounts

This commit is contained in:
2021-11-19 20:10:36 -06:00
parent 088961dfec
commit f94227f9f3
12 changed files with 222 additions and 129 deletions

View File

@@ -0,0 +1,15 @@
class CreateLndhubWalletJob < ApplicationJob
queue_as :default
def perform(user)
res = Faraday.post("#{ENV["LNDHUB_API_URL"]}/create",
{ partnerid: "bluewallet", accounttype: "common" }.to_json,
"Content-Type" => "application/json")
credentials = JSON.parse(res.body)
user.update! ln_login: credentials["login"],
ln_password: credentials["password"]
end
end

View File

@@ -10,6 +10,9 @@ class User < ApplicationRecord
validates_uniqueness_of :email
validates :email, email: true
encrypts :ln_login
encrypts :ln_password
# Include default devise modules. Others available are:
# :confirmable, :lockable, :timeoutable, :trackable and :omniauthable
devise :ldap_authenticatable,

View File

@@ -10,6 +10,7 @@ class CreateAccount < ApplicationService
def call
user = create_user_in_database
add_ldap_document
create_lndhub_wallet
if @invitation.present?
update_invitation(user.id)
@@ -44,4 +45,8 @@ class CreateAccount < ApplicationService
return if Rails.env.development?
ExchangeXmppContactsJob.perform_later(@invitation.user, @username, @domain)
end
def create_lndhub_wallet
CreateLndhubWalletJob.perform_later(user)
end
end