module BtcpayManager
  class FetchOnchainWalletBalance < BtcpayManagerService
    def call
      res = get "stores/#{store_id}/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
