30 lines
854 B
Ruby
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
|