Skip to content

Commit

Permalink
Fixed problem when using many bitcoin adresses and rate limiting API.
Browse files Browse the repository at this point in the history
  • Loading branch information
UdoBretz committed Oct 9, 2020
1 parent b061650 commit 9ef7273
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion Bitcoin.lua
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@


WebBanking{
version = 0.3,
version = 0.5,
description = "Include your Bitcoins as cryptoportfolio in MoneyMoney by providing Bitcoin addresses as username (comma separated).",
services= { "Bitcoin" }
}
Expand Down Expand Up @@ -72,6 +72,9 @@ function RefreshAccount (account, since)
quantity = bitcoinQuantity,
price = BTCinEURprice,
}

-- Add sleep for 1 second to avoid possible rate limitation of the API
sleep(1)
end

return {securities = s}
Expand Down Expand Up @@ -110,3 +113,9 @@ end
function bitcoinRequestUrl(bitcoinAddress)
return "https://api.blockcypher.com/v1/btc/main/addrs/" .. bitcoinAddress
end

function sleep(n) -- seconds
local t0 = os.clock()
while os.clock() - t0 <= n do
end
end

0 comments on commit 9ef7273

Please sign in to comment.