tipjar 0.1.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +8 -0
- data/Gemfile +3 -0
- data/README.md +140 -0
- data/README_old.md +140 -0
- data/Rakefile +3 -0
- data/bin/bitbot +55 -0
- data/bitbot.gemspec +28 -0
- data/lib/bitbot/blockchain.rb +70 -0
- data/lib/bitbot/database.rb +142 -0
- data/lib/bitbot/plugin.rb +83 -0
- data/lib/bitbot/plugin/balance.rb +8 -0
- data/lib/bitbot/plugin/common.rb +119 -0
- data/lib/bitbot/plugin/deposit.rb +33 -0
- data/lib/bitbot/plugin/doc.rb +5 -0
- data/lib/bitbot/plugin/help.rb +6 -0
- data/lib/bitbot/plugin/history.rb +27 -0
- data/lib/bitbot/plugin/online.rb +5 -0
- data/lib/bitbot/plugin/ping.rb +5 -0
- data/lib/bitbot/plugin/prize.rb +29 -0
- data/lib/bitbot/plugin/ticker.rb +15 -0
- data/lib/bitbot/plugin/tip.rb +61 -0
- data/lib/bitbot/plugin/tipstats.rb +29 -0
- data/lib/bitbot/plugin/txfee.rb +6 -0
- data/lib/bitbot/plugin/update_addresses.rb +112 -0
- data/lib/bitbot/plugin/update_exchange_rates.rb +5 -0
- data/lib/bitbot/plugin/version.rb +5 -0
- data/lib/bitbot/plugin/withdraw.rb +35 -0
- data/lib/ircstring.rb +55 -0
- data/tipjar.gemspec +28 -0
- metadata +159 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: edb9688b3b0718910793eb0f8ba0345894ded926
|
4
|
+
data.tar.gz: 3113b6d46e45d00c61d7ddd3d79ab4af579efe50
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: adb39aa9775bb90b9e542fc2f8f7badf672eefd1410b38b7dbccaa13c273e9d8d1c929e2d7e8942c56f924a27aac98d4425b5c31541080d324eec0d7f5dfd629
|
7
|
+
data.tar.gz: cdfa0c618e46776e828873028c1d5118d52d52b9c87d91d4c58373380a5b483515a475ea68ff868be9bd487133dcd5292e9630424f3e577f399aa74d7b5b3181
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/README.md
ADDED
@@ -0,0 +1,140 @@
|
|
1
|
+
# Bitbot v0.0.5
|
2
|
+
|
3
|
+
An IRC bit-tip style bot using blockchain.info as a payment route.
|
4
|
+
* 0.0.5 Update schema to reflect different bot name etc
|
5
|
+
|
6
|
+
## Security
|
7
|
+
|
8
|
+
**You probably don't want to use this.**
|
9
|
+
|
10
|
+
This section is first because anything Bitcoin related seems to attract
|
11
|
+
l33t hax0rs. This is just a toy. You probably shouldn't use it, and if
|
12
|
+
you do, you shouldn't put much money into it. Here's why:
|
13
|
+
|
14
|
+
Bitbot does not operate on nicknames, but usernames. Therefore, it's
|
15
|
+
only secure on IRC networks where usernames are forced. *This probably
|
16
|
+
isn't true of whatever IRC network you're on.* (On our IRC network,
|
17
|
+
usernames cannot be spoofed.) In order to be secure, the bot would need
|
18
|
+
to authenticate users in some other way, perhaps by using NickServ or
|
19
|
+
something. Pull requests accepted.
|
20
|
+
|
21
|
+
Bitbot uses an online wallet at https://blockchain.info. This was
|
22
|
+
because it was the easiest path forward, but it is not the most secure.
|
23
|
+
Blockchain.info itself seems reasonably secure, but if someone were to
|
24
|
+
breach its servers, they would be able to steal all the coins stored by
|
25
|
+
Bitbot. A better setup would be for Bitbot to perform its own
|
26
|
+
transactions on the Bitcoin network. Pull requests accepted. :)
|
27
|
+
|
28
|
+
Bitbot is based on a Ruby IRC library called
|
29
|
+
[Cinch](https://github.com/cinchrb/cinch). I have no idea how secure
|
30
|
+
Cinch is - it's possible that it has a remote code execution
|
31
|
+
vulnerability. If it does, an attacker can steal all the coins from
|
32
|
+
Bitbot.
|
33
|
+
|
34
|
+
## How Does It Work
|
35
|
+
|
36
|
+
Bitbot lets people in IRC send each other Bitcoin. It's loosely modelled
|
37
|
+
after the [Reddit Bitcointip](http://redd.it/13iykn).
|
38
|
+
|
39
|
+
The big difference is that in Bitbot, tips between users do not show up
|
40
|
+
in the blockchain. Bitbot maintains a wallet with all of the deposited
|
41
|
+
funds, and then keeps a record of transactions between users. Only
|
42
|
+
deposits and withdrawals to and from Bitbot show up in the Bitcoin
|
43
|
+
blockchain.
|
44
|
+
|
45
|
+
We do this because our tips are generally pretty tiny, and if each one
|
46
|
+
were a real transaction, our entire "Bitconomy" would be eaten up by
|
47
|
+
transaction fees.
|
48
|
+
|
49
|
+
## Installation
|
50
|
+
|
51
|
+
* Install the dependencies (sqlite3)
|
52
|
+
|
53
|
+
* Install the gem:
|
54
|
+
|
55
|
+
```bash
|
56
|
+
gem install bitbot
|
57
|
+
```
|
58
|
+
|
59
|
+
* Create an online wallet at https://blockchain.info/wallet/ . Create a
|
60
|
+
secondary password on it, and I suggest locking access to the IP from
|
61
|
+
which your bot will be running for an little extra security. It's
|
62
|
+
probably also good to set up (encrypted) wallet backups to go to your
|
63
|
+
email address.
|
64
|
+
|
65
|
+
* Create a data directory for Bitbot:
|
66
|
+
|
67
|
+
```bash
|
68
|
+
$ mkdir ~/.bitbot
|
69
|
+
```
|
70
|
+
|
71
|
+
* Create a bitbot.yml file that looks like this:
|
72
|
+
|
73
|
+
```yaml
|
74
|
+
irc:
|
75
|
+
server: irc.example.com
|
76
|
+
port: 8765
|
77
|
+
ssl: false
|
78
|
+
channels:
|
79
|
+
- "#crypt0chat"
|
80
|
+
- "#omgwtfbotting"
|
81
|
+
- "#CryptoGamble"
|
82
|
+
nick: TipJar
|
83
|
+
username: bitbot@example.com
|
84
|
+
password: blahblah
|
85
|
+
|
86
|
+
blockchain:
|
87
|
+
wallet_id: <long guid>
|
88
|
+
password1: <password>
|
89
|
+
password2: <secondary password>
|
90
|
+
withdrawal_fee: <fee in satoshi, default: 50000>
|
91
|
+
|
92
|
+
data:
|
93
|
+
path: /home/me/.bitbot
|
94
|
+
```
|
95
|
+
|
96
|
+
* Start the bot:
|
97
|
+
|
98
|
+
```bash
|
99
|
+
$ bitbot start <path to config.yml>
|
100
|
+
```
|
101
|
+
|
102
|
+
## Usage
|
103
|
+
|
104
|
+
### Help
|
105
|
+
|
106
|
+
To get help, `/msg bitbot help`. He will respond with a list of commands
|
107
|
+
he supports:
|
108
|
+
|
109
|
+
```
|
110
|
+
bitbot: Commands: deposit, balance, history, withdrawal
|
111
|
+
```
|
112
|
+
|
113
|
+
### Deposit
|
114
|
+
|
115
|
+
To make a deposit to your Bitbot account, ask bitbot for your depositing
|
116
|
+
address: `/msg bitbot deposit`. Bitbot will respond with a Bitcoin
|
117
|
+
address to send coins to. Once
|
118
|
+
|
119
|
+
### Tipping
|
120
|
+
|
121
|
+
To tip somebody, you must both be in a room with Bitbot. The syntax is
|
122
|
+
`+tip <nickname> <amount in BTC> <message>`. When Bitbot sees that, it
|
123
|
+
verifies that you have the funds to tip, does a `whois` on the recipient
|
124
|
+
nickname, and then transfers the funds. He then responds with a
|
125
|
+
confirmation:
|
126
|
+
|
127
|
+
```
|
128
|
+
bob: how do i make rails tests fast?
|
129
|
+
john: refactor your app so you can test it without rails
|
130
|
+
bob: +tip john 0.01 ur so smart
|
131
|
+
bitbot: [✔] Verified: bob ➜ ฿+0.01 [$1.12] ➜ john
|
132
|
+
```
|
133
|
+
|
134
|
+
### Withdrawing
|
135
|
+
|
136
|
+
When you want to withdraw funds to another Bitcoin address, just tell
|
137
|
+
Bitbot: `/msg bitbot withdraw <amount> <address>`.
|
138
|
+
|
139
|
+
Bitbot will verify that you have enough money, and send `<amount>` BTC -
|
140
|
+
0.0005 (to cover the transaction fee) to the specified `<address>`.
|
data/README_old.md
ADDED
@@ -0,0 +1,140 @@
|
|
1
|
+
# Bitbot
|
2
|
+
|
3
|
+
An IRC bit-tip style bot. Just for fun, don't use with lots of coins.
|
4
|
+
|
5
|
+
## Security
|
6
|
+
|
7
|
+
**You probably don't want to use this.**
|
8
|
+
|
9
|
+
This section is first because anything Bitcoin related seems to attract
|
10
|
+
l33t hax0rs. This is just a toy. You probably shouldn't use it, and if
|
11
|
+
you do, you shouldn't put much money into it. Here's why:
|
12
|
+
|
13
|
+
Bitbot does not operate on nicknames, but usernames. Therefore, it's
|
14
|
+
only secure on IRC networks where usernames are forced. *This probably
|
15
|
+
isn't true of whatever IRC network you're on.* (On our IRC network,
|
16
|
+
usernames cannot be spoofed.) In order to be secure, the bot would need
|
17
|
+
to authenticate users in some other way, perhaps by using NickServ or
|
18
|
+
something. Pull requests accepted.
|
19
|
+
|
20
|
+
Bitbot uses an online wallet at https://blockchain.info. This was
|
21
|
+
because it was the easiest path forward, but it is not the most secure.
|
22
|
+
Blockchain.info itself seems reasonably secure, but if someone were to
|
23
|
+
breach its servers, they would be able to steal all the coins stored by
|
24
|
+
Bitbot. A better setup would be for Bitbot to perform its own
|
25
|
+
transactions on the Bitcoin network. Pull requests accepted. :)
|
26
|
+
|
27
|
+
Bitbot is based on a Ruby IRC library called
|
28
|
+
[Cinch](https://github.com/cinchrb/cinch). I have no idea how secure
|
29
|
+
Cinch is - it's possible that it has a remote code execution
|
30
|
+
vulnerability. If it does, an attacker can steal all the coins from
|
31
|
+
Bitbot.
|
32
|
+
|
33
|
+
Hopefully the above has scared you off from installing this and using it
|
34
|
+
on Freenode. If it didn't, then you deserve to lose whatever you put in.
|
35
|
+
You could just send it to me directly instead:
|
36
|
+
`1zachsQ82fM7DC4HZQXMAAmkZ2Qg7pH2V`.
|
37
|
+
|
38
|
+
## How Does It Work
|
39
|
+
|
40
|
+
Bitbot lets people in IRC send each other Bitcoin. It's loosely modelled
|
41
|
+
after the [Reddit Bitcointip](http://redd.it/13iykn).
|
42
|
+
|
43
|
+
The big difference is that in Bitbot, tips between users do not show up
|
44
|
+
in the blockchain. Bitbot maintains a wallet with all of the deposited
|
45
|
+
funds, and then keeps a record of transactions between users. Only
|
46
|
+
deposits and withdrawals to and from Bitbot show up in the Bitcoin
|
47
|
+
blockchain.
|
48
|
+
|
49
|
+
We do this because our tips are generally pretty tiny, and if each one
|
50
|
+
were a real transaction, our entire "Bitconomy" would be eaten up by
|
51
|
+
transaction fees.
|
52
|
+
|
53
|
+
## Installation
|
54
|
+
|
55
|
+
* Install the dependencies (sqlite3)
|
56
|
+
|
57
|
+
* Install the gem:
|
58
|
+
|
59
|
+
```bash
|
60
|
+
gem install bitbot
|
61
|
+
```
|
62
|
+
|
63
|
+
* Create an online wallet at https://blockchain.info/wallet/ . Create a
|
64
|
+
secondary password on it, and I suggest locking access to the IP from
|
65
|
+
which your bot will be running for an little extra security. It's
|
66
|
+
probably also good to set up (encrypted) wallet backups to go to your
|
67
|
+
email address.
|
68
|
+
|
69
|
+
* Create a data directory for Bitbot:
|
70
|
+
|
71
|
+
```bash
|
72
|
+
$ mkdir ~/.bitbot
|
73
|
+
```
|
74
|
+
|
75
|
+
* Create a bitbot.yml file that looks like this:
|
76
|
+
|
77
|
+
```yaml
|
78
|
+
irc:
|
79
|
+
server: irc.example.com
|
80
|
+
port: 8765
|
81
|
+
ssl: true
|
82
|
+
nick: bitbot
|
83
|
+
username: bitbot@example.com
|
84
|
+
password: blahblah
|
85
|
+
|
86
|
+
blockchain:
|
87
|
+
wallet_id: <long guid>
|
88
|
+
password1: <password>
|
89
|
+
password2: <secondary password>
|
90
|
+
withdrawal_fee: <fee in satoshi, default: 50000>
|
91
|
+
|
92
|
+
data:
|
93
|
+
path: /home/me/.bitbot
|
94
|
+
```
|
95
|
+
|
96
|
+
* Start the bot:
|
97
|
+
|
98
|
+
```bash
|
99
|
+
$ bitbot start <path to config.yml>
|
100
|
+
```
|
101
|
+
|
102
|
+
## Usage
|
103
|
+
|
104
|
+
### Help
|
105
|
+
|
106
|
+
To get help, `/msg bitbot help`. He will respond with a list of commands
|
107
|
+
he supports:
|
108
|
+
|
109
|
+
```
|
110
|
+
bitbot: Commands: deposit, balance, history, withdrawal
|
111
|
+
```
|
112
|
+
|
113
|
+
### Deposit
|
114
|
+
|
115
|
+
To make a deposit to your Bitbot account, ask bitbot for your depositing
|
116
|
+
address: `/msg bitbot deposit`. Bitbot will respond with a Bitcoin
|
117
|
+
address to send coins to. Once
|
118
|
+
|
119
|
+
### Tipping
|
120
|
+
|
121
|
+
To tip somebody, you must both be in a room with Bitbot. The syntax is
|
122
|
+
`+tip <nickname> <amount in BTC> <message>`. When Bitbot sees that, it
|
123
|
+
verifies that you have the funds to tip, does a `whois` on the recipient
|
124
|
+
nickname, and then transfers the funds. He then responds with a
|
125
|
+
confirmation:
|
126
|
+
|
127
|
+
```
|
128
|
+
bob: how do i make rails tests fast?
|
129
|
+
john: refactor your app so you can test it without rails
|
130
|
+
bob: +tip john 0.01 ur so smart
|
131
|
+
bitbot: [✔] Verified: bob ➜ ฿+0.01 [$1.12] ➜ john
|
132
|
+
```
|
133
|
+
|
134
|
+
### Withdrawing
|
135
|
+
|
136
|
+
When you want to withdraw funds to another Bitcoin address, just tell
|
137
|
+
Bitbot: `/msg bitbot withdraw <amount> <address>`.
|
138
|
+
|
139
|
+
Bitbot will verify that you have enough money, and send `<amount>` BTC -
|
140
|
+
0.0005 (to cover the transaction fee) to the specified `<address>`.
|
data/Rakefile
ADDED
data/bin/bitbot
ADDED
@@ -0,0 +1,55 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'daemons'
|
4
|
+
require 'yaml'
|
5
|
+
|
6
|
+
require 'bitbot/plugin'
|
7
|
+
|
8
|
+
def usage
|
9
|
+
puts "Usage: #{File.basename($0)} {start|stop|run} <path to config.yml>"
|
10
|
+
exit 1
|
11
|
+
end
|
12
|
+
|
13
|
+
if ARGV.length < 2
|
14
|
+
usage()
|
15
|
+
end
|
16
|
+
|
17
|
+
config_file = File.expand_path(ARGV.pop)
|
18
|
+
|
19
|
+
unless File.exist?(config_file)
|
20
|
+
usage()
|
21
|
+
end
|
22
|
+
|
23
|
+
config = YAML::load(File.open(config_file))
|
24
|
+
unless File.exist?(File.dirname(config['data']['path']))
|
25
|
+
puts "Data directory does not exist: #{File.dirname(config['data']['path'])}"
|
26
|
+
exit 1
|
27
|
+
end
|
28
|
+
|
29
|
+
Daemons.run_proc(config['daemon_name'] || 'bitbot',
|
30
|
+
:hard_exit => true,
|
31
|
+
:backtrace => true,
|
32
|
+
:ontop => false,
|
33
|
+
:multiple => false,
|
34
|
+
:monitor => true,
|
35
|
+
:log_output => true) do
|
36
|
+
|
37
|
+
bot = Cinch::Bot.new do
|
38
|
+
configure do |c|
|
39
|
+
c.server = config['irc']['server']
|
40
|
+
c.port = config['irc']['port']
|
41
|
+
c.ssl.use = config['irc']['ssl']
|
42
|
+
c.channels = config['irc']['channels']
|
43
|
+
c.nick = config['irc']['nick'] || 'bitbot'
|
44
|
+
c.user = config['irc']['username'] || 'bitbot'
|
45
|
+
c.password = config['irc']['password']
|
46
|
+
c.verbose = config['irc']['verbose']
|
47
|
+
|
48
|
+
c.plugins.plugins = [Bitbot::Plugin]
|
49
|
+
c.plugins.options[Bitbot::Plugin] = config
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
bot.start
|
54
|
+
end
|
55
|
+
|
data/bitbot.gemspec
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
$:.push File.expand_path("../lib", __FILE__)
|
2
|
+
|
3
|
+
Gem::Specification.new do |s|
|
4
|
+
s.name = %q{bitbot}
|
5
|
+
s.version = "0.0.5"
|
6
|
+
s.platform = Gem::Platform::RUBY
|
7
|
+
s.authors = ["WeirdThall", "Zach Wily"]
|
8
|
+
s.email = ["weirdthall@gmail.com", "zach@zwily.com"]
|
9
|
+
s.homepage = %q{http://github.com/zwily/bitbot}
|
10
|
+
s.summary = %q{Bitcoin IRC Tip Bot}
|
11
|
+
s.description = ["A Bitcoin IRC Tip Bot on freenode"]
|
12
|
+
|
13
|
+
s.files = `git ls-files`.split("\n")
|
14
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
15
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
16
|
+
s.default_executable = %q{bitbot}
|
17
|
+
s.require_paths = ["lib"]
|
18
|
+
|
19
|
+
|
20
|
+
s.add_dependency "cinch"
|
21
|
+
s.add_dependency "daemons"
|
22
|
+
s.add_dependency "sqlite3"
|
23
|
+
s.add_dependency "httparty"
|
24
|
+
|
25
|
+
s.add_development_dependency "rspec", "~> 2.5"
|
26
|
+
s.add_development_dependency "yard"
|
27
|
+
end
|
28
|
+
|
@@ -0,0 +1,70 @@
|
|
1
|
+
require 'httparty'
|
2
|
+
require 'cgi'
|
3
|
+
require 'json'
|
4
|
+
|
5
|
+
module Bitbot
|
6
|
+
class Blockchain
|
7
|
+
def initialize(id, password1, password2)
|
8
|
+
@id = id
|
9
|
+
@password1 = password1
|
10
|
+
@password2 = password2
|
11
|
+
end
|
12
|
+
|
13
|
+
def request(api, action = nil, params = {})
|
14
|
+
path = if api == :merchant
|
15
|
+
"merchant/#{@id}/#{action}"
|
16
|
+
elsif api == :ticker
|
17
|
+
"ticker"
|
18
|
+
else
|
19
|
+
"#{api}/#{action}"
|
20
|
+
end
|
21
|
+
url = "https://blockchain.info/#{path}?"
|
22
|
+
params.each do |key, value|
|
23
|
+
url += "#{key}=#{CGI::escape value.to_s}&"
|
24
|
+
end
|
25
|
+
|
26
|
+
response = HTTParty.get(url)
|
27
|
+
raise "HTTP Error: #{response}" unless response.code == 200
|
28
|
+
|
29
|
+
JSON.parse(response.body)
|
30
|
+
end
|
31
|
+
|
32
|
+
def create_deposit_address_for_user_id(user_id)
|
33
|
+
self.request(:merchant, :new_address,
|
34
|
+
:password => @password1,
|
35
|
+
:second_password => @password2,
|
36
|
+
:label => user_id)
|
37
|
+
end
|
38
|
+
|
39
|
+
def get_details_for_address(address)
|
40
|
+
self.request(:address, address, :format => :json)
|
41
|
+
end
|
42
|
+
|
43
|
+
def get_addresses_in_wallet
|
44
|
+
response = self.request(:merchant, :list, :password => @password1)
|
45
|
+
response["addresses"]
|
46
|
+
end
|
47
|
+
|
48
|
+
def get_balance_for_address(address, confirmations = 1)
|
49
|
+
response = self.request(:merchant, :address_balance,
|
50
|
+
:password => @password1,
|
51
|
+
:address => address,
|
52
|
+
:confirmations => confirmations)
|
53
|
+
response["balance"]
|
54
|
+
end
|
55
|
+
|
56
|
+
def create_payment(address, amount, fee)
|
57
|
+
response = self.request(:merchant, :payment,
|
58
|
+
:password => @password1,
|
59
|
+
:second_password => @password2,
|
60
|
+
:to => address,
|
61
|
+
:amount => amount,
|
62
|
+
:fee => fee)
|
63
|
+
response
|
64
|
+
end
|
65
|
+
|
66
|
+
def get_exchange_rates
|
67
|
+
self.request(:ticker)
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|