akkounts/app/services/btcpay_manager/fetch_onchain_wallet_balance.rb
Râu Cao 69b3afb8f7
DRY up btcpay and lndhub services
Removing initialize methods from the main/manager class also allows for
different iniitalizers in specific task services
2024-03-02 14:31:48 +01:00

14 lines
406 B
Ruby

module BtcpayManager
class FetchOnchainWalletBalance < BtcpayManagerService
def call
res = get "/payment-methods/onchain/BTC/wallet"
{
balance: (res["balance"].to_f * 100000000).to_i, # BTC to sats
unconfirmed_balance: (res["unconfirmedBalance"].to_f * 100000000).to_i,
confirmed_balance: (res["confirmedBalance"].to_f * 100000000).to_i
}
end
end
end