Skip to content

Commit 141c82d

Browse files
committed
Allow users to set betch32 addresses
Closes #363
1 parent 52418d9 commit 141c82d

14 files changed

+3496
-7
lines changed

Gemfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ gem 'rails', '4.2.11.3'
77
gem 'acts_as_paranoid', github: 'ActsAsParanoid/acts_as_paranoid'
88
gem 'airbrake', '~> 3.1.15'
99
gem 'bcrypt', '~> 3.1.12'
10+
gem 'bech32', '~> 1.0.5'
1011
gem 'bootstrap_form', github: 'bootstrap-ruby/rails-bootstrap-forms'
1112
gem 'cancancan'
1213
gem 'coffee-rails', '~> 4.0.0'

Gemfile.lock

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ GEM
7777
backports (3.18.2)
7878
bcrypt (3.1.16)
7979
bcrypt_pbkdf (1.0.0)
80+
bech32 (1.0.5)
8081
builder (3.2.4)
8182
cancancan (1.7.1)
8283
capistrano (3.4.1)
@@ -403,6 +404,7 @@ DEPENDENCIES
403404
airbrake (~> 3.1.15)
404405
bcrypt (~> 3.1.12)
405406
bcrypt_pbkdf (~> 1.0.0)
407+
bech32 (~> 1.0.5)
406408
bootstrap_form!
407409
cancancan
408410
capistrano (~> 3.4.0)

config/config.yml.sample

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,5 @@ min_tip: 50000 # optional
4040

4141
deposit_address: 1M4bS4gPyA6Kb8w7aXsgth9oUZWcRk73tQ
4242

43-
address_versions: # 0/5 for bitcoin addresses, 111/196 for testnet, see chainparams.cpp
44-
- 0
45-
- 5
43+
# Can be testnet or mainnet
44+
network: mainnet

features/bitcoin_address.feature

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
Feature: Users should be able to change their bitcoin address
2+
Background:
3+
Given a developer named "seldon" exists without a bitcoin address
4+
And I'm signed in as "seldon"
5+
6+
@vcr-ignore-params
7+
Scenario: Users should be able to set P2PKH address
8+
Given I visit the "seldon user" page
9+
Then I should see "Bitcoin address"
10+
When I fill "Bitcoin address" with: "1BvBMSEYstWetqTFn5Au4m4GFg7xJaNVN2"
11+
And I click "Update user info"
12+
Then I should see "Your information saved!"
13+
14+
@vcr-ignore-params
15+
Scenario: Users should not be able to set invalid P2PKH address
16+
Given I visit the "seldon user" page
17+
Then I should see "Bitcoin address"
18+
When I fill "Bitcoin address" with: "1BvBMSEYstWetqTFn5Au4m4GFg7xJaNVA"
19+
And I click "Update user info"
20+
Then I should not see "Your information saved!"
21+
And I should see "Bitcoin address is invalid"
22+
23+
@vcr-ignore-params
24+
Scenario: Users should be able to set P2SH address
25+
Given I visit the "seldon user" page
26+
Then I should see "Bitcoin address"
27+
When I fill "Bitcoin address" with: "3J98t1WpEZ73CNmQviecrnyiWrnqRhWNLy"
28+
And I click "Update user info"
29+
Then I should see "Your information saved!"
30+
31+
@vcr-ignore-params
32+
Scenario: Users should not be able to set invalid P2SH address
33+
Given I visit the "seldon user" page
34+
Then I should see "Bitcoin address"
35+
When I fill "Bitcoin address" with: "3J98t1WpEZ73CNmQviecrnyiWrnqRhWNLA"
36+
And I click "Update user info"
37+
Then I should not see "Your information saved!"
38+
And I should see "Bitcoin address is invalid"
39+
40+
@vcr-ignore-params
41+
Scenario: Users should not be able to set testnet address
42+
Given I visit the "seldon user" page
43+
Then I should see "Bitcoin address"
44+
When I fill "Bitcoin address" with: "mtXWDB6k5yC5v7TcwKZHB89SUp85yCKshy"
45+
And I click "Update user info"
46+
Then I should not see "Your information saved!"
47+
And I should see "Bitcoin address is invalid"
48+
49+
@vcr-ignore-params
50+
Scenario: Users should be able to set Bech32 P2WPKH address
51+
Given I visit the "seldon user" page
52+
Then I should see "Bitcoin address"
53+
When I fill "Bitcoin address" with: "bc1qw508d6qejxtdg4y5r3zarvary0c5xw7kv8f3t4"
54+
And I click "Update user info"
55+
Then I should see "Your information saved!"
56+
57+
@vcr-ignore-params
58+
Scenario: Users should be able to set Bech32 P2WSH address
59+
Given I visit the "seldon user" page
60+
Then I should see "Bitcoin address"
61+
When I fill "Bitcoin address" with: "bc1qrp33g0q5c5txsp9arysrx4k6zdkfs4nce4xj0gdcccefvpysxf3qccfmv3"
62+
And I click "Update user info"
63+
Then I should see "Your information saved!"
64+
65+
@vcr-ignore-params
66+
Scenario: Users should not be able to set testnet Bech32 address
67+
Given I visit the "seldon user" page
68+
Then I should see "Bitcoin address"
69+
When I fill "Bitcoin address" with: "tb1qw508d6qejxtdg4y5r3zarvary0c5xw7kxpjzsx"
70+
And I click "Update user info"
71+
Then I should not see "Your information saved!"
72+
And I should see "Bitcoin address is invalid"

0 commit comments

Comments
 (0)