akkounts/app/controllers/api/btcpay_controller.rb
Râu Cao 69fffb29d8
Some checks failed
continuous-integration/drone/push Build is passing
continuous-integration/drone/pr Build is failing
Make publishing of BTCPay wallet balances optional
2023-09-20 18:36:53 +02:00

30 lines
854 B
Ruby

class Api::BtcpayController < Api::BaseController
before_action :require_feature_enabled
def onchain_btc_balance
balance = BtcpayManager::FetchOnchainWalletBalance.call
render json: balance
rescue => error
Rails.logger.warn "Failed to fetch BTC wallet balance: #{error.message}"
render json: { error: 'Failed to fetch wallet balance' },
status: 500
end
def lightning_btc_balance
balance = BtcpayManager::FetchLightningWalletBalance.call
render json: balance
rescue => error
Rails.logger.warn "Failed to fetch BTC lightning balance: #{error.message}"
render json: { error: 'Failed to fetch wallet balance' },
status: 500
end
private
def require_feature_enabled
unless Setting.btcpay_publish_wallet_balances
http_status :not_found and return
end
end
end