bitcoin-client
bitcoin client library for price ticker and wallet
git clone https://9o.is/git/bitcoin-client.git
README.md
(1402B)
1 # Bitcoin Client Library
2
3 Provides several client-side bitcoin services such as price ticker and wallet.
4
5 ----
6 ## usage examples
7
8 Retrieve bitcoin price using BitStamp service.
9
10 import akka.actor._
11 import akka.pattern._
12 import scala.concurrent.duration._
13 import inc.pyc.bitcoin._
14
15 val props = BitcoinService.props(BitcoinService.BitStamp)
16 val system = ActorSystem("sys")
17
18 import system.dispatcher
19 val ticker = system.actorOf(props)
20 val price = ticker.ask(Tick)(5 seconds).mapTo[Price]
21 price.foreach(p => println(p.format))
22
23
24 Retrieve bitcoin address balance using Blockchain service.
25
26 import akka.actor._
27 import akka.pattern._
28 import com.typesafe.config._
29 import scala.concurrent.duration._
30 import inc.pyc.bitcoin._, BitcoinJsonRPC._
31
32 val props = BitcoinService.props(BitcoinService.BlockChain)
33 val system = ActorSystem("sys", ConfigFactory.load(ConfigFactory.parseString("""
34 bitcoin.blockchain {
35 wallet-uri = "https://rpc.blockchain.info"
36 rpc-user = "<blockchain wallet identifier>"
37 rpc-pass = "<blockchain password>"
38 wallet-pass = "<blockchain second password>"
39 }
40 """)))
41
42 import system.dispatcher
43 val wallet = system.actorOf(props)
44 val balance = wallet.ask(GetBalance)(5 seconds).mapTo[String]
45 balance.foreach(println)