├── .gitignore
├── Capfile
├── Gemfile
├── Gemfile.lock
├── LICENSE
├── README.md
├── Rakefile
├── app
├── assets
│ ├── images
│ │ ├── add.gif
│ │ ├── bitcoin.png
│ │ ├── currencies
│ │ │ ├── btc_icon.png
│ │ │ ├── btc_logo.png
│ │ │ ├── cad_icon.png
│ │ │ ├── cad_logo.png
│ │ │ ├── eur_icon.png
│ │ │ ├── eur_logo.png
│ │ │ ├── inr_icon.png
│ │ │ ├── inr_logo.png
│ │ │ ├── lreur_icon.png
│ │ │ ├── lreur_logo.png
│ │ │ ├── lrusd_icon.png
│ │ │ ├── lrusd_logo.png
│ │ │ ├── pgau_icon.png
│ │ │ ├── pgau_logo.png
│ │ │ ├── usd_icon.png
│ │ │ └── usd_logo.png
│ │ ├── dark-pool.png
│ │ ├── delete.png
│ │ ├── details.png
│ │ ├── fancybox
│ │ │ ├── blank.gif
│ │ │ ├── fancy_close.png
│ │ │ ├── fancy_loading.png
│ │ │ ├── fancy_nav_left.png
│ │ │ ├── fancy_nav_right.png
│ │ │ ├── fancy_shadow_e.png
│ │ │ ├── fancy_shadow_n.png
│ │ │ ├── fancy_shadow_ne.png
│ │ │ ├── fancy_shadow_nw.png
│ │ │ ├── fancy_shadow_s.png
│ │ │ ├── fancy_shadow_se.png
│ │ │ ├── fancy_shadow_sw.png
│ │ │ ├── fancy_shadow_w.png
│ │ │ ├── fancy_title_left.png
│ │ │ ├── fancy_title_main.png
│ │ │ ├── fancy_title_over.png
│ │ │ ├── fancy_title_right.png
│ │ │ ├── fancybox-x.png
│ │ │ ├── fancybox-y.png
│ │ │ └── fancybox.png
│ │ ├── flags
│ │ │ ├── all.jpg
│ │ │ ├── de.png
│ │ │ ├── en.png
│ │ │ ├── fr.png
│ │ │ └── it.png
│ │ ├── icons
│ │ │ ├── favicon114-precomposed.png
│ │ │ ├── favicon32.png
│ │ │ ├── favicon57-precomposed.png
│ │ │ └── favicon72-precomposed.png
│ │ ├── info.png
│ │ ├── os
│ │ │ ├── apple.png
│ │ │ ├── github.png
│ │ │ ├── linux.png
│ │ │ ├── ubuntu_ppa.png
│ │ │ └── windows.png
│ │ ├── paid.png
│ │ ├── pending.png
│ │ ├── play.png
│ │ ├── processed.png
│ │ ├── processing.png
│ │ ├── qrcode.png
│ │ ├── square.png
│ │ └── yubico-icon.png
│ ├── javascripts
│ │ ├── application.js
│ │ ├── excanvas.js
│ │ ├── jqplot.dateAxisRenderer.js
│ │ ├── jqplot.highlighter.js
│ │ ├── jqplot.js
│ │ ├── jquery-ui.js
│ │ ├── jquery.countdown.js
│ │ └── jquery.fancybox.js
│ └── stylesheets
│ │ ├── .gitkeep
│ │ ├── application.css.scss
│ │ ├── jqplot.css
│ │ ├── jquery.fancybox.css.scss
│ │ ├── main.css.scss
│ │ └── reset.css.scss
├── controllers
│ ├── accounts_controller.rb
│ ├── admin
│ │ ├── account_operations_controller.rb
│ │ ├── admin_controller.rb
│ │ ├── announcements_controller.rb
│ │ ├── currencies_controller.rb
│ │ ├── informations_controller.rb
│ │ ├── pending_transfers_controller.rb
│ │ ├── static_pages_controller.rb
│ │ ├── tickets_controller.rb
│ │ ├── users_controller.rb
│ │ └── yubikeys_controller.rb
│ ├── application_controller.rb
│ ├── bank_accounts_controller.rb
│ ├── comments_controller.rb
│ ├── informations_controller.rb
│ ├── invoices_controller.rb
│ ├── qrcodes_controller.rb
│ ├── registrations_controller.rb
│ ├── static_pages_controller.rb
│ ├── third_party_callbacks_controller.rb
│ ├── tickets_controller.rb
│ ├── trade_orders_controller.rb
│ ├── trades_controller.rb
│ ├── transfers_controller.rb
│ ├── users_controller.rb
│ └── yubikeys_controller.rb
├── helpers
│ ├── accounts_helper.rb
│ ├── admin
│ │ ├── account_operations_helpers.rb
│ │ ├── announcements_helper.rb
│ │ ├── currencies_helper.rb
│ │ ├── informations_helper.rb
│ │ ├── pending_transfers_helper.rb
│ │ ├── static_pages_helper.rb
│ │ ├── tickets_helper.rb
│ │ ├── users_helper.rb
│ │ └── yubikeys_helper.rb
│ ├── application_helper.rb
│ ├── bank_accounts_helper.rb
│ ├── comments_helper.rb
│ ├── informations_helper.rb
│ ├── invoices_helper.rb
│ ├── qrcodes_helper.rb
│ ├── registrations_helper.rb
│ ├── static_pages_helper.rb
│ ├── tickets_helper.rb
│ ├── trade_orders_helper.rb
│ ├── trades_helper.rb
│ ├── transfers_helper.rb
│ ├── users_helper.rb
│ └── yubikeys_helper.rb
├── mailers
│ ├── backup_mailer.rb
│ ├── ticket_mailer.rb
│ └── user_mailer.rb
├── models
│ ├── account.rb
│ ├── account_operation.rb
│ ├── admin.rb
│ ├── announcement.rb
│ ├── bank_account.rb
│ ├── bitcoin_transfer.rb
│ ├── comment.rb
│ ├── currency.rb
│ ├── invoice.rb
│ ├── liberty_reserve_transfer.rb
│ ├── limit_order.rb
│ ├── manager.rb
│ ├── market_order.rb
│ ├── operation.rb
│ ├── static_page.rb
│ ├── ticket.rb
│ ├── trade.rb
│ ├── trade_order.rb
│ ├── transfer.rb
│ ├── used_currency.rb
│ ├── user.rb
│ ├── wire_transfer.rb
│ └── yubikey.rb
└── views
│ ├── accounts
│ ├── _balance_row.html.haml
│ ├── _lr_sci_form.html.erb
│ ├── _px_sci_form.html.erb
│ ├── deposit.html.haml
│ ├── pecunix_deposit_form.js.erb
│ └── show.html.haml
│ ├── admin
│ ├── account_operations
│ │ └── _currency_form_column.html.erb
│ ├── informations
│ │ └── balances.html.haml
│ ├── pending_transfers
│ │ └── process_tx.js.erb
│ └── users
│ │ └── balances.html.haml
│ ├── backup_mailer
│ └── wallet_backup.text.erb
│ ├── bank_accounts
│ ├── _fields.html.haml
│ ├── _list.html.haml
│ └── index.html.haml
│ ├── devise
│ ├── confirmations
│ │ └── new.html.erb
│ ├── mailer
│ │ ├── confirmation_instructions.html.erb
│ │ ├── reset_password_instructions.html.erb
│ │ └── unlock_instructions.html.erb
│ ├── passwords
│ │ ├── edit.html.erb
│ │ └── new.html.erb
│ ├── sessions
│ │ └── new.html.haml
│ ├── shared
│ │ └── _links.html.erb
│ └── unlocks
│ │ └── new.html.haml
│ ├── informations
│ ├── _what_is_bitcoin.de.html.erb
│ ├── _what_is_bitcoin.en.html.erb
│ ├── _what_is_bitcoin.fr.html.erb
│ ├── economy.html.erb
│ ├── faq.html.erb
│ ├── support.html.haml
│ └── welcome.html.haml
│ ├── invoices
│ ├── index.html.haml
│ ├── new.html.haml
│ └── show.html.haml
│ ├── layouts
│ ├── _announcements.html.haml
│ ├── _errors.html.erb
│ ├── _flash.html.erb
│ ├── _footer.html.haml
│ ├── _google_analytics.html.erb
│ ├── _icons.html.haml
│ ├── _locale_select.html.erb
│ ├── _navigation.html.haml
│ ├── _no_data.html.haml
│ ├── _open_graph.html
│ ├── _user_informations.html.haml
│ ├── application.html.haml
│ ├── mailers.html.haml
│ └── static.html.haml
│ ├── registrations
│ ├── edit.html.erb
│ └── new.html.erb
│ ├── static
│ ├── 404.html.haml
│ ├── 500.html.haml
│ └── maintenance.html.haml
│ ├── static_pages
│ └── show.html.haml
│ ├── ticket_mailer
│ ├── ticket_notification.html.erb
│ └── ticket_notification.text.erb
│ ├── tickets
│ ├── _ticket.html.haml
│ ├── index.html.haml
│ ├── new.html.haml
│ └── show.html.haml
│ ├── trade_orders
│ ├── _detailed_list.html.haml
│ ├── _list.html.haml
│ ├── book.html.haml
│ ├── book.xml.builder
│ ├── index.html.haml
│ └── new.html.haml
│ ├── trades
│ ├── all_trades.json.erb
│ ├── all_trades.xml.builder
│ ├── index.html.haml
│ ├── ticker.json.erb
│ └── ticker.xml.builder
│ ├── transfers
│ ├── index.html.haml
│ ├── index.xml.builder
│ ├── new.html.haml
│ └── show.html.haml
│ ├── user_mailer
│ ├── invoice_payment_notification.html.haml
│ ├── invoice_payment_notification.text.haml
│ ├── registration_confirmation.html.erb
│ ├── registration_confirmation.text.erb
│ ├── trade_notification.html.haml
│ ├── trade_notification.text.erb
│ ├── withdrawal_processed_notification.html.haml
│ └── withdrawal_processed_notification.text.haml
│ ├── users
│ ├── _form.html.haml
│ ├── _password_change_form.html.haml
│ ├── edit.html.haml
│ ├── edit_password.html.haml
│ ├── ga_otp_configuration.en.html.haml
│ ├── ga_otp_configuration.fr.html.haml
│ └── new.html.haml
│ └── yubikeys
│ └── index.html.haml
├── config.ru
├── config
├── application.rb
├── backup.yml
├── banks.yml
├── bitcoin.yml
├── boot.rb
├── database.yml
├── deploy.rb
├── environment.rb
├── environments
│ ├── development.rb
│ ├── production.rb
│ └── test.rb
├── google_analytics.yml
├── initializers
│ ├── action_mailer.rb
│ ├── active_scaffold.rb
│ ├── backtrace_silencers.rb
│ ├── big_decimal.rb
│ ├── devise.rb
│ ├── donations.rb
│ ├── inflections.rb
│ ├── json_serialization.rb
│ ├── liberty_reserve.rb
│ ├── mime_types.rb
│ ├── monkey_patches.rb
│ ├── paranoia.rb
│ ├── recaptcha_keys.rb
│ ├── secret_token.rb
│ ├── session_store.rb
│ ├── transaction.rb
│ └── will_paginate.rb
├── liberty_reserve.yml
├── locales
│ ├── en
│ │ ├── currencies.yml
│ │ ├── defaults.yml
│ │ ├── devise.yml
│ │ ├── emails.yml
│ │ ├── models.yml
│ │ ├── other.yml
│ │ └── views.yml
│ └── fr
│ │ ├── currencies.yml
│ │ ├── defaults.yml
│ │ ├── devise.yml
│ │ ├── emails.yml
│ │ ├── models.yml
│ │ ├── other.yml
│ │ └── views.yml
├── pecunix.yml
├── recaptcha.yml
├── routes.rb
├── schedule.rb
└── yubico.yml
├── db
├── migrate
│ ├── 20101017190414_add_sessions_table.rb
│ ├── 20101017194104_create_users.rb
│ ├── 20101017230001_create_transfers.rb
│ ├── 20101022090523_add_last_address_column.rb
│ ├── 20101123114028_add_currency_to_transfers.rb
│ ├── 20101124101527_add_lr_metadata.rb
│ ├── 20101125091027_add_salt_to_users.rb
│ ├── 20101125140724_add_btc_meta_data.rb
│ ├── 20101130120618_create_trade_orders.rb
│ ├── 20101220214804_add_lr_fields.rb
│ ├── 20101222002654_add_time_zone_to_users.rb
│ ├── 20101222014309_create_trades.rb
│ ├── 20101222020005_add_payee_id_to_transfers.rb
│ ├── 20101223013915_add_cancelled_at_to_trade_orders.rb
│ ├── 20101229231455_add_active_to_trade_order.rb
│ ├── 20101229232404_add_ids_to_trades.rb
│ ├── 20101230150344_remove_status_from_trade_orders.rb
│ ├── 20110101105004_drop_cancelled_at_column.rb
│ ├── 20110107095311_add_dark_pool_attributes.rb
│ ├── 20110120142138_add_admin_flag.rb
│ ├── 20110121112916_add_secret_token_to_users.rb
│ ├── 20110123220843_add_email_to_transfers.rb
│ ├── 20110126134715_remove_cash_transfer.rb
│ ├── 20110201144233_add_pecunix_fields.rb
│ ├── 20110201210946_add_px_fee.rb
│ ├── 20110506082222_devise_create_users.rb
│ ├── 20110511194431_add_lr_tx_id_index.rb
│ ├── 20110517105159_create_invoices.rb
│ ├── 20110518094622_add_merchant_flag_to_users.rb
│ ├── 20110518211846_add_invoice_reference.rb
│ ├── 20110519121047_add_comment_and_merchant_ref_to_invoice.rb
│ ├── 20110521122924_add_auth_token_to_invoices.rb
│ ├── 20110521125911_add_item_url_to_invoices.rb
│ ├── 20110625123015_add_otp_fields.rb
│ ├── 20110630161800_create_announcements.rb
│ ├── 20110701083833_add_comment_to_transfers.rb
│ ├── 20110702184056_bitcoin_addresses_refactoring.rb
│ ├── 20110707141245_create_yubikeys.rb
│ ├── 20110709144427_add_yubikey_flag_to_users.rb
│ ├── 20110713164217_create_operations.rb
│ ├── 20110713165908_create_account_operations.rb
│ ├── 20110713191630_create_accounts.rb
│ ├── 20110719172103_add_bank_info_to_transfers.rb
│ ├── 20110726190751_add_state_to_account_operations.rb
│ ├── 20110728104040_create_static_pages.rb
│ ├── 20110729211831_create_bank_accounts.rb
│ ├── 20110729211904_add_bank_account_id_to_transfers.rb
│ ├── 20110806153411_create_tickets.rb
│ ├── 20110820164434_create_currencies.rb
│ ├── 20110821125702_create_used_currencies.rb
│ ├── 20110821132029_drop_admin_flag.rb
│ ├── 20110911205535_create_comments.rb
│ ├── 20110914082906_add_user_personal_data_columns.rb
│ ├── 20110914093520_add_trade_notification_option_to_users.rb
│ ├── 20110914131115_add_last_notified_to_users.rb
│ ├── 20111117115222_modify_ppc_default_value.rb
│ ├── 20111122160759_add_type_to_trade_orders.rb
│ ├── 20111129123247_add_max_read_id_to_users.rb
│ └── 20111205110307_add_commission_rate_to_users.rb
├── schema.rb
└── seeds.rb
├── doc
└── README_FOR_APP
├── lib
├── bitcoin
│ ├── client.rb
│ ├── json_wrapper.rb
│ └── util.rb
├── devise
│ ├── models
│ │ ├── ga_otp_authenticatable.rb
│ │ └── yk_otp_authenticatable.rb
│ └── strategies
│ │ ├── ga_otp_authenticatable.rb
│ │ └── yk_otp_authenticatable.rb
├── liberty_reserve
│ └── client.rb
├── lockfile.rb
├── tasks
│ ├── .gitkeep
│ ├── bitcoin.rake
│ ├── deployment.rake
│ ├── liberty_reserve.rake
│ └── notifications.rake
├── validators
│ ├── bitcoin_address_validator.rb
│ ├── blank_validator.rb
│ ├── iban_validator.rb
│ ├── maximal_amount_validator.rb
│ ├── minimal_amount_validator.rb
│ ├── minimal_order_amount_validator.rb
│ ├── minimal_order_ppc_validator.rb
│ ├── negative_validator.rb
│ ├── not_mine_validator.rb
│ ├── url_validator.rb
│ └── user_balance_validator.rb
└── yubico
│ ├── client.rb
│ └── replayed_otp_error.rb
├── public
├── 404.html
├── 422.html
├── 500.html
├── maintenance.html
└── robots.txt
├── script
└── rails
└── test
├── factories.rb
├── functional
├── accounts_controller_test.rb
├── admin
│ ├── account_operations_controller_test.rb
│ ├── announcements_controller_test.rb
│ ├── currencies_controller_test.rb
│ ├── informations_controller_test.rb
│ ├── pending_transfers_controller_test.rb
│ ├── static_pages_controller_test.rb
│ ├── tickets_controller_test.rb
│ ├── users_controller_test.rb
│ └── yubikeys_controller_test.rb
├── backup_mailer_test.rb
├── bank_accounts_controller_test.rb
├── comments_controller_test.rb
├── informations_controller_test.rb
├── invoices_controller_test.rb
├── qrcodes_controller_test.rb
├── registrations_controller_test.rb
├── static_pages_controller_test.rb
├── third_party_callbacks_controller_test.rb
├── tickets_controller_test.rb
├── trade_orders_controller_test.rb
├── trades_controller_test.rb
├── transfers_controller_test.rb
├── user_mailer_test.rb
├── users_controller_test.rb
└── yubikeys_controller_test.rb
├── integration
├── google_authenticator_test.rb
├── http_basic_auth_test.rb
├── liberty_reserve_sci_test.rb
├── redirection_after_login_test.rb
└── yubikey_auth_test.rb
├── performance
└── browsing_test.rb
├── test_helper.rb
└── unit
├── account_operation_test.rb
├── account_test.rb
├── admin_test.rb
├── announcement_test.rb
├── bank_account_test.rb
├── bitcoin_address_validator_test.rb
├── bitcoin_transfer_test.rb
├── comment_test.rb
├── currency_test.rb
├── helpers
├── accounts_helper_test.rb
├── admin
│ ├── account_operations_helper_test.rb
│ ├── announcements_helper_test.rb
│ ├── currencies_helper_test.rb
│ ├── informations_helper_test.rb
│ ├── pending_transfers_helper_test.rb
│ ├── static_pages_helper_test.rb
│ ├── tickets_helper_test.rb
│ ├── users_helper_test.rb
│ └── yubikeys_helper_test.rb
├── application_helper_test.rb
├── bank_accounts_helper_test.rb
├── bitcoin_transfers_helper_test.rb
├── bitcoin_withdrawals_helper_test.rb
├── charts_helper_test.rb
├── comments_helper_test.rb
├── informations_helper_test.rb
├── invoices_helper_test.rb
├── liberty_reserve_transfer_helper_test.rb
├── liberty_reserve_withdrawals_helper_test.rb
├── qrcodes_helper_test.rb
├── registrations_helper_test.rb
├── static_pages_helper_test.rb
├── tickets_helper_test.rb
├── trade_orders_helper_test.rb
├── trades_helper_test.rb
├── transfers_helper_test.rb
├── users_helper_test.rb
└── yubikeys_helper_test.rb
├── invoice_test.rb
├── liberty_reserve_transfer_test.rb
├── manager_test.rb
├── monkey_patches_test.rb
├── operation_test.rb
├── rails_test.rb
├── static_page_test.rb
├── ticket_test.rb
├── trade_order_test.rb
├── trade_test.rb
├── transfer_test.rb
├── url_validator_test.rb
├── used_currency_test.rb
├── user_test.rb
├── wire_transfer_test.rb
└── yubikey_test.rb
/.gitignore:
--------------------------------------------------------------------------------
1 | .bundle
2 | db/*.sqlite3
3 | log/*.log
4 | tmp/**/*
5 | nbproject
6 | nbproject/*
7 | nbproject/**/*
8 | Thumbs.db
9 | **/Thumbs.db
10 | public/**/active_scaffold
11 | public/blank.html
12 | .idea/
13 | /.sass-cache/
--------------------------------------------------------------------------------
/Capfile:
--------------------------------------------------------------------------------
1 | load 'deploy' if respond_to?(:namespace) # cap2 differentiator
2 |
3 | # Uncomment if you are using Rails' asset pipelineload 'deploy/assets'
4 |
5 | Dir['vendor/gems/*/recipes/*.rb','vendor/plugins/*/recipes/*.rb'].each { |plugin| load(plugin) }
6 |
7 | load 'config/deploy' # remove this line to skip loading any of the default tasks
--------------------------------------------------------------------------------
/Gemfile:
--------------------------------------------------------------------------------
1 | source 'http://rubygems.org'
2 |
3 | gem 'rails', '3.1.3'
4 | gem 'rake'
5 | gem 'mysql2'
6 | gem 'addressable'
7 | gem 'devise'
8 | gem 'whenever'
9 | gem 'capistrano'
10 | gem 'active_scaffold'
11 | gem 'haml'
12 | gem 'jquery-rails'
13 | gem 'sass-rails'
14 | gem 'coffee-rails'
15 |
16 | gem 'recaptcha',
17 | :require => 'recaptcha/rails'
18 |
19 | gem 'exception_notification',
20 | :git => "git@github.com:rails/exception_notification.git",
21 | :require => 'exception_notifier'
22 |
23 | gem 'transitions',
24 | :require => ["transitions", "active_record/transitions"]
25 |
26 | gem 'will_paginate', '~> 3.0.pre2'
27 |
28 | # OTP toolbox
29 | gem 'rotp', '~> 1.3.0'
30 |
31 | # QR Code generation
32 | gem 'qrencoder'
33 |
34 | # IBAN format validations
35 | gem 'iban-tools'
36 |
37 | gem 'delayed_job'
38 |
39 | # CSS toolbox
40 | gem 'blueprint-rails'
41 | gem 'bourbon'
42 |
43 | # File attachment with database storage support
44 | gem 'paperclip',
45 | :git => 'https://github.com/patshaughnessy/paperclip.git'
46 |
47 | # Apple push notifications
48 | gem 'apn_on_rails',
49 | :git => 'https://github.com/natescherer/apn_on_rails.git',
50 | :branch => 'rails3'
51 |
52 | group :test do
53 | gem 'mocha', :require => false
54 | gem 'factory_girl_rails'
55 | end
56 |
57 | group :assets do
58 | gem 'uglifier'
59 | gem 'execjs'
60 | gem 'therubyracer'
61 | end
62 |
--------------------------------------------------------------------------------
/Rakefile:
--------------------------------------------------------------------------------
1 | # Add your own tasks in files placed in lib/tasks ending in .rake,
2 | # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
3 |
4 | require File.expand_path('../config/application', __FILE__)
5 | require 'rake'
6 |
7 | BitcoinBank::Application.load_tasks
8 |
--------------------------------------------------------------------------------
/app/assets/images/add.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/davout/bitcoin-central/25f056bf8589df213013b012e3d4e5d3e7cf919f/app/assets/images/add.gif
--------------------------------------------------------------------------------
/app/assets/images/bitcoin.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/davout/bitcoin-central/25f056bf8589df213013b012e3d4e5d3e7cf919f/app/assets/images/bitcoin.png
--------------------------------------------------------------------------------
/app/assets/images/currencies/btc_icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/davout/bitcoin-central/25f056bf8589df213013b012e3d4e5d3e7cf919f/app/assets/images/currencies/btc_icon.png
--------------------------------------------------------------------------------
/app/assets/images/currencies/btc_logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/davout/bitcoin-central/25f056bf8589df213013b012e3d4e5d3e7cf919f/app/assets/images/currencies/btc_logo.png
--------------------------------------------------------------------------------
/app/assets/images/currencies/cad_icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/davout/bitcoin-central/25f056bf8589df213013b012e3d4e5d3e7cf919f/app/assets/images/currencies/cad_icon.png
--------------------------------------------------------------------------------
/app/assets/images/currencies/cad_logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/davout/bitcoin-central/25f056bf8589df213013b012e3d4e5d3e7cf919f/app/assets/images/currencies/cad_logo.png
--------------------------------------------------------------------------------
/app/assets/images/currencies/eur_icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/davout/bitcoin-central/25f056bf8589df213013b012e3d4e5d3e7cf919f/app/assets/images/currencies/eur_icon.png
--------------------------------------------------------------------------------
/app/assets/images/currencies/eur_logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/davout/bitcoin-central/25f056bf8589df213013b012e3d4e5d3e7cf919f/app/assets/images/currencies/eur_logo.png
--------------------------------------------------------------------------------
/app/assets/images/currencies/inr_icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/davout/bitcoin-central/25f056bf8589df213013b012e3d4e5d3e7cf919f/app/assets/images/currencies/inr_icon.png
--------------------------------------------------------------------------------
/app/assets/images/currencies/inr_logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/davout/bitcoin-central/25f056bf8589df213013b012e3d4e5d3e7cf919f/app/assets/images/currencies/inr_logo.png
--------------------------------------------------------------------------------
/app/assets/images/currencies/lreur_icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/davout/bitcoin-central/25f056bf8589df213013b012e3d4e5d3e7cf919f/app/assets/images/currencies/lreur_icon.png
--------------------------------------------------------------------------------
/app/assets/images/currencies/lreur_logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/davout/bitcoin-central/25f056bf8589df213013b012e3d4e5d3e7cf919f/app/assets/images/currencies/lreur_logo.png
--------------------------------------------------------------------------------
/app/assets/images/currencies/lrusd_icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/davout/bitcoin-central/25f056bf8589df213013b012e3d4e5d3e7cf919f/app/assets/images/currencies/lrusd_icon.png
--------------------------------------------------------------------------------
/app/assets/images/currencies/lrusd_logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/davout/bitcoin-central/25f056bf8589df213013b012e3d4e5d3e7cf919f/app/assets/images/currencies/lrusd_logo.png
--------------------------------------------------------------------------------
/app/assets/images/currencies/pgau_icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/davout/bitcoin-central/25f056bf8589df213013b012e3d4e5d3e7cf919f/app/assets/images/currencies/pgau_icon.png
--------------------------------------------------------------------------------
/app/assets/images/currencies/pgau_logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/davout/bitcoin-central/25f056bf8589df213013b012e3d4e5d3e7cf919f/app/assets/images/currencies/pgau_logo.png
--------------------------------------------------------------------------------
/app/assets/images/currencies/usd_icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/davout/bitcoin-central/25f056bf8589df213013b012e3d4e5d3e7cf919f/app/assets/images/currencies/usd_icon.png
--------------------------------------------------------------------------------
/app/assets/images/currencies/usd_logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/davout/bitcoin-central/25f056bf8589df213013b012e3d4e5d3e7cf919f/app/assets/images/currencies/usd_logo.png
--------------------------------------------------------------------------------
/app/assets/images/dark-pool.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/davout/bitcoin-central/25f056bf8589df213013b012e3d4e5d3e7cf919f/app/assets/images/dark-pool.png
--------------------------------------------------------------------------------
/app/assets/images/delete.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/davout/bitcoin-central/25f056bf8589df213013b012e3d4e5d3e7cf919f/app/assets/images/delete.png
--------------------------------------------------------------------------------
/app/assets/images/details.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/davout/bitcoin-central/25f056bf8589df213013b012e3d4e5d3e7cf919f/app/assets/images/details.png
--------------------------------------------------------------------------------
/app/assets/images/fancybox/blank.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/davout/bitcoin-central/25f056bf8589df213013b012e3d4e5d3e7cf919f/app/assets/images/fancybox/blank.gif
--------------------------------------------------------------------------------
/app/assets/images/fancybox/fancy_close.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/davout/bitcoin-central/25f056bf8589df213013b012e3d4e5d3e7cf919f/app/assets/images/fancybox/fancy_close.png
--------------------------------------------------------------------------------
/app/assets/images/fancybox/fancy_loading.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/davout/bitcoin-central/25f056bf8589df213013b012e3d4e5d3e7cf919f/app/assets/images/fancybox/fancy_loading.png
--------------------------------------------------------------------------------
/app/assets/images/fancybox/fancy_nav_left.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/davout/bitcoin-central/25f056bf8589df213013b012e3d4e5d3e7cf919f/app/assets/images/fancybox/fancy_nav_left.png
--------------------------------------------------------------------------------
/app/assets/images/fancybox/fancy_nav_right.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/davout/bitcoin-central/25f056bf8589df213013b012e3d4e5d3e7cf919f/app/assets/images/fancybox/fancy_nav_right.png
--------------------------------------------------------------------------------
/app/assets/images/fancybox/fancy_shadow_e.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/davout/bitcoin-central/25f056bf8589df213013b012e3d4e5d3e7cf919f/app/assets/images/fancybox/fancy_shadow_e.png
--------------------------------------------------------------------------------
/app/assets/images/fancybox/fancy_shadow_n.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/davout/bitcoin-central/25f056bf8589df213013b012e3d4e5d3e7cf919f/app/assets/images/fancybox/fancy_shadow_n.png
--------------------------------------------------------------------------------
/app/assets/images/fancybox/fancy_shadow_ne.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/davout/bitcoin-central/25f056bf8589df213013b012e3d4e5d3e7cf919f/app/assets/images/fancybox/fancy_shadow_ne.png
--------------------------------------------------------------------------------
/app/assets/images/fancybox/fancy_shadow_nw.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/davout/bitcoin-central/25f056bf8589df213013b012e3d4e5d3e7cf919f/app/assets/images/fancybox/fancy_shadow_nw.png
--------------------------------------------------------------------------------
/app/assets/images/fancybox/fancy_shadow_s.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/davout/bitcoin-central/25f056bf8589df213013b012e3d4e5d3e7cf919f/app/assets/images/fancybox/fancy_shadow_s.png
--------------------------------------------------------------------------------
/app/assets/images/fancybox/fancy_shadow_se.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/davout/bitcoin-central/25f056bf8589df213013b012e3d4e5d3e7cf919f/app/assets/images/fancybox/fancy_shadow_se.png
--------------------------------------------------------------------------------
/app/assets/images/fancybox/fancy_shadow_sw.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/davout/bitcoin-central/25f056bf8589df213013b012e3d4e5d3e7cf919f/app/assets/images/fancybox/fancy_shadow_sw.png
--------------------------------------------------------------------------------
/app/assets/images/fancybox/fancy_shadow_w.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/davout/bitcoin-central/25f056bf8589df213013b012e3d4e5d3e7cf919f/app/assets/images/fancybox/fancy_shadow_w.png
--------------------------------------------------------------------------------
/app/assets/images/fancybox/fancy_title_left.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/davout/bitcoin-central/25f056bf8589df213013b012e3d4e5d3e7cf919f/app/assets/images/fancybox/fancy_title_left.png
--------------------------------------------------------------------------------
/app/assets/images/fancybox/fancy_title_main.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/davout/bitcoin-central/25f056bf8589df213013b012e3d4e5d3e7cf919f/app/assets/images/fancybox/fancy_title_main.png
--------------------------------------------------------------------------------
/app/assets/images/fancybox/fancy_title_over.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/davout/bitcoin-central/25f056bf8589df213013b012e3d4e5d3e7cf919f/app/assets/images/fancybox/fancy_title_over.png
--------------------------------------------------------------------------------
/app/assets/images/fancybox/fancy_title_right.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/davout/bitcoin-central/25f056bf8589df213013b012e3d4e5d3e7cf919f/app/assets/images/fancybox/fancy_title_right.png
--------------------------------------------------------------------------------
/app/assets/images/fancybox/fancybox-x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/davout/bitcoin-central/25f056bf8589df213013b012e3d4e5d3e7cf919f/app/assets/images/fancybox/fancybox-x.png
--------------------------------------------------------------------------------
/app/assets/images/fancybox/fancybox-y.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/davout/bitcoin-central/25f056bf8589df213013b012e3d4e5d3e7cf919f/app/assets/images/fancybox/fancybox-y.png
--------------------------------------------------------------------------------
/app/assets/images/fancybox/fancybox.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/davout/bitcoin-central/25f056bf8589df213013b012e3d4e5d3e7cf919f/app/assets/images/fancybox/fancybox.png
--------------------------------------------------------------------------------
/app/assets/images/flags/all.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/davout/bitcoin-central/25f056bf8589df213013b012e3d4e5d3e7cf919f/app/assets/images/flags/all.jpg
--------------------------------------------------------------------------------
/app/assets/images/flags/de.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/davout/bitcoin-central/25f056bf8589df213013b012e3d4e5d3e7cf919f/app/assets/images/flags/de.png
--------------------------------------------------------------------------------
/app/assets/images/flags/en.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/davout/bitcoin-central/25f056bf8589df213013b012e3d4e5d3e7cf919f/app/assets/images/flags/en.png
--------------------------------------------------------------------------------
/app/assets/images/flags/fr.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/davout/bitcoin-central/25f056bf8589df213013b012e3d4e5d3e7cf919f/app/assets/images/flags/fr.png
--------------------------------------------------------------------------------
/app/assets/images/flags/it.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/davout/bitcoin-central/25f056bf8589df213013b012e3d4e5d3e7cf919f/app/assets/images/flags/it.png
--------------------------------------------------------------------------------
/app/assets/images/icons/favicon114-precomposed.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/davout/bitcoin-central/25f056bf8589df213013b012e3d4e5d3e7cf919f/app/assets/images/icons/favicon114-precomposed.png
--------------------------------------------------------------------------------
/app/assets/images/icons/favicon32.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/davout/bitcoin-central/25f056bf8589df213013b012e3d4e5d3e7cf919f/app/assets/images/icons/favicon32.png
--------------------------------------------------------------------------------
/app/assets/images/icons/favicon57-precomposed.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/davout/bitcoin-central/25f056bf8589df213013b012e3d4e5d3e7cf919f/app/assets/images/icons/favicon57-precomposed.png
--------------------------------------------------------------------------------
/app/assets/images/icons/favicon72-precomposed.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/davout/bitcoin-central/25f056bf8589df213013b012e3d4e5d3e7cf919f/app/assets/images/icons/favicon72-precomposed.png
--------------------------------------------------------------------------------
/app/assets/images/info.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/davout/bitcoin-central/25f056bf8589df213013b012e3d4e5d3e7cf919f/app/assets/images/info.png
--------------------------------------------------------------------------------
/app/assets/images/os/apple.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/davout/bitcoin-central/25f056bf8589df213013b012e3d4e5d3e7cf919f/app/assets/images/os/apple.png
--------------------------------------------------------------------------------
/app/assets/images/os/github.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/davout/bitcoin-central/25f056bf8589df213013b012e3d4e5d3e7cf919f/app/assets/images/os/github.png
--------------------------------------------------------------------------------
/app/assets/images/os/linux.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/davout/bitcoin-central/25f056bf8589df213013b012e3d4e5d3e7cf919f/app/assets/images/os/linux.png
--------------------------------------------------------------------------------
/app/assets/images/os/ubuntu_ppa.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/davout/bitcoin-central/25f056bf8589df213013b012e3d4e5d3e7cf919f/app/assets/images/os/ubuntu_ppa.png
--------------------------------------------------------------------------------
/app/assets/images/os/windows.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/davout/bitcoin-central/25f056bf8589df213013b012e3d4e5d3e7cf919f/app/assets/images/os/windows.png
--------------------------------------------------------------------------------
/app/assets/images/paid.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/davout/bitcoin-central/25f056bf8589df213013b012e3d4e5d3e7cf919f/app/assets/images/paid.png
--------------------------------------------------------------------------------
/app/assets/images/pending.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/davout/bitcoin-central/25f056bf8589df213013b012e3d4e5d3e7cf919f/app/assets/images/pending.png
--------------------------------------------------------------------------------
/app/assets/images/play.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/davout/bitcoin-central/25f056bf8589df213013b012e3d4e5d3e7cf919f/app/assets/images/play.png
--------------------------------------------------------------------------------
/app/assets/images/processed.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/davout/bitcoin-central/25f056bf8589df213013b012e3d4e5d3e7cf919f/app/assets/images/processed.png
--------------------------------------------------------------------------------
/app/assets/images/processing.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/davout/bitcoin-central/25f056bf8589df213013b012e3d4e5d3e7cf919f/app/assets/images/processing.png
--------------------------------------------------------------------------------
/app/assets/images/qrcode.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/davout/bitcoin-central/25f056bf8589df213013b012e3d4e5d3e7cf919f/app/assets/images/qrcode.png
--------------------------------------------------------------------------------
/app/assets/images/square.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/davout/bitcoin-central/25f056bf8589df213013b012e3d4e5d3e7cf919f/app/assets/images/square.png
--------------------------------------------------------------------------------
/app/assets/images/yubico-icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/davout/bitcoin-central/25f056bf8589df213013b012e3d4e5d3e7cf919f/app/assets/images/yubico-icon.png
--------------------------------------------------------------------------------
/app/assets/stylesheets/.gitkeep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/davout/bitcoin-central/25f056bf8589df213013b012e3d4e5d3e7cf919f/app/assets/stylesheets/.gitkeep
--------------------------------------------------------------------------------
/app/assets/stylesheets/application.css.scss:
--------------------------------------------------------------------------------
1 | /**
2 | *= require_self
3 | */
4 |
5 | @import "bourbon";
6 | @import "reset";
7 | @import "jqplot";
8 | @import "jquery.fancybox";
9 | @import "main";
10 | @import "active_scaffold";
11 |
--------------------------------------------------------------------------------
/app/controllers/admin/admin_controller.rb:
--------------------------------------------------------------------------------
1 | class Admin::AdminController < ApplicationController
2 | before_filter :enforce_management_rights
3 |
4 | def enforce_management_rights
5 | enforce_user_type(Manager)
6 | end
7 |
8 | def enforce_admin_rights
9 | enforce_user_type(Admin)
10 | end
11 |
12 | def enforce_user_type(klass)
13 | unless current_user and current_user.is_a?(klass)
14 | redirect_to root_path,
15 | :error => t(:insufficient_privileges)
16 | end
17 | end
18 | end
19 |
--------------------------------------------------------------------------------
/app/controllers/admin/announcements_controller.rb:
--------------------------------------------------------------------------------
1 | class Admin::AnnouncementsController < Admin::AdminController
2 | active_scaffold :announcement do |config|
3 | config.columns = [:content, :active]
4 |
5 | config.columns[:active].inplace_edit = true
6 | end
7 | end
8 |
--------------------------------------------------------------------------------
/app/controllers/admin/currencies_controller.rb:
--------------------------------------------------------------------------------
1 | class Admin::CurrenciesController < Admin::AdminController
2 | before_filter :enforce_admin_rights
3 |
4 | active_scaffold :currency do |config|
5 | config.columns = [:code, :created_at]
6 | config.actions.exclude :update, :delete
7 | end
8 | end
9 |
--------------------------------------------------------------------------------
/app/controllers/admin/informations_controller.rb:
--------------------------------------------------------------------------------
1 | class Admin::InformationsController < Admin::AdminController
2 | def balances
3 | @balances = [:lrusd, :lreur, :pgau, :eur, :btc, :cad, :inr].inject({}) do |balances, currency|
4 | balances[currency] = {}
5 |
6 | balances[currency][:user] = AccountOperation.
7 | joins(:account).
8 | where("`accounts`.`type` IN ('User', 'Manager', 'Admin')").
9 | with_currency(currency).
10 | select("SUM(`amount`) AS `amount`").
11 | first.
12 | amount
13 |
14 | balances[currency][:user] ||= 0
15 |
16 | balances[currency][:reported] = reported_balance(currency)
17 |
18 | if balances[currency][:reported].is_a? Numeric
19 | balances[currency][:delta] = balances[currency][:reported] - balances[currency][:user]
20 | else
21 | balances[currency][:delta] = "N/A"
22 | end
23 |
24 | balances
25 | end
26 |
27 | @currencies = @balances.keys.map(&:to_s).sort.map(&:to_sym)
28 | end
29 |
30 |
31 | protected
32 |
33 | def reported_balance(currency)
34 | if currency == :btc
35 | Bitcoin::Client.instance.get_balance
36 | elsif [:lreur, :lrusd].include?(currency)
37 | LibertyReserve::Client.instance.get_balance(currency)
38 | else
39 | "N/A"
40 | end
41 | end
42 | end
43 |
--------------------------------------------------------------------------------
/app/controllers/admin/pending_transfers_controller.rb:
--------------------------------------------------------------------------------
1 | class Admin::PendingTransfersController < Admin::AdminController
2 | active_scaffold :account_operation do |config|
3 | config.actions = [:list, :show]
4 |
5 | config.columns = [
6 | :account,
7 | :amount,
8 | :currency,
9 | :type,
10 | :created_at
11 | ]
12 |
13 | config.action_links.add 'process_tx',
14 | :label => 'Mark processed',
15 | :type => :member,
16 | :method => :post,
17 | :position => false
18 | end
19 |
20 | def conditions_for_collection
21 | ["state = 'pending' AND currency IN (#{current_user.allowed_currencies.map { |c| "'#{c.to_s.upcase}'" }.join(",")})"]
22 | end
23 |
24 | def process_tx
25 | Transfer;WireTransfer;LibertyReserveTransfer;BitcoinTransfer
26 |
27 | @record = Transfer.where("currency IN (#{current_user.allowed_currencies.map { |c| "'#{c.to_s.upcase}'" }.join(",")})").
28 | find(params[:id])
29 |
30 | @record.process!
31 |
32 | UserMailer.withdrawal_processed_notification(@record).deliver
33 |
34 | render :template => 'admin/pending_transfers/process_tx'
35 | end
36 | end
37 |
--------------------------------------------------------------------------------
/app/controllers/admin/static_pages_controller.rb:
--------------------------------------------------------------------------------
1 | class Admin::StaticPagesController < Admin::AdminController
2 | active_scaffold :static_page do |config|
3 | config.columns = [:name, :title, :locale, :contents]
4 | config.list.columns = [:name, :title, :locale]
5 | end
6 | end
7 |
--------------------------------------------------------------------------------
/app/controllers/admin/tickets_controller.rb:
--------------------------------------------------------------------------------
1 | class Admin::TicketsController < Admin::AdminController
2 | active_scaffold :ticket do |config|
3 | config.columns = [:id, :state, :user, :created_at, :title, :description]
4 | end
5 | end
--------------------------------------------------------------------------------
/app/controllers/admin/yubikeys_controller.rb:
--------------------------------------------------------------------------------
1 | class Admin::YubikeysController < Admin::AdminController
2 | active_scaffold :yubikey do |config|
3 | config.columns = [:user, :key_id, :active, :otp]
4 |
5 | config.list.columns = config.show.columns = [:user, :key_id, :active]
6 | config.create.columns = [:otp]
7 | config.update.columns = [:active]
8 |
9 | config.columns[:active].inplace_edit = true
10 | end
11 | end
12 |
--------------------------------------------------------------------------------
/app/controllers/bank_accounts_controller.rb:
--------------------------------------------------------------------------------
1 | class BankAccountsController < ApplicationController
2 | def index
3 | @bank_accounts = current_user.bank_accounts
4 | @bank_account = BankAccount.new
5 | end
6 |
7 | def create
8 | @bank_accounts = current_user.bank_accounts
9 | @bank_account = current_user.bank_accounts.new(params[:bank_account])
10 |
11 | if @bank_account.save
12 | redirect_to user_bank_accounts_path,
13 | :notice => t("bank_accounts.index.created")
14 | else
15 | render :action => :index
16 | end
17 | end
18 |
19 | def destroy
20 | @bank_account = current_user.bank_accounts.find(params[:id])
21 |
22 | if @bank_account.wire_transfers.blank? && (@bank_account.state != 'verified')
23 | @bank_account.destroy
24 | flash[:notice] = t("bank_accounts.index.destroyed")
25 | else
26 | flash[:error] = t("bank_accounts.index.not_destroyed")
27 | end
28 |
29 | @bank_accounts = current_user.bank_accounts
30 | redirect_to user_bank_accounts_path
31 | end
32 | end
33 |
--------------------------------------------------------------------------------
/app/controllers/comments_controller.rb:
--------------------------------------------------------------------------------
1 | class CommentsController < ApplicationController
2 | def create
3 | ticket = Ticket.find(params[:ticket_id])
4 | comment = ticket.comments.new(params[:comment])
5 | comment.user = current_user
6 | comment.save
7 | redirect_to user_ticket_path(ticket, :anchor => "comment-#{comment.id}")
8 | end
9 | end
10 |
--------------------------------------------------------------------------------
/app/controllers/qrcodes_controller.rb:
--------------------------------------------------------------------------------
1 | class QrcodesController < ApplicationController
2 | skip_before_filter :authenticate_user!
3 |
4 | ALLOWED_PATTERN = /^[a-zA-Z0-9\:\/\-\?\=]{1,255}$/
5 |
6 | def show
7 | data = params[:data]
8 |
9 | raise "Invalid data" unless data.match(ALLOWED_PATTERN)
10 |
11 | png_data = QREncoder.encode(data, :correction => :high).
12 | png(:pixels_per_module => 6, :margin => 1).
13 | to_blob
14 |
15 | send_data png_data,
16 | :type => 'image/png',
17 | :disposition => 'inline',
18 | :filename => "#{params[:filename] || data}.png"
19 | end
20 | end
21 |
--------------------------------------------------------------------------------
/app/controllers/registrations_controller.rb:
--------------------------------------------------------------------------------
1 | class RegistrationsController < Devise::RegistrationsController
2 | def create
3 | build_resource
4 |
5 | resource.email = params[:user][:email]
6 |
7 | verify_recaptcha and resource.captcha_checked!
8 |
9 | if resource.save
10 | redirect_to root_path,
11 | :notice => t("devise.registrations.signed_up")
12 | else
13 | clean_up_passwords(resource)
14 | render_with_scope :new
15 | end
16 | end
17 | end
18 |
--------------------------------------------------------------------------------
/app/controllers/static_pages_controller.rb:
--------------------------------------------------------------------------------
1 | class StaticPagesController < ApplicationController
2 | skip_before_filter :authenticate_user!
3 |
4 | def show
5 | @static_page = StaticPage.get_page(params[:name], I18n.locale)
6 |
7 | unless @static_page
8 | raise ActionController::RoutingError.new('Not Found')
9 | end
10 | end
11 | end
12 |
--------------------------------------------------------------------------------
/app/controllers/tickets_controller.rb:
--------------------------------------------------------------------------------
1 | class TicketsController < ApplicationController
2 | before_filter :check_permissions,
3 | :only => [:show, :close, :reopen]
4 |
5 | def new
6 | @ticket = current_user.tickets.new
7 | end
8 |
9 | def index
10 | @tickets = current_user.tickets
11 | end
12 |
13 | def create
14 | @ticket = current_user.tickets.new(params[:ticket])
15 |
16 | if @ticket.save
17 | redirect_to user_ticket_path(@ticket),
18 | :notice => t("tickets.index.successfully_created")
19 | else
20 | render :action => :new
21 | end
22 | end
23 |
24 | def show
25 | end
26 |
27 | def reopen
28 | @ticket.reopen!
29 | redirect_to user_ticket_path(@ticket)
30 | end
31 |
32 | def close
33 | @ticket.close!
34 | redirect_to user_ticket_path(@ticket)
35 | end
36 |
37 | def check_permissions
38 | @ticket = Ticket.find(params[:id])
39 |
40 | unless (@ticket.user == current_user) || current_user.is_a?(Manager)
41 | render :nothing => true,
42 | :status => :forbidden
43 |
44 | return(false)
45 | end
46 | end
47 | end
48 |
--------------------------------------------------------------------------------
/app/controllers/trades_controller.rb:
--------------------------------------------------------------------------------
1 | class TradesController < ApplicationController
2 | skip_before_filter :authenticate_user!,
3 | :only => [:all_trades, :ticker]
4 |
5 | def index
6 | @trades = Trade.
7 | involved(current_user).
8 | paginate(:page => params[:page], :per_page => 16)
9 | end
10 |
11 | def all_trades
12 | predicate = Trade
13 |
14 | if params[:currency]
15 | predicate = predicate.with_currency(params[:currency])
16 | end
17 |
18 | @trades = predicate.all
19 | end
20 |
21 | def ticker
22 | currency = (params[:currency] || "eur").downcase.to_sym
23 |
24 | @ticker = {
25 | :at => DateTime.now.to_i,
26 | :high => Trade.with_currency(currency).last_24h.maximum(:ppc),
27 | :low => Trade.with_currency(currency).last_24h.minimum(:ppc),
28 | :volume => (Trade.with_currency(currency).last_24h.sum(:traded_btc) || 0),
29 | :buy => TradeOrder.with_currency(currency).with_category(:buy).active.maximum(:ppc),
30 | :sell => TradeOrder.with_currency(currency).with_category(:sell).active.minimum(:ppc),
31 | :last_trade => Trade.with_currency(currency).count.zero? ? nil : {
32 | :at => Trade.with_currency(currency).plottable(currency).last.created_at.to_i,
33 | :price => Trade.with_currency(currency).plottable(currency).last.ppc
34 | }
35 | }
36 | end
37 | end
38 |
--------------------------------------------------------------------------------
/app/controllers/yubikeys_controller.rb:
--------------------------------------------------------------------------------
1 | class YubikeysController < ApplicationController
2 | def index
3 | @yubikeys = current_user.yubikeys
4 | @yubikey = Yubikey.new
5 | end
6 |
7 | def create
8 | @yubikeys = current_user.yubikeys
9 | @yubikey = current_user.yubikeys.new(:otp => params[:yubikey][:otp])
10 |
11 | if @yubikey.save
12 | redirect_to user_yubikeys_path,
13 | :notice => t("yubikeys.index.created")
14 | else
15 | render :action => :index
16 | end
17 | end
18 |
19 | def destroy
20 | current_user.yubikeys.find(params[:id]).destroy
21 | redirect_to user_yubikeys_path,
22 | :notice => t("yubikeys.index.destroyed")
23 | end
24 | end
25 |
--------------------------------------------------------------------------------
/app/helpers/accounts_helper.rb:
--------------------------------------------------------------------------------
1 | module AccountsHelper
2 | def exact_balance(balance, code)
3 | "#{"%.5f" % balance} #{code.upcase}"
4 | end
5 |
6 | def color_for_balance(balance)
7 | if balance > 0
8 | "green"
9 | elsif balance < 0
10 | "red"
11 | end
12 | end
13 |
14 | def sign_for_balance(balance)
15 | if balance > 0
16 | "+"
17 | elsif balance < 0
18 | "-"
19 | end
20 | end
21 | end
22 |
--------------------------------------------------------------------------------
/app/helpers/admin/account_operations_helpers.rb:
--------------------------------------------------------------------------------
1 | module Admin::AccountOperationsHelper
2 | def user_column(record)
3 | record.user.account
4 | end
5 | end
6 |
--------------------------------------------------------------------------------
/app/helpers/admin/announcements_helper.rb:
--------------------------------------------------------------------------------
1 | module Admin::AnnouncementsHelper
2 | end
3 |
--------------------------------------------------------------------------------
/app/helpers/admin/currencies_helper.rb:
--------------------------------------------------------------------------------
1 | module Admin::CurrenciesHelper
2 | end
3 |
--------------------------------------------------------------------------------
/app/helpers/admin/informations_helper.rb:
--------------------------------------------------------------------------------
1 | module Admin::InformationsHelper
2 | end
3 |
--------------------------------------------------------------------------------
/app/helpers/admin/pending_transfers_helper.rb:
--------------------------------------------------------------------------------
1 | module Admin::PendingTransfersHelper
2 | def type_column(record)
3 | record.class.to_s.gsub(/Transfer$/, "")
4 | end
5 | end
6 |
--------------------------------------------------------------------------------
/app/helpers/admin/static_pages_helper.rb:
--------------------------------------------------------------------------------
1 | module Admin::StaticPagesHelper
2 | end
3 |
--------------------------------------------------------------------------------
/app/helpers/admin/tickets_helper.rb:
--------------------------------------------------------------------------------
1 | module Admin::TicketsHelper
2 | def title_column(record)
3 | link_to(record.title, user_ticket_path(record))
4 | end
5 | end
6 |
--------------------------------------------------------------------------------
/app/helpers/admin/users_helper.rb:
--------------------------------------------------------------------------------
1 | module Admin::UsersHelper
2 | def id_column(record)
3 | record.id.to_s
4 | end
5 |
6 | def name_column(record)
7 | link_to record.name, admin_user_account_operations_path(record)
8 | end
9 | end
10 |
--------------------------------------------------------------------------------
/app/helpers/admin/yubikeys_helper.rb:
--------------------------------------------------------------------------------
1 | module Admin::YubikeysHelper
2 | end
3 |
--------------------------------------------------------------------------------
/app/helpers/bank_accounts_helper.rb:
--------------------------------------------------------------------------------
1 | module BankAccountsHelper
2 | def bank_account_delete(bank_account)
3 | if bank_account.wire_transfers.blank? && (bank_account.state != 'verified')
4 | link_to(image_tag("delete.png", :alt => t(".delete"), :title => t(".delete")), user_bank_account_path(bank_account), :method => :delete, :confirm => t(".confirm"))
5 | end
6 | end
7 | end
8 |
--------------------------------------------------------------------------------
/app/helpers/comments_helper.rb:
--------------------------------------------------------------------------------
1 | module CommentsHelper
2 | end
3 |
--------------------------------------------------------------------------------
/app/helpers/informations_helper.rb:
--------------------------------------------------------------------------------
1 | module InformationsHelper
2 | end
3 |
--------------------------------------------------------------------------------
/app/helpers/invoices_helper.rb:
--------------------------------------------------------------------------------
1 | module InvoicesHelper
2 | def invoice_details(invoice)
3 | link_to(image_tag("details.png", :alt => t(".details"), :title => t(".details")), invoice_path(invoice))
4 | end
5 |
6 | def invoice_delete(invoice)
7 | link_to(image_tag("delete.png", :alt => t(".delete"), :title => t(".delete")), invoice_path(invoice), :method => :delete, :confirm => t(".confirm"))
8 | end
9 |
10 | def invoice_state(state, options = {})
11 | content_tag :span,
12 | :title => tooltip_for_state(state),
13 | :class => ["invoice-state", color_for_state(state)] do
14 | "#{options[:icon] ? image_tag("#{state}.png", :class => "state-icon") : ""} #{t("activerecord.extra.invoice.state_translations.#{state}")}".strip.html_safe
15 | end
16 | end
17 |
18 | def color_for_state(state)
19 | case state
20 | when "pending" then "red"
21 | when "processing" then "orange"
22 | when "paid" then "green"
23 | end
24 | end
25 |
26 | def tooltip_for_state(state)
27 | t("activerecord.extra.invoice.state_tooltips.#{state}")
28 | end
29 |
30 | def auto_refresh_if_necessary(invoice)
31 | unless invoice.paid?
32 | content_for :head do
33 | tag :meta, "http-equiv" => "refresh", "content" => "30"
34 | end
35 | end
36 | end
37 | end
--------------------------------------------------------------------------------
/app/helpers/qrcodes_helper.rb:
--------------------------------------------------------------------------------
1 | module QrcodesHelper
2 | end
3 |
--------------------------------------------------------------------------------
/app/helpers/registrations_helper.rb:
--------------------------------------------------------------------------------
1 | module RegistrationsHelper
2 | end
3 |
--------------------------------------------------------------------------------
/app/helpers/static_pages_helper.rb:
--------------------------------------------------------------------------------
1 | module StaticPagesHelper
2 | end
3 |
--------------------------------------------------------------------------------
/app/helpers/tickets_helper.rb:
--------------------------------------------------------------------------------
1 | module TicketsHelper
2 | end
3 |
--------------------------------------------------------------------------------
/app/helpers/trades_helper.rb:
--------------------------------------------------------------------------------
1 | module TradesHelper
2 | def type_for_trade(trade)
3 | if trade.buyer_id == current_user.id
4 | t("activerecord.extra.trade.types.buy")
5 | else
6 | t("activerecord.extra.trade.types.sell")
7 | end
8 | end
9 | end
10 |
--------------------------------------------------------------------------------
/app/helpers/transfers_helper.rb:
--------------------------------------------------------------------------------
1 | module TransfersHelper
2 | def color_for(transfer)
3 | transfer.amount > 0 ? (transfer.confirmed? ? "green" : "unconfirmed") : "red"
4 | end
5 |
6 | def confirmation_tooltip_for(transfer)
7 | unless transfer.confirmed?
8 | t :confirmations_left, :count => (Transfer::MIN_BTC_CONFIRMATIONS - transfer.bt_tx_confirmations)
9 | end
10 | end
11 |
12 | def transfer_details(transfer)
13 | link_to(image_tag("details.png", :alt => t(".details"), :title => t(".details")), account_transfer_path(transfer))
14 | end
15 |
16 | def transfer_state(state, options = {})
17 | content_tag :span,
18 | :class => ["transfer-state", color_for_transfer_state(state)] do
19 | "#{options[:icon] ? image_tag("#{state}.png", :class => "state-icon") : ""} #{options[:message]}".strip.html_safe
20 | end
21 | end
22 |
23 | def color_for_transfer_state(state)
24 | case state
25 | when "pending" : "orange"
26 | when "processed" : "green"
27 | end
28 | end
29 | end
30 |
--------------------------------------------------------------------------------
/app/helpers/users_helper.rb:
--------------------------------------------------------------------------------
1 | module UsersHelper
2 | end
3 |
--------------------------------------------------------------------------------
/app/helpers/yubikeys_helper.rb:
--------------------------------------------------------------------------------
1 | module YubikeysHelper
2 | def yubikey_details(yubikey)
3 | link_to(image_tag("details.png", :alt => t(".details"), :title => t(".details")), user_yubikey_path(yubikey))
4 | end
5 |
6 | def yubikey_delete(yubikey)
7 | link_to(image_tag("delete.png", :alt => t(".delete"), :title => t(".delete")), user_yubikey_path(yubikey), :method => :delete, :confirm => t(".confirm"))
8 | end
9 | end
10 |
--------------------------------------------------------------------------------
/app/mailers/backup_mailer.rb:
--------------------------------------------------------------------------------
1 | class BackupMailer < BitcoinCentralMailer
2 | def wallet_backup(recipient, wallet)
3 | attachments["wallet_#{DateTime.now.strftime("%Y_%m_%d_%H_%M.dat.gpg")}"] = File.read(wallet)
4 |
5 | mail :to => recipient,
6 | :subject => (I18n.t :wallet_backup_subject, :date=>(I18n.l DateTime.now))
7 | end
8 | end
9 |
--------------------------------------------------------------------------------
/app/mailers/ticket_mailer.rb:
--------------------------------------------------------------------------------
1 | class TicketMailer < BitcoinCentralMailer
2 | def create_notification(ticket)
3 | do_notify(:create, ticket)
4 | end
5 |
6 | def reopen_notification(ticket)
7 | do_notify(:reopen, ticket)
8 | end
9 |
10 | def close_notification(ticket)
11 | do_notify(:close, ticket)
12 | end
13 |
14 | def comment_notification(ticket)
15 | do_notify(:comment, ticket)
16 | end
17 |
18 | def do_notify(action, ticket)
19 | @user = ticket.user
20 | @ticket = ticket
21 |
22 | mail :to => @user.email,
23 | :bcc => Manager.all.map(&:email),
24 | :subject => I18n.t("emails.tickets.#{action}_notification.subject"),
25 | :template_name => 'ticket_notification'
26 | end
27 | end
28 |
--------------------------------------------------------------------------------
/app/mailers/user_mailer.rb:
--------------------------------------------------------------------------------
1 | class UserMailer < BitcoinCentralMailer
2 | def registration_confirmation(user)
3 | @user = user
4 |
5 | mail :to => user.email,
6 | :subject => (I18n.t :sign_up_confirmation)
7 | end
8 |
9 | def invoice_payment_notification(invoice)
10 | @user = invoice.user
11 | @invoice = invoice
12 |
13 | mail :to => @user.email,
14 | :subject => I18n.t("emails.invoice_payment_notification.subject")
15 | end
16 |
17 | def withdrawal_processed_notification(withdrawal)
18 | @user = withdrawal.account
19 | @withdrawal = withdrawal
20 |
21 | mail :to => @user.email,
22 | :subject => I18n.t("emails.withdrawal_processed_notification.subject")
23 | end
24 |
25 | def trade_notification(user, sales, purchases)
26 | @sales = sales
27 | @purchases = purchases
28 |
29 | mail :to => user.email,
30 | :subject => I18n.t("emails.trade_notification.subject")
31 | end
32 | end
33 |
--------------------------------------------------------------------------------
/app/models/account.rb:
--------------------------------------------------------------------------------
1 | class Account < ActiveRecord::Base
2 | has_many :account_operations
3 |
4 | has_many :used_currencies,
5 | :dependent => :destroy
6 |
7 | belongs_to :parent,
8 | :class_name => 'Account'
9 |
10 | validates :name,
11 | :presence => true,
12 | :uniqueness => true
13 |
14 | # BigDecimal returned here
15 | def balance(currency, options = {} )
16 | account_operations.with_currency(currency).with_confirmations(options[:unconfirmed]).map(&:amount).sum
17 | end
18 |
19 | # Generates a new receiving address if it hasn't already been refreshed during the last hour
20 | def generate_new_address
21 | unless last_address_refresh && last_address_refresh > DateTime.now.advance(:hours => -1)
22 | self.last_address_refresh = DateTime.now
23 | self.bitcoin_address = Bitcoin::Client.instance.get_new_address(id.to_s)
24 | save
25 | end
26 | end
27 |
28 | def max_withdraw_for(currency)
29 | Transfer.round_amount(self.balance(currency), currency)
30 | end
31 |
32 | def self.storage_account_for(currency)
33 | account_name = "storage_for_#{currency.to_s.downcase}"
34 | account = find_by_name(account_name)
35 |
36 | if account
37 | account
38 | else
39 | Account.create! do |a|
40 | a.name = account_name
41 | end
42 | end
43 | end
44 | end
45 |
--------------------------------------------------------------------------------
/app/models/admin.rb:
--------------------------------------------------------------------------------
1 | class Admin < Manager
2 | def allowed_currencies
3 | Currency.all.map { |c| c.code.downcase.to_sym }
4 | end
5 | end
6 |
--------------------------------------------------------------------------------
/app/models/announcement.rb:
--------------------------------------------------------------------------------
1 | class Announcement < ActiveRecord::Base
2 | default_scope order("created_at DESC")
3 |
4 | validates :content,
5 | :presence => true
6 |
7 | def self.active
8 | where(:active => true)
9 | end
10 | end
11 |
--------------------------------------------------------------------------------
/app/models/bank_account.rb:
--------------------------------------------------------------------------------
1 | class BankAccount < ActiveRecord::Base
2 | include ActiveRecord::Transitions
3 |
4 | attr_accessible :bic, :iban, :account_holder
5 |
6 | belongs_to :user
7 |
8 | has_many :wire_transfers
9 |
10 | validates :bic,
11 | :presence => true,
12 | :format => { :with => /[A-Z]{6}[A-Z0-9]{2}[A-Z0-9]{0,3}/ }
13 |
14 | validates :iban,
15 | :presence => true,
16 | :iban => true
17 |
18 | validates :account_holder,
19 | :presence => true
20 |
21 | state_machine do
22 | state :unverified
23 | state :verified
24 |
25 | event :verify do
26 | transitions :to => :verified, :from => :unverified
27 | end
28 | end
29 |
30 | def iban
31 | IBANTools::IBAN.new(super).prettify
32 | end
33 |
34 | def to_label
35 | iban
36 | end
37 | end
38 |
--------------------------------------------------------------------------------
/app/models/bitcoin_transfer.rb:
--------------------------------------------------------------------------------
1 | class BitcoinTransfer < Transfer
2 | attr_accessible :address
3 |
4 | validates :address,
5 | :bitcoin_address => true,
6 | :not_mine => true,
7 | :presence => true
8 |
9 | validates :currency,
10 | :inclusion => { :in => ["BTC"] }
11 |
12 | def address=(a)
13 | self[:address] = a.strip
14 | end
15 |
16 | def execute
17 | # TODO : Re-implement instant internal transfer
18 | if bt_tx_id.blank? && pending? && (Bitcoin::Client.instance.get_balance >= amount.abs)
19 | update_attribute(:bt_tx_id, Bitcoin::Client.instance.send_to_address(address, amount.abs))
20 | process!
21 | end
22 | end
23 | end
24 |
25 |
--------------------------------------------------------------------------------
/app/models/comment.rb:
--------------------------------------------------------------------------------
1 | class Comment < ActiveRecord::Base
2 | default_scope order("created_at ASC")
3 |
4 | attr_accessible :contents
5 |
6 | after_create :notify_comment!
7 |
8 | belongs_to :user
9 | belongs_to :ticket
10 |
11 | validates :user,
12 | :presence => true
13 |
14 | validates :contents,
15 | :presence => true
16 |
17 | def notify_comment!
18 | TicketMailer.comment_notification(self.ticket).deliver
19 | end
20 | end
21 |
--------------------------------------------------------------------------------
/app/models/currency.rb:
--------------------------------------------------------------------------------
1 | class Currency < ActiveRecord::Base
2 | has_many :used_currencies,
3 | :dependent => :destroy
4 | end
5 |
--------------------------------------------------------------------------------
/app/models/liberty_reserve_transfer.rb:
--------------------------------------------------------------------------------
1 | class LibertyReserveTransfer < Transfer
2 | attr_accessible :lr_account_id
3 |
4 | validates :currency,
5 | :inclusion => { :in => ["LRUSD", "LREUR"] }
6 |
7 | validates :lr_account_id,
8 | :presence => true
9 |
10 | def execute
11 | if lr_transaction_id.blank? && pending? && (LibertyReserve::Client.instance.get_balance(currency) >= amount.abs)
12 | result = LibertyReserve::Client.instance.transfer(lr_account_id, amount.to_d.abs, currency)
13 | update_attribute(:lr_transaction_id, result['TransferResponse']['Receipt']['ReceiptId'])
14 | process!
15 | end
16 | end
17 | end
18 |
--------------------------------------------------------------------------------
/app/models/limit_order.rb:
--------------------------------------------------------------------------------
1 | class LimitOrder < TradeOrder
2 | validates :ppc,
3 | :minimal_order_ppc => true,
4 | :numericality => true
5 |
6 | validate :amount do
7 | if new_record?
8 | if amount and (amount > user.balance(:btc)) and selling?
9 | errors[:amount] << (I18n.t "errors.greater_than_balance", :balance=>("%.4f" % user.balance(:btc)), :currency=>"BTC")
10 | end
11 |
12 | unless currency.blank?
13 | if amount and ppc and ((user.balance(currency) / ppc) < amount ) and buying?
14 | errors[:amount] << (I18n.t "errors.greater_than_capacity", :capacity=>("%.4f" % (user.balance(currency) / ppc)), :ppc=>ppc, :currency=>currency)
15 | end
16 | end
17 | end
18 | end
19 |
20 | def sub_matching_orders(predicate)
21 | predicate.where("(ppc #{buying? ? '<=' : '>='} ? OR ppc IS NULL)", ppc)
22 | end
23 | end
24 |
--------------------------------------------------------------------------------
/app/models/manager.rb:
--------------------------------------------------------------------------------
1 | class Manager < User
2 | def allowed_currencies
3 | Currency.
4 | where("id IN (#{used_currencies.where(:management => true).map(&:currency_id).join(",")})").
5 | map { |c| c.code.downcase.to_sym }
6 | end
7 | end
8 |
--------------------------------------------------------------------------------
/app/models/market_order.rb:
--------------------------------------------------------------------------------
1 | class MarketOrder < TradeOrder
2 | validates :ppc,
3 | :blank => true
4 |
5 | def sub_matching_orders(predicate)
6 | predicate.where("ppc IS NOT NULL")
7 | end
8 | end
9 |
--------------------------------------------------------------------------------
/app/models/operation.rb:
--------------------------------------------------------------------------------
1 | class Operation < ActiveRecord::Base
2 | has_many :account_operations
3 |
4 | validate :check_debit_credit_equality
5 |
6 | def check_debit_credit_equality
7 | # Debit and credit amounts should be equal for *each* currency
8 | account_operations.map(&:currency).uniq.each do |currency|
9 | unless account_operations.select{ |ao| ao.currency = currency }.map(&:amount).compact.sum.zero?
10 | errors[:base] << I18n.t("errors.debit_not_equal_to_credit", :currency => currency)
11 | end
12 | end
13 | end
14 | end
15 |
--------------------------------------------------------------------------------
/app/models/static_page.rb:
--------------------------------------------------------------------------------
1 | class StaticPage < ActiveRecord::Base
2 | attr_accessible :name, :title, :locale, :contents
3 |
4 | validates :name,
5 | :presence => true
6 |
7 | validates :title,
8 | :presence => true
9 |
10 | validates :locale,
11 | :presence => true,
12 | :inclusion => { :in => I18n.available_locales.map(&:to_s) }
13 |
14 | validates :contents,
15 | :presence => true
16 |
17 | def self.get_page(name, locale)
18 | with_name(name).with_locale(locale).first or with_name(name).with_locale(I18n.default_locale).first
19 | end
20 |
21 |
22 | protected
23 |
24 | def self.with_name(name)
25 | where(:name => name)
26 | end
27 |
28 | def self.with_locale(locale)
29 | where("locale = ?", locale)
30 | end
31 | end
32 |
--------------------------------------------------------------------------------
/app/models/ticket.rb:
--------------------------------------------------------------------------------
1 | class Ticket < ActiveRecord::Base
2 | include ActiveRecord::Transitions
3 |
4 | attr_accessible :title, :description
5 |
6 | belongs_to :user
7 |
8 | has_many :comments,
9 | :dependent => :destroy
10 |
11 | validates :title,
12 | :presence => true
13 |
14 | validates :description,
15 | :presence => true
16 |
17 | after_create :notify_create!
18 |
19 | state_machine do
20 | state :pending
21 | state :closed
22 |
23 | event :close do
24 | transitions :to => :closed,
25 | :from => :pending,
26 | :on_transition => lambda { |t|
27 | t.notify_close!
28 | }
29 | end
30 |
31 | event :reopen do
32 | transitions :to => :pending,
33 | :from => :closed,
34 | :on_transition => lambda { |t|
35 | t.notify_reopen!
36 | }
37 | end
38 | end
39 |
40 | def self.pending
41 | where(:state => 'pending')
42 | end
43 |
44 | def notify_close!
45 | TicketMailer.close_notification(self).deliver
46 | end
47 |
48 | def notify_reopen!
49 | TicketMailer.reopen_notification(self).deliver
50 | end
51 |
52 | def notify_create!
53 | TicketMailer.create_notification(self).deliver
54 | end
55 | end
56 |
--------------------------------------------------------------------------------
/app/models/used_currency.rb:
--------------------------------------------------------------------------------
1 | class UsedCurrency < ActiveRecord::Base
2 | belongs_to :user
3 | belongs_to :currency
4 | end
5 |
--------------------------------------------------------------------------------
/app/models/wire_transfer.rb:
--------------------------------------------------------------------------------
1 | class WireTransfer < Transfer
2 | attr_accessible :bank_account_id, :bank_account_attributes
3 |
4 | belongs_to :bank_account
5 |
6 | accepts_nested_attributes_for :bank_account
7 |
8 | before_validation :check_bank_account_id
9 |
10 | validates :bank_account,
11 | :presence => true
12 |
13 | validates :currency,
14 | :inclusion => { :in => ["EUR"] }
15 |
16 | def execute
17 | # Placeholder for now
18 | end
19 |
20 | def check_bank_account_id
21 | if bank_account_id && account.bank_accounts.find(bank_account_id).blank?
22 | raise "Someone is trying to pull something fishy off"
23 | end
24 | end
25 | end
26 |
--------------------------------------------------------------------------------
/app/models/yubikey.rb:
--------------------------------------------------------------------------------
1 | class Yubikey < ActiveRecord::Base
2 | attr_accessor :otp
3 | attr_accessible :otp
4 |
5 | belongs_to :user
6 |
7 | before_validation :set_key_id
8 |
9 | validates :key_id,
10 | :presence => true,
11 | :uniqueness => true
12 |
13 | validates :user,
14 | :presence => true
15 |
16 | def valid_otp?(yk_otp)
17 | !yk_otp.blank? && (key_id.blank? || (yk_otp[0, 12] == key_id)) && Yubico::Client.instance.verify_otp(yk_otp)
18 | end
19 |
20 | def to_label
21 | "Key : #{key_id}"
22 | end
23 |
24 |
25 | protected
26 |
27 | def set_key_id
28 | unless key_id
29 | if valid_otp?(otp)
30 | self.key_id = otp[0, 12]
31 | else
32 | errors[:base] << I18n.t("errors.messages.invalid_otp")
33 | end
34 | end
35 | end
36 | end
37 |
--------------------------------------------------------------------------------
/app/views/accounts/_balance_row.html.haml:
--------------------------------------------------------------------------------
1 | - if (balance > 0) or %w{btc eur}.include?(code)
2 | %tr
3 | %td= link_to image_tag("currencies/#{code}_logo.png", :alt => t("currencies.#{code}.name"), :title => t("currencies.#{code}.name")), t("currencies.#{code}.link"), :target => "_blank", :title => t("currencies.#{code}.name")
4 | %td= code.upcase
5 | %td.account-balance{ :title => exact_balance(balance, code) }
6 | %div{ :class => color_for_balance(balance) }
7 | #{sign_for_balance(balance)} #{number_to_currency(balance, :unit => "")}
8 |
9 | - if code == "btc" and unconfirmed_btc > 0
10 | %br
11 | %span.unconfirmed{ :title => t(:balance_unconfirmed) }
12 | + #{number_to_currency(unconfirmed_btc, :unit => "")}
--------------------------------------------------------------------------------
/app/views/accounts/_lr_sci_form.html.erb:
--------------------------------------------------------------------------------
1 |
2 | <%= t(".click_for_lr_html", :action => "$('#add_lr').submit();") %>
3 |
4 |
5 |
23 |
--------------------------------------------------------------------------------
/app/views/accounts/_px_sci_form.html.erb:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/app/views/accounts/pecunix_deposit_form.js.erb:
--------------------------------------------------------------------------------
1 | $("div#pecunix-sci-form-container").html("<%= escape_javascript(render(:partial => "accounts/px_sci_form", :locals => { :config => @config, :hash => @hash, :amount => @amount, :payment_id => @payment_id })).html_safe %>");
2 | $("#pecunix-sci-form").submit();
--------------------------------------------------------------------------------
/app/views/accounts/show.html.haml:
--------------------------------------------------------------------------------
1 | .creation-link
2 | = link_to("#{image_tag("add.gif", :alt => t(".add_funds"), :title => t(".add_funds"))} #{t(".add_funds")}".html_safe, deposit_account_path)
3 |
4 | %h1= t :account_balance_title
5 |
6 | %table#account-balances.default
7 | %tr
8 | %th
9 | %th= t :currency
10 | %th= t :balance
11 |
12 | - @balances.keys.sort.each do |code|
13 | - unless %w{UNCONFIRMED_BTC ADDRESS}.include?(code)
14 | = render :partial => 'accounts/balance_row', :locals => { :code => code.downcase, :balance => @balances[code], :unconfirmed_btc => @balances['UNCONFIRMED_BTC'] }
15 |
--------------------------------------------------------------------------------
/app/views/admin/account_operations/_currency_form_column.html.erb:
--------------------------------------------------------------------------------
1 |
2 |
3 | <%= t("activerecord.attributes.account_operation.currency") %>
4 |
5 |
6 |
7 | <% current_user.allowed_currencies.map(&:to_s).each do |c| %>
8 | <%= c.upcase %> - <%= t("activerecord.extra.currency.codes.#{c}") %>
9 | <% end %>
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/app/views/admin/informations/balances.html.haml:
--------------------------------------------------------------------------------
1 | %h1 Total balances
2 |
3 | %table.default
4 | %tr
5 | %th Currency
6 | %th User total balance
7 | %th Third-party balance
8 | %th Delta
9 | - @currencies.each do |currency|
10 | %tr{ :class => cycle('even', 'odd') }
11 | %td= currency.to_s.upcase
12 | %td.amount= @balances[currency][:user]
13 | %td.amount= @balances[currency][:reported]
14 | %td.amount= @balances[currency][:delta]
15 |
--------------------------------------------------------------------------------
/app/views/admin/pending_transfers/process_tx.js.erb:
--------------------------------------------------------------------------------
1 | ActiveScaffold.delete_record_row('<%=element_row_id(:action => 'list', :id => params[:id])%>', '<%=url_for(params_for(:action => :index, :id => nil, :page => [active_scaffold_config.list.user.page.to_i - 1, 1].max, :escape => false))%>');
--------------------------------------------------------------------------------
/app/views/admin/users/balances.html.haml:
--------------------------------------------------------------------------------
1 | %h1= "Balances for #{@user.name} (#{@user.email})"
2 |
3 | %table.default.details
4 | - @balances.each do |c, b|
5 | %tr{ :class => cycle('even', 'odd') }
6 | %th= c
7 | %td.amount= b
--------------------------------------------------------------------------------
/app/views/backup_mailer/wallet_backup.text.erb:
--------------------------------------------------------------------------------
1 | <%= t :encrypted_wallet, :date=>(l DateTime.now) %>
--------------------------------------------------------------------------------
/app/views/bank_accounts/_fields.html.haml:
--------------------------------------------------------------------------------
1 | .form-field
2 | = form_builder.label :bic
3 | = form_builder.text_field :bic
4 |
5 | .form-field
6 | = form_builder.label :iban
7 | = form_builder.text_field :iban
8 |
9 | .form-field
10 | = form_builder.label :account_holder
11 | = form_builder.text_area :account_holder, :rows => 5
12 |
--------------------------------------------------------------------------------
/app/views/bank_accounts/_list.html.haml:
--------------------------------------------------------------------------------
1 | %table.default
2 | %tr
3 | %th= t("activerecord.attributes.bank_account.created_at")
4 | %th= t("activerecord.attributes.bank_account.bic")
5 | %th= t("activerecord.attributes.bank_account.iban")
6 | %th= t("activerecord.attributes.bank_account.state")
7 | %th.auto-sized
8 |
9 | - unless bank_accounts.blank?
10 | - bank_accounts.each do |bank_account|
11 | %tr{ :class => cycle('even', 'odd') }
12 | %td= l(bank_account.created_at, :format => :short)
13 | %td.fixed= bank_account.bic
14 | %td.fixed= bank_account.iban
15 | %td{ :class => bank_account.state }= t("activerecord.extra.bank_account.states.#{bank_account.state}")
16 | %td.auto-sized= bank_account_delete(bank_account)
17 | - else
18 | = render :partial => "layouts/no_data"
19 |
--------------------------------------------------------------------------------
/app/views/bank_accounts/index.html.haml:
--------------------------------------------------------------------------------
1 | %h1= t(".title")
2 |
3 | = form_for [current_user, @bank_account], :url => user_bank_accounts_path do |f|
4 | = errors_for @bank_account, :message => "bank_accounts.index.error"
5 | = render :partial => 'bank_accounts/fields', :locals => { :form_builder => f }
6 | .form-field
7 | = f.submit t(".submit"), :class => 'submit'
8 |
9 | %br
10 |
11 | %h1= t("activerecord.models.bank_account.other")
12 | = render :partial => 'bank_accounts/list', :locals => { :bank_accounts => @bank_accounts }
13 |
--------------------------------------------------------------------------------
/app/views/devise/confirmations/new.html.erb:
--------------------------------------------------------------------------------
1 | <%= devise_error_messages! %>
2 |
3 | <%= t(:resend_confirmation) %>
4 |
5 | <%= form_for(resource, :as => resource_name, :url => confirmation_path(resource_name), :html => { :method => :post }) do |f| %>
6 |
7 | <%= f.label :email %>
8 | <%= f.text_field :email %>
9 |
10 |
11 |
12 | <%= f.submit t(:resend_confirmation), :class => "submit" %>
13 |
14 | <% end %>
15 |
16 | <%= render :partial => "devise/shared/links" %>
--------------------------------------------------------------------------------
/app/views/devise/mailer/confirmation_instructions.html.erb:
--------------------------------------------------------------------------------
1 | Welcome <%= @resource.email %>!
2 |
3 | You can confirm your account through the link below:
4 |
5 | <%= link_to 'Confirm my account', confirmation_url(@resource, :confirmation_token => @resource.confirmation_token) %>
6 |
--------------------------------------------------------------------------------
/app/views/devise/mailer/reset_password_instructions.html.erb:
--------------------------------------------------------------------------------
1 | Hello <%= @resource.email %>!
2 |
3 | Someone has requested a link to change your password, and you can do this through the link below.
4 |
5 | <%= link_to 'Change my password', edit_password_url(@resource, :reset_password_token => @resource.reset_password_token) %>
6 |
7 | If you didn't request this, please ignore this email.
8 | Your password won't change until you access the link above and create a new one.
9 |
--------------------------------------------------------------------------------
/app/views/devise/mailer/unlock_instructions.html.erb:
--------------------------------------------------------------------------------
1 | Hello <%= @resource.email %>!
2 |
3 | Your account has been locked due to an excessive amount of unsuccessful sign in attempts.
4 |
5 | Click the link below to unlock your account:
6 |
7 | <%= link_to 'Unlock my account', unlock_url(@resource, :unlock_token => @resource.unlock_token) %>
8 |
--------------------------------------------------------------------------------
/app/views/devise/passwords/edit.html.erb:
--------------------------------------------------------------------------------
1 | <%= devise_error_messages! %>
2 |
3 | <%= t(:change_password) %>
4 |
5 | <%= form_for(resource, :as => resource_name, :url => password_path(resource_name), :html => { :method => :put }) do |f| %>
6 |
7 | <%= f.label :password %>
8 | <%= f.password_field :password %>
9 |
10 |
11 |
12 | <%= f.label :password_confirmation %>
13 | <%= f.password_field :password_confirmation %>
14 |
15 |
16 | <%= f.hidden_field :reset_password_token %>
17 |
18 |
19 | <%= f.submit t(:submit), :class => "submit" %>
20 |
21 | <% end %>
22 |
--------------------------------------------------------------------------------
/app/views/devise/passwords/new.html.erb:
--------------------------------------------------------------------------------
1 | <%= devise_error_messages! %>
2 |
3 | <%= t(:password_forgotten) %>
4 |
5 | <%= form_for(resource, :as => resource_name, :url => password_path(resource_name), :html => { :method => :post }) do |f| %>
6 |
7 | <%= f.label :email %>
8 | <%= f.text_field :email %>
9 |
10 |
11 |
12 | <%= f.submit t(:submit), :class => "submit" %>
13 |
14 | <% end %>
15 |
16 | <%= render :partial => "devise/shared/links" %>
--------------------------------------------------------------------------------
/app/views/devise/sessions/new.html.haml:
--------------------------------------------------------------------------------
1 | %h1= t(".sign_in")
2 |
3 | = form_for(resource, :as => resource_name, :url => session_path(resource_name)) do |f|
4 | .form-field
5 | = f.label :name
6 | = f.text_field :name
7 | .explanation= t(:account_description)
8 |
9 | .form-field
10 | = f.label :password
11 | = f.password_field :password
12 | .explanation= link_to t(".password_explanation"), new_password_path(resource_name)
13 |
14 | .form-field
15 | = f.label :ga_otp
16 | = f.text_field :ga_otp, :class => "ga-otp"
17 | .explanation= t(".ga_otp_explanation")
18 |
19 | .form-field
20 | = f.label :yk_otp
21 | = f.text_field :yk_otp, :class => "yk-otp"
22 | .explanation= t(".yk_otp_explanation")
23 |
24 | .form-field
25 | = f.submit t(".sign_in"), :class => "submit"
26 |
27 | = render :partial => "devise/shared/links"
28 |
--------------------------------------------------------------------------------
/app/views/devise/shared/_links.html.erb:
--------------------------------------------------------------------------------
1 |
2 | <%- if devise_mapping.confirmable? && controller_name != 'confirmations' %>
3 | <%= link_to t(:didnt_receive_confirmation), new_confirmation_path(resource_name) %>
4 | <% end -%>
5 |
6 | <%- if devise_mapping.lockable? && resource_class.unlock_strategy_enabled?(:email) && controller_name != 'unlocks' %>
7 | <%= link_to t(:didnt_receive_unlock_instructions), new_unlock_path(resource_name) %>
8 | <% end -%>
9 |
10 |
--------------------------------------------------------------------------------
/app/views/devise/unlocks/new.html.haml:
--------------------------------------------------------------------------------
1 | %h2= t(".resend")
2 |
3 | = form_for(resource, :as => resource_name, :url => unlock_path(resource_name), :html => { :method => :post }) do |f|
4 | = devise_error_messages!
5 |
6 | .form-field
7 | = f.label :email
8 | = f.text_field :email
9 |
10 | .form-field
11 | = f.submit t(:submit), :class => "submit"
12 |
13 | = render :partial => "devise/shared/links"
--------------------------------------------------------------------------------
/app/views/informations/_what_is_bitcoin.de.html.erb:
--------------------------------------------------------------------------------
1 | Was ist Bitcoin?
2 |
3 | Bitcoin ist eine digitale Peer-to-Peer Währung. Peer-to-Peer bedeutet, dass es keine zentrale
4 | Authorität gibt die neues Geld ausgibt oder Transaktionen überwacht. Stattdessen werden diese
5 | Aufgaben gemeinsam durch die Teilnehmer des Netzwerks durchgeführt.
6 | Das hat folgende Vorteile:
7 |
8 |
9 | Bitcoins können einfach über das Internet verschickt werden ohne Dienstleistern vertrauen
10 | zu müssen.
11 |
12 |
13 | Transaktionen können nicht widerrufen werden.
14 |
15 |
16 | Sie sind sicher vor möglichen Krisen, die durch das partielle Reservesystem und
17 | Zentralbanken verursacht werden können. Die begrenzte Steigerung der Geldmenge im Bitcoin-System
18 | wird gerecht (nach Leistung des Prozessors) auf das Netzwerk verteilt und nicht nur
19 | durch Banken.
20 |
21 |
22 | Weitere Erläuterungen können sie auf <%= link_to "bitcoin.org", "http://bitcoin.org" %> finden.
23 |
24 |
--------------------------------------------------------------------------------
/app/views/informations/_what_is_bitcoin.en.html.erb:
--------------------------------------------------------------------------------
1 | What is Bitcoin?
2 |
3 | Bitcoin is a peer-to-peer digital currency. Peer-to-peer means that there is no central authority to issue new money or keep track of transactions. Instead, these tasks are managed collectively by the nodes of the network. Advantages:
4 |
5 |
6 | Bitcoins can be sent easily through the Internet, without having to trust middlemen.
7 |
8 |
9 | Transactions are designed to be irreversible.
10 |
11 |
12 | Be safe from instability caused by fractional reserve banking and central banks. The limited inflation of the Bitcoin system’s money supply is distributed evenly (by CPU power) throughout the network, not monopolized by banks.
13 |
14 |
15 | More detailed explanations can be found at <%= link_to "bitcoin.org", "http://bitcoin.org" %> .
16 |
17 |
--------------------------------------------------------------------------------
/app/views/informations/_what_is_bitcoin.fr.html.erb:
--------------------------------------------------------------------------------
1 | Que sont les Bitcoins ?
2 |
3 | Bitcoin est une monnaie électronique décentralisée. Il n'y a pas d'autorité central régulant la monnaie, son émission et le suivi des transactions sont gérées collectivement par tous les noeuds du réseau. Avantages :
4 |
5 |
6 | Les bitcoins peuvent-être transférés facilement via Internet, sans intermédiaire.
7 |
8 |
9 | Les transactions sont irréversibles.
10 |
11 |
12 | Il n'y a pas d'insécurité monétaire causée par l'émission de monnaie par les banques centrales. L'inflation limitée et bornée de la masse monétaire est distribuée à travers tout le réseau et non monopolisée par le système bancaire.
13 |
14 |
15 | Plus d'informations : <%= link_to "bitcoin.org", "http://bitcoin.org" %> .
16 |
17 |
--------------------------------------------------------------------------------
/app/views/informations/economy.html.erb:
--------------------------------------------------------------------------------
1 | <%= t :economy_title %>
2 | <%= t :how_many_generated %>
3 | <%= t :generated_coins_html, :count=>(number_to_currency (Bitcoin::Client.instance.get_block_count * 50), :precision => 0, :unit => '') %>
--------------------------------------------------------------------------------
/app/views/informations/faq.html.erb:
--------------------------------------------------------------------------------
1 |
2 |
<%= t :faq_title %>
3 |
4 | <%= render :partial => "what_is_bitcoin" %>
5 |
6 |
7 |
--------------------------------------------------------------------------------
/app/views/informations/support.html.haml:
--------------------------------------------------------------------------------
1 | %h1= t(".contact")
2 | %p= t(".contact_description_html", :email => "support@bitcoin-central.net")
3 |
4 | %h1= t("activerecord.models.ticket.other")
5 |
6 | - if current_user
7 | %p
8 | = t(".your_tickets", :count => @tickets.pending.count)
9 | %p
10 | = link_to t(".open_a_ticket"), new_user_ticket_path
11 | - unless @tickets.blank?
12 | = " | "
13 | = link_to t(".view_tickets"), user_tickets_path
14 |
15 | - else
16 | = t(".please_sign_in")
17 |
--------------------------------------------------------------------------------
/app/views/invoices/index.html.haml:
--------------------------------------------------------------------------------
1 | = creation_link :invoice, t(".create")
2 |
3 | %h1= t("activerecord.models.invoice.other")
4 |
5 | %table.default
6 | %tr
7 | %th= t("activerecord.attributes.invoice.reference")
8 | %th= t("activerecord.attributes.invoice.state")
9 | %th= t("activerecord.attributes.invoice.paid_at")
10 | %th= t("activerecord.attributes.invoice.amount")
11 | %th.auto-sized
12 |
13 | - unless @invoices.blank?
14 | - @invoices.each do |invoice|
15 | %tr{ :class => cycle('even', 'odd') }
16 | %td= invoice.reference
17 | %td= invoice_state(invoice.state)
18 | %td= !invoice.pending? ? l(invoice.paid_at) : "N/A"
19 | %td.amount= number_to_bitcoins invoice.amount
20 | %td.auto-sized
21 | = invoice_delete(invoice)
22 | = invoice_details(invoice)
23 | - else
24 | = render :partial => "layouts/no_data"
25 |
26 | = will_paginate(@invoices)
--------------------------------------------------------------------------------
/app/views/invoices/new.html.haml:
--------------------------------------------------------------------------------
1 | %h1= t(".create_invoice")
2 |
3 | = form_for @invoice do |f|
4 | = errors_for @invoice, :message => "invoices.new.error"
5 |
6 | .form-field
7 | = f.label :merchant_reference
8 | = f.text_field :merchant_reference
9 |
10 | .form-field
11 | = f.label :amount
12 | = f.text_field :amount, :class => "amount"
13 | .explanation= t(".amount_explanation")
14 |
15 | .form-field
16 | = f.label :merchant_memo
17 | = f.text_area :merchant_memo, :rows => 5
18 |
19 | .form-field
20 | = f.label :callback_url
21 | = f.text_field :callback_url
22 | .explanation= t(".callback_url_explanation")
23 |
24 | .form-field
25 | = f.label :item_url
26 | = f.text_field :item_url
27 | .explanation= t(".item_url_explanation")
28 |
29 | .form-field
30 | = f.submit t(".submit"), :class => 'submit'
--------------------------------------------------------------------------------
/app/views/invoices/show.html.haml:
--------------------------------------------------------------------------------
1 | = auto_refresh_if_necessary(@invoice)
2 |
3 | %h1= t(".details")
4 |
5 | %table.default.details
6 | %tr
7 | %th= t(".payee")
8 | %td.fixed= @invoice.user.name
9 |
10 | %tr
11 | %th= t("activerecord.attributes.invoice.reference")
12 | %td.fixed= @invoice.reference
13 |
14 | - unless @invoice.merchant_reference.blank?
15 | %tr
16 | %th= t("activerecord.attributes.invoice.merchant_reference")
17 | %td.fixed= @invoice.merchant_reference
18 |
19 | %tr
20 | %th= t("activerecord.attributes.invoice.amount")
21 | %td.amount= number_to_bitcoins @invoice.amount
22 |
23 | %tr
24 | %th= t("activerecord.attributes.invoice.state")
25 | %td= invoice_state(@invoice.state, :icon => true)
26 |
27 | - if @invoice.paid_at
28 | %tr
29 | %th= t("activerecord.attributes.invoice.paid_at")
30 | %td= l(@invoice.paid_at)
31 |
32 | - unless @invoice.paid?
33 | %tr
34 | %th= t("activerecord.attributes.invoice.payment_address")
35 | %td.bitcoin-address= @invoice.payment_address
36 |
37 | - unless @invoice.merchant_memo.blank?
38 | %tr
39 | %th= t("activerecord.attributes.invoice.merchant_memo")
40 | %td
41 | %pre= @invoice.merchant_memo
42 |
43 | - if @invoice.item_url && !@invoice.pending?
44 | %br
45 | .invoice-item-link
46 | = link_to(t(".return_to_item"), @invoice.item_url)
47 |
48 | - if @invoice.pending?
49 | %br
50 | .payment-explanations= t(".payment-explanations")
--------------------------------------------------------------------------------
/app/views/layouts/_announcements.html.haml:
--------------------------------------------------------------------------------
1 | - unless @announcements.blank?
2 | .announcements
3 | %ul
4 | - @announcements.each do |a|
5 | %li= a.content.html_safe
6 |
7 |
--------------------------------------------------------------------------------
/app/views/layouts/_errors.html.erb:
--------------------------------------------------------------------------------
1 | <% if model.errors.any? %>
2 |
3 |
4 | <% if translated_message %>
5 | <%= translated_message %>
6 | <% else %>
7 | <%= t message, :count => model.errors.count %>
8 | <% end %>
9 |
10 |
11 |
12 | <% model.errors.full_messages.each do |msg| %>
13 | <%= msg %>
14 | <% end %>
15 |
16 |
17 | <% end %>
--------------------------------------------------------------------------------
/app/views/layouts/_flash.html.erb:
--------------------------------------------------------------------------------
1 | <% if flash %>
2 | <% unless [:notice, :alert, :error].map{ |i| flash[i].blank? }.all? %>
3 |
4 | <% unless flash[:error].blank? %>
5 |
6 | <%= flash[:error].html_safe %>
7 |
8 | <% end %>
9 |
10 | <% unless flash[:alert].blank? %>
11 |
12 | <%= flash[:alert].html_safe %>
13 |
14 | <% end %>
15 |
16 | <% unless flash[:notice].blank? %>
17 |
18 | <%= flash[:notice].html_safe %>
19 |
20 | <% end %>
21 |
22 | <% end %>
23 | <% end %>
--------------------------------------------------------------------------------
/app/views/layouts/_footer.html.haml:
--------------------------------------------------------------------------------
1 | #footer
2 | = t(:footer_html, :adress => BitcoinBank::Donations)
3 | = link_to qrcode_image_path(BitcoinBank::Donations), :class => "address-qrcode" do
4 | = image_tag "qrcode.png"
--------------------------------------------------------------------------------
/app/views/layouts/_google_analytics.html.erb:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/app/views/layouts/_icons.html.haml:
--------------------------------------------------------------------------------
1 | %link{ :rel => "apple-touch-icon-precomposed", :sizes => "114x114", :href => "assets/icons/favicon114-precomposed.png" }
2 | %link{ :rel => "apple-touch-icon-precomposed", :sizes => "72x72", :href => "assets/icons/favicon72-precomposed.png" }
3 | %link{ :rel => "apple-touch-icon-precomposed", :sizes => "57x57", :href => "assets/icons/favicon57-precomposed.png" }
4 |
5 | %link{ :rel => "icon", :type => "image/png", :href => "assets/icons/favicon32.png" }
6 |
--------------------------------------------------------------------------------
/app/views/layouts/_locale_select.html.erb:
--------------------------------------------------------------------------------
1 |
2 | <% I18n.available_locales.sort{ |a,b| a.to_s <=> b.to_s }.each do |locale| %>
3 | <%= link_to(
4 | image_tag("flags/#{locale}.png",
5 | :title => I18n::Locales[locale],
6 | :alt => I18n::Locales[locale]
7 | ),
8 | locale_switch_link(locale, request.url)
9 | )
10 | %>
11 | <% end %>
12 |
13 |
--------------------------------------------------------------------------------
/app/views/layouts/_no_data.html.haml:
--------------------------------------------------------------------------------
1 | %tr
2 | %td.no-records{ :colspan => 999 }
3 | = t(:no_data)
--------------------------------------------------------------------------------
/app/views/layouts/_open_graph.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/app/views/layouts/_user_informations.html.haml:
--------------------------------------------------------------------------------
1 | #user-information
2 | %p
3 | - if current_user
4 | %p.identification
5 | = t(".signed_in_as")
6 | = link_to @current_user.name, edit_user_path
7 | = "-"
8 | = link_to t(".logout"), destroy_session_path(:user)
9 | %span#countdown{ :data => { "delay" => Devise.timeout_in.to_i, "logout-path" => destroy_user_session_path } }
10 |
11 | %p{ :title => t(".address_tip") }
12 | %span.address-label
13 | = t(".your_address")
14 | = ":"
15 |
16 | %span#last-bitcoin-address.bitcoin-address
17 | = @current_user.bitcoin_address
18 | = link_to qrcode_image_path(current_user.bitcoin_address), :class => "address-qrcode" do
19 | = image_tag "qrcode.png"
20 |
21 | - else
22 | = link_to t(".sign_up"), new_registration_path(:user)
23 | = "|"
24 | = link_to t(".sign_in"), new_session_path(:user)
25 |
26 |
--------------------------------------------------------------------------------
/app/views/layouts/mailers.html.haml:
--------------------------------------------------------------------------------
1 | !!! XML
2 | !!!
3 |
4 | %html
5 | %head
6 | %title= t(:website_title)
7 | %style{ :type => "text/css" }
8 | table th, table td { text-align: left }
9 | %body
10 | .content
11 | = link_to image_tag(attachments['bitcoin.png'].url), "https://bitcoin-central.net"
12 | %p= yield
13 |
--------------------------------------------------------------------------------
/app/views/layouts/static.html.haml:
--------------------------------------------------------------------------------
1 | !!! XML
2 | !!!
3 |
4 | %html
5 | %head
6 | %title= t(:website_title)
7 | %link{ :rel => 'stylesheet', :media => 'screen', :href => '/stylesheets/reset.css', type => 'text/css' }
8 | %link{ :rel => 'stylesheet', :media => 'screen', :href => '/stylesheets/application.css', type => 'text/css' }
9 |
10 | %body
11 | #content
12 | #right-content{ :style => "margin-top:4em; width:50%" }
13 | %h1#main-title= link_to(content_tag(:span, t(:website_title)), "/")
14 | = yield
15 |
16 | / This is used to force the container to stretch
17 | %div{ :style => "clear:both" }
18 |
19 | = render :partial => 'layouts/footer'
--------------------------------------------------------------------------------
/app/views/registrations/edit.html.erb:
--------------------------------------------------------------------------------
1 | Edit <%= resource_name.to_s.humanize %>
2 |
3 | <%= form_for(resource, :as => resource_name, :url => registration_path(resource_name), :html => { :method => :put }) do |f| %>
4 | <%= devise_error_messages! %>
5 |
6 | <%= f.label :email %>
7 | <%= f.text_field :email %>
8 |
9 | <%= f.label :password %> (leave blank if you don't want to change it)
10 | <%= f.password_field :password %>
11 |
12 | <%= f.label :password_confirmation %>
13 | <%= f.password_field :password_confirmation %>
14 |
15 | <%= f.label :current_password %> (we need your current password to confirm your changes)
16 | <%= f.password_field :current_password %>
17 |
18 | <%= f.submit "Update" %>
19 | <% end %>
20 |
21 | Cancel my account
22 |
23 | Unhappy? <%= link_to "Cancel my account", registration_path(resource_name), :confirm => "Are you sure?", :method => :delete %>.
24 |
25 | <%= link_to "Back", :back %>
26 |
--------------------------------------------------------------------------------
/app/views/static/404.html.haml:
--------------------------------------------------------------------------------
1 | %h1 HTTP 404 - The requested resource could not be found
2 | %p You may have mistyped the address or the resource may have moved.
--------------------------------------------------------------------------------
/app/views/static/500.html.haml:
--------------------------------------------------------------------------------
1 | %h1 HTTP 500 - Internal server error
2 | %p An error has occurred, we apologize for the inconvenience.
3 | %p We have been notified and will take a look shortly.
--------------------------------------------------------------------------------
/app/views/static/maintenance.html.haml:
--------------------------------------------------------------------------------
1 | %h1 Bitcoin-Central.net is currently down for maintenance
2 | %p
3 | We're working hard to get it back online as soon as possible. We apologize for the inconvenience.
--------------------------------------------------------------------------------
/app/views/static_pages/show.html.haml:
--------------------------------------------------------------------------------
1 | = @static_page.contents.html_safe
2 | %br
3 | .last-update= t(".last_modification_at", :updated_at => l(@static_page.updated_at))
4 |
--------------------------------------------------------------------------------
/app/views/ticket_mailer/ticket_notification.html.erb:
--------------------------------------------------------------------------------
1 | <%= link_to t("emails.tickets.view_details_of", :title => @ticket.title), user_ticket_url(@ticket) %>
--------------------------------------------------------------------------------
/app/views/ticket_mailer/ticket_notification.text.erb:
--------------------------------------------------------------------------------
1 | <%= t("emails.tickets.view_details_of", :title => @ticket.title) %> : <%= user_ticket_url(@ticket) %>
--------------------------------------------------------------------------------
/app/views/tickets/_ticket.html.haml:
--------------------------------------------------------------------------------
1 | .ticket
2 | .ticket-buttons
3 | - if ticket.closed?
4 | = form_tag reopen_user_ticket_path(ticket), :method => :post do
5 | .form-field
6 | = submit_tag t(".reopen"), :class => 'submit reopen'
7 | - else
8 | = form_tag close_user_ticket_path(ticket), :method => :post do
9 | .form-field
10 | = submit_tag t(".close"), :class => 'submit close'
11 |
12 | %h2= ticket.title
13 |
14 | %div
15 | %strong= "#{t("activerecord.attributes.ticket.state")} : "
16 | = t("activerecord.extra.ticket.states.#{ticket.state}")
17 | .ticket-comment
18 | = t(".someone_wrote", :who => (ticket.user == current_user ? t(".you") : ticket.user.name), :when => distance_of_time_in_words_to_now(ticket.created_at.utc))
19 | %div= ticket.description
20 |
21 | - ticket.comments.each do |comment|
22 | .ticket-comment
23 | = t(".someone_wrote", :who => (comment.user == current_user ? t(".you") : comment.user.name), :when => distance_of_time_in_words_to_now(comment.created_at))
24 |
25 | /Ugly anchor
26 | %a{ :name => "comment-#{comment.id}"}
27 | %div= comment.contents
28 |
29 | - unless ticket.closed?
30 | %br
31 |
32 | = form_for ticket.comments.new, :url => user_ticket_comments_path(ticket) do |f|
33 | .form-field
34 | = f.text_area :contents, :rows => 5
35 |
36 | .form-field
37 | = f.submit t(".add_comment"), :class => 'submit'
38 |
--------------------------------------------------------------------------------
/app/views/tickets/index.html.haml:
--------------------------------------------------------------------------------
1 | %h1= t(".your_tickets")
2 |
3 | - if @tickets.blank?
4 | = t(".no_tickets_found")
5 | - else
6 | = render :partial => 'ticket', :collection => @tickets
--------------------------------------------------------------------------------
/app/views/tickets/new.html.haml:
--------------------------------------------------------------------------------
1 | %h1= t(".title")
2 |
3 | = form_for @ticket, :url => user_tickets_path do |f|
4 | = errors_for @ticket, :message => "tickets.new.error"
5 |
6 | .form-field
7 | = f.label :title
8 | = f.text_field :title
9 |
10 | .form-field
11 | = f.label :description
12 | = f.text_area :description, :rows => 6
13 | .explanation= t(".description_explanation")
14 |
15 | .form-field
16 | = f.submit t(".submit"), :class => 'submit'
17 |
--------------------------------------------------------------------------------
/app/views/tickets/show.html.haml:
--------------------------------------------------------------------------------
1 | = render :partial => "ticket", :object => @ticket
--------------------------------------------------------------------------------
/app/views/trade_orders/_detailed_list.html.haml:
--------------------------------------------------------------------------------
1 | %table#trade-orders.default
2 | %tr
3 | %th= t("activerecord.attributes.trade_order.updated_at")
4 | %th= t("activerecord.attributes.trade_order.category")
5 | %th= t("activerecord.attributes.trade_order.type")
6 | %th= t("activerecord.attributes.trade_order.amount")
7 | %th= t("activerecord.attributes.trade_order.ppc")
8 | %th= t("activerecord.attributes.trade_order.total")
9 | %th.auto-sized
10 | %th.auto-sized
11 | %th.auto-sized
12 | %th.auto-sized
13 |
14 | - unless trade_orders.blank?
15 | - trade_orders.each do |to|
16 | %tr{ :class => cycle('even', 'odd', :name => 'trade_orders') }
17 | %td= l(to.updated_at)
18 | %td= t(".#{to.category}")
19 | %td= t(".#{to.type.gsub(/Order/, "").downcase}")
20 | %td.amount= number_to_bitcoins to.amount, :precision => 4
21 | - if to.is_a?(LimitOrder)
22 | %td.amount= format_amount(to.ppc, to[:currency], 5)
23 | %td.amount= format_amount(to.ppc * to.amount, to[:currency], 4)
24 | - else
25 | %td= t(".market_order")
26 | %td= t(".market_order")
27 | %td.auto-sized= dark_pool_icon_for(to)
28 | %td.auto-sized= currency_icon_for(to[:currency])
29 | %td.auto-sized= activate_link_for(to) if to.activable?
30 | %td.auto-sized= delete_link_for(to)
31 |
32 | - reset_cycle 'trade_orders'
33 | - else
34 | = render :partial => "layouts/no_data"
--------------------------------------------------------------------------------
/app/views/trade_orders/_list.html.haml:
--------------------------------------------------------------------------------
1 | %div{ :id => "#{type}-orders", :class => "order-book" }
2 | %h2= t(".#{title}")
3 | %table.default
4 | %tr
5 | %th= t(".price")
6 | %th= t(".amount")
7 | %th= t(".total")
8 | %th.auto-sized
9 |
10 | - unless orders.blank?
11 | - orders.each do |to|
12 | %tr{ :class => cycle('even', 'odd') }
13 | - if to.ppc
14 | %td.amount= format_amount(to[:price], to[:currency], 4)
15 | - else
16 | %td= t(".market_order")
17 | %td.amount= number_to_bitcoins to[:amount], :precision => 3
18 | - if to.ppc
19 | %td.amount= format_amount(to[:ppc]*to[:amount], to[:currency], 3)
20 | - else
21 | %td= t(".market_order")
22 | %td.auto-sized= currency_icon_for(to.currency)
23 | - else
24 | = render :partial => "layouts/no_data"
25 |
--------------------------------------------------------------------------------
/app/views/trade_orders/book.html.haml:
--------------------------------------------------------------------------------
1 | = form_tag order_book_path, :method => :get do
2 | .form-field
3 | = label_tag :currency, t("activerecord.attributes.trade_order.currency")
4 | = select_tag(:currency, currency_as_options(@currency, :exclude => :btc), :id => "currency-select" )
5 | .form-field#order-book-filter-submit
6 | = submit_tag 'Filter', :class => "submit", :class => "submit"
7 | %script{ :type => "text/javascript" }
8 | $('#order-book-filter-submit').hide()
9 | $('#currency-select').change(function(e) { $(e.target).parents('form').submit() })
10 |
11 | %div{ :style => "clear:both" }
12 |
13 | = render :partial => "list", :locals => { :type => "purchase", :title => :bids, :orders => @purchases }
14 |
15 | = render :partial => "list", :locals => { :type => "sale", :title => :asks, :orders => @sales }
16 |
--------------------------------------------------------------------------------
/app/views/trade_orders/book.xml.builder:
--------------------------------------------------------------------------------
1 | xml.instruct!
2 |
3 | xml.bids do
4 | @purchases.each do |to|
5 | xml.bid :currency => to[:currency],
6 | :price => "QWRWER",
7 | :amount => to[:amount],
8 | :timestamp => to[:created_at].to_i
9 | end
10 | end
11 |
12 | xml.asks do
13 | @sales.each do |to|
14 | xml.ask :currency => to[:currency],
15 | :price => to[:price].to_d,
16 | :amount => to[:amount],
17 | :timestamp => to[:created_at].to_i
18 | end
19 | end
20 |
--------------------------------------------------------------------------------
/app/views/trade_orders/index.html.haml:
--------------------------------------------------------------------------------
1 | = creation_link :account_trade_order, t(".create")
2 |
3 | %h1= t(".active_orders", :count => @trade_orders.active.count)
4 | = render :partial => "trade_orders/detailed_list", :locals => { :trade_orders => @trade_orders.active }
5 |
6 | %h1= t(".inactive_orders", :count => @trade_orders.inactive.count)
7 | = render :partial => "trade_orders/detailed_list", :locals => { :trade_orders => @trade_orders.inactive }
--------------------------------------------------------------------------------
/app/views/trades/all_trades.json.erb:
--------------------------------------------------------------------------------
1 | [
2 | <%= @trades.map { |t| "{\"date\":#{t.created_at.to_i},\"price\":#{t.ppc},\"amount\":#{t.traded_btc},\"currency\":\"#{t.currency}\"}" }.join(",\n").html_safe %>
3 | ]
--------------------------------------------------------------------------------
/app/views/trades/all_trades.xml.builder:
--------------------------------------------------------------------------------
1 | xml.instruct!
2 |
3 | xml.trades do
4 | @trades.each do |t|
5 | xml.trade :date => t.created_at.to_i,
6 | :price => t.ppc,
7 | :amount => t.traded_btc,
8 | :currency => t.currency
9 | end
10 | end
--------------------------------------------------------------------------------
/app/views/trades/index.html.haml:
--------------------------------------------------------------------------------
1 | %h1= t(".title")
2 |
3 | %table#trade-history.default
4 | %tr
5 | %th= t("activerecord.attributes.trade.created_at")
6 | %th= t("activerecord.attributes.trade.type")
7 | %th= t("activerecord.attributes.trade.amount")
8 | %th= t("activerecord.attributes.trade.price")
9 | %th= t("activerecord.attributes.trade.total")
10 | %th.auto-sized
11 |
12 | - unless @trades.blank?
13 | - @trades.each do |trade|
14 | %tr{ :class => cycle('even', 'odd') }
15 | %td= l trade.created_at
16 | %td= type_for_trade(trade)
17 | %td.amount= number_to_bitcoins trade.traded_btc, :precision => 4
18 | %td.amount= format_amount(trade.ppc, trade.currency, 5)
19 | %td.amount= format_amount(trade.traded_currency, trade.currency, 4)
20 | %td.auto-sized= currency_icon_for(trade.currency)
21 |
22 | - else
23 | = render :partial => "layouts/no_data"
24 |
25 | = will_paginate(@trades)
--------------------------------------------------------------------------------
/app/views/trades/ticker.json.erb:
--------------------------------------------------------------------------------
1 | <%= @ticker.to_json.html_safe %>
2 |
--------------------------------------------------------------------------------
/app/views/trades/ticker.xml.builder:
--------------------------------------------------------------------------------
1 | xml.instruct!
2 |
3 | xml.ticker :at => DateTime.now.to_i do
4 | xml.high @ticker[:high]
5 | xml.low @ticker[:low]
6 | xml.buy @ticker[:buy]
7 | xml.sell @ticker[:sell]
8 | xml.volume @ticker[:volume]
9 | if @ticker[:last_trade]
10 | xml.tag! "last-trade", :at => @ticker[:last_trade][:at],
11 | :price => @ticker[:last_trade][:price]
12 | end
13 | end
--------------------------------------------------------------------------------
/app/views/transfers/index.html.haml:
--------------------------------------------------------------------------------
1 | %h1= t :account_history_title
2 |
3 | %table#history.default
4 | %tr
5 | %th Date
6 | %th= t :currency
7 | %th= t :amount
8 | %th.auto-sized
9 |
10 | - unless @transfers.blank?
11 | - @transfers.each do |transfer|
12 | %tr{ :class => cycle('even', 'odd') }
13 | %td= l transfer.created_at
14 | %td
15 | = currency_icon_for(transfer.currency)
16 | = transfer.currency
17 | %td.amount
18 | %span{ :class => color_for(transfer), :title => confirmation_tooltip_for(transfer) }
19 | = "#{transfer.amount > 0 ? "+" : "-"} #{number_to_currency transfer.amount.abs, :unit => ""}"
20 | %td.auto-sized
21 | = transfer_details(transfer)
22 |
23 | - else
24 | = render :partial => "layouts/no_data"
25 |
26 | = will_paginate(@transfers)
--------------------------------------------------------------------------------
/app/views/transfers/index.xml.builder:
--------------------------------------------------------------------------------
1 | xml.instruct!
2 |
3 | xml.transfers do
4 | @transfers.each do |transfer|
5 | xml.transfer :at => transfer.created_at.to_i,
6 | :currency => transfer.currency,
7 | :amount => transfer.amount,
8 | :confirmed => transfer.confirmed?
9 | end
10 | end
--------------------------------------------------------------------------------
/app/views/user_mailer/invoice_payment_notification.html.haml:
--------------------------------------------------------------------------------
1 | %p= t("emails.invoice_payment_notification.body", :amount => @invoice.amount, :reference => @invoice.reference)
--------------------------------------------------------------------------------
/app/views/user_mailer/invoice_payment_notification.text.haml:
--------------------------------------------------------------------------------
1 | = t("emails.invoice_payment_notification.body", :amount => @invoice.amount, :reference => @invoice.reference)
--------------------------------------------------------------------------------
/app/views/user_mailer/registration_confirmation.html.erb:
--------------------------------------------------------------------------------
1 |
2 | <%= t :thanks_for_registering %>
3 |
4 |
5 |
6 | <%= t :your_account_id_is, :account_id => @user.name %>
7 |
8 |
--------------------------------------------------------------------------------
/app/views/user_mailer/registration_confirmation.text.erb:
--------------------------------------------------------------------------------
1 | <%= t :thanks_for_registering %>
2 | <%= t :your_account_id_is, :account_id => @user.name %>
--------------------------------------------------------------------------------
/app/views/user_mailer/trade_notification.html.haml:
--------------------------------------------------------------------------------
1 | = t("emails.trade_notification.subject")
2 |
3 | - unless @sales.blank?
4 | %h3= t("emails.trade_notification.sold")
5 | %ul
6 | - @sales.each do |s|
7 | %li= t("emails.trade_notification.traded", :traded_btc => s.traded_btc, :ppc => s.ppc, :currency => s.currency, :traded_currency => s.traded_currency)
8 |
9 |
10 |
11 | - unless @purchases.blank?
12 | %h3= t("emails.trade_notification.bought")
13 | %ul
14 | - @purchases.each do |p|
15 | %li= t("emails.trade_notification.traded", :traded_btc => p.traded_btc, :ppc => p.ppc, :currency => p.currency, :traded_currency => p.traded_currency)
16 |
--------------------------------------------------------------------------------
/app/views/user_mailer/trade_notification.text.erb:
--------------------------------------------------------------------------------
1 | <%= t("emails.trade_notification.subject") %>
2 |
3 | <% unless @sales.blank? %>
4 | <%= t("emails.trade_notification.sold") %>
5 | <% @sales.each do |s| %>
6 | - <%= t("emails.trade_notification.traded", :traded_btc => s.traded_btc, :ppc => s.ppc, :currency => s.currency, :traded_currency => s.traded_currency) %>
7 | <% end %>
8 | <% end %>
9 |
10 | <% unless @purchases.blank? %>
11 | <%= t("emails.trade_notification.bought") %>
12 | <% @purchases.each do |p| %>
13 | - <%= t("emails.trade_notification.traded", :traded_btc => p.traded_btc, :ppc => p.ppc, :currency => p.currency, :traded_currency => p.traded_currency) %>
14 | <% end %>
15 | <% end %>
16 |
--------------------------------------------------------------------------------
/app/views/user_mailer/withdrawal_processed_notification.html.haml:
--------------------------------------------------------------------------------
1 | %p= t("emails.withdrawal_processed_notification.body")
2 |
3 | %table
4 | %tr
5 | %th= "#{t("activerecord.models.bank_account.one")} : "
6 | %td= @withdrawal.bank_account.iban
7 | %tr
8 | %th= "#{t("activerecord.attributes.transfer.amount")} : "
9 | %td= "#{@withdrawal.amount} #{@withdrawal.currency}"
10 |
--------------------------------------------------------------------------------
/app/views/user_mailer/withdrawal_processed_notification.text.haml:
--------------------------------------------------------------------------------
1 | = t("emails.withdrawal_processed_notification.body")
2 |
3 | = "#{t("activerecord.models.bank_account.one")} : "
4 | = @withdrawal.bank_account.iban
5 |
6 | = "#{t("activerecord.attributes.account_operation.amount")} : "
7 | = "#{@withdrawal.amount} #{@withdrawal.currency}"
8 |
--------------------------------------------------------------------------------
/app/views/users/_password_change_form.html.haml:
--------------------------------------------------------------------------------
1 | %fieldset
2 | %legend= t(".change_password")
3 | .form-field
4 | = f.label :current_password
5 | = f.password_field :current_password
6 |
7 | .form-field
8 | = f.label :password
9 | = f.password_field :password, :value => ""
10 |
11 | .form-field
12 | = f.label :password_confirmation
13 | = f.password_field :password_confirmation
14 |
15 | .form-field
16 | = f.submit t(".submit"), :class => 'submit'
17 |
--------------------------------------------------------------------------------
/app/views/users/edit.html.haml:
--------------------------------------------------------------------------------
1 | %h1= t :account_details_title
2 |
3 | = render 'form'
4 |
5 | %br
6 |
7 | = form_for @user, :as => :user, :url => update_password_user_path do |f|
8 | = render :partial => 'password_change_form', :locals => { :f => f }
9 |
--------------------------------------------------------------------------------
/app/views/users/edit_password.html.haml:
--------------------------------------------------------------------------------
1 | = form_for @user, :as => :user, :url => update_password_user_path do |f|
2 | = errors_for @user, :message => "error_updating_password"
3 | = render :partial => 'password_change_form', :locals => { :f => f }
--------------------------------------------------------------------------------
/app/views/users/new.html.haml:
--------------------------------------------------------------------------------
1 | %h1= t :sign_up_for_account_title
2 |
3 | = render 'form'
4 |
--------------------------------------------------------------------------------
/app/views/yubikeys/index.html.haml:
--------------------------------------------------------------------------------
1 | %h1= t(".associate")
2 |
3 | = form_for @yubikey, :url => user_yubikeys_path(@yubikey) do |f|
4 | = errors_for @yubikey, :message => "yubikeys.index.error"
5 |
6 | .form-field
7 | = f.label :otp
8 | = f.text_field :otp, :class => "yk-otp"
9 | .explanation= t(".otp_explanation")
10 |
11 | %br
12 |
13 | %h1= t("activerecord.models.yubikey.other")
14 |
15 | %table.default
16 | %tr
17 | %th= t("activerecord.attributes.yubikey.key_id")
18 | %th= t("activerecord.attributes.yubikey.created_at")
19 | %th.auto-sized
20 |
21 | - unless @yubikeys.blank?
22 | - @yubikeys.each do |yubikey|
23 | %tr{ :class => cycle('even', 'odd') }
24 | %td.fixed= yubikey.key_id
25 | %td= l(yubikey.created_at, :format => :short)
26 | %td.auto-sized= yubikey_delete(yubikey)
27 | - else
28 | = render :partial => "layouts/no_data"
29 |
30 |
--------------------------------------------------------------------------------
/config.ru:
--------------------------------------------------------------------------------
1 | # This file is used by Rack-based servers to start the application.
2 |
3 | require ::File.expand_path('../config/environment', __FILE__)
4 | run BitcoinBank::Application
5 |
--------------------------------------------------------------------------------
/config/application.rb:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 | require File.expand_path('../boot', __FILE__)
3 |
4 | require 'rails/all'
5 |
6 | if defined?(Bundler)
7 | Bundler.require(*Rails.groups(:assets => %w(development, test)))
8 | Bundler.require(:default, Rails.env)
9 | end
10 |
11 | module BitcoinBank
12 | class Application < Rails::Application
13 | I18n.const_set :Locales, {
14 | :en => "English",
15 | :fr => "Français"
16 | }
17 |
18 | config.i18n.default_locale = :en
19 |
20 | config.i18n.available_locales = I18n::Locales.keys
21 |
22 | config.i18n.load_path += Dir[Rails.root.join('config', 'locales', '**', '*.yml')]
23 |
24 |
25 | config.encoding = "utf-8"
26 | config.filter_parameters += [:password]
27 | config.action_dispatch.session_store = :active_record_store
28 |
29 | config.autoload_paths << File.join(config.root, "lib")
30 | config.autoload_paths << File.join(config.root, "lib", "bitcoin")
31 | config.autoload_paths << File.join(config.root, "lib", "validators")
32 |
33 | config.assets.enabled = true
34 | config.assets.version = '1.0'
35 |
36 | Haml::Template.options[:ugly] = true
37 | end
38 | end
39 |
--------------------------------------------------------------------------------
/config/backup.yml:
--------------------------------------------------------------------------------
1 | recipient: backup@bitcoin-central.net
2 | ftp_servers:
3 | server1:
4 | host: ftp.domain.tld
5 | username: user
6 | password: pass
7 | server2:
8 | host: ftp2.domain.tld
9 | username: user
10 | password: pass
--------------------------------------------------------------------------------
/config/banks.yml:
--------------------------------------------------------------------------------
1 | development:
2 | bic: XXXX
3 | iban: XX99 XXXX 0000 0000 0000 0
4 | account_holder: MyCompany LLC
5 | account_holder_address: "Some street\nSome country"
6 | bank_address: "Some other street\nSome other country"
7 | bank: Some bank
8 |
9 | test:
10 | bic: XXXX
11 | iban: XX99 XXXX 0000 0000 0000 0
12 | account_holder: MyCompany LLC
13 | account_holder_address: "Some street\nSome country"
14 | bank_address: "Some other street\nSome other country"
15 | bank: Some bank
16 |
--------------------------------------------------------------------------------
/config/bitcoin.yml:
--------------------------------------------------------------------------------
1 | development:
2 | username: bitcoin-admin
3 | password: 5MLpeupM46
4 | url: http://localhost:8332/
5 | donations: 1FXWhKPChEcUnSEoFQ3DGzxKe44MDbatz
6 |
7 | test:
8 | username: bitcoin-admin
9 | password: 5MLpeupM46
10 | url: http://localhost:8332/
11 | donations: 1FXWhKPChEcUnSEoFQ3DGzxKe44MDbatz
12 |
--------------------------------------------------------------------------------
/config/boot.rb:
--------------------------------------------------------------------------------
1 | require 'rubygems'
2 |
3 | # Set up gems listed in the Gemfile.
4 | gemfile = File.expand_path('../../Gemfile', __FILE__)
5 | begin
6 | ENV['BUNDLE_GEMFILE'] = gemfile
7 | require 'bundler'
8 | Bundler.setup
9 | rescue Bundler::GemNotFound => e
10 | STDERR.puts e.message
11 | STDERR.puts "Try running `bundle install`."
12 | exit!
13 | end if File.exist?(gemfile)
14 |
--------------------------------------------------------------------------------
/config/database.yml:
--------------------------------------------------------------------------------
1 | development:
2 | adapter: mysql2
3 | encoding: utf8
4 | database: bitcoin-bank_development
5 | username: rails
6 | password: rails
7 |
8 | test:
9 | adapter: mysql2
10 | encoding: utf8
11 | database: bitcoin-bank_test
12 | username: rails
13 | password: rails
14 |
--------------------------------------------------------------------------------
/config/environment.rb:
--------------------------------------------------------------------------------
1 | # Load the rails application
2 | require File.expand_path('../application', __FILE__)
3 |
4 | # Initialize the rails application
5 | BitcoinBank::Application.initialize!
6 |
--------------------------------------------------------------------------------
/config/environments/development.rb:
--------------------------------------------------------------------------------
1 | BitcoinBank::Application.configure do
2 | # Settings specified here will take precedence over those in config/environment.rb
3 |
4 | # In the development environment your application's code is reloaded on
5 | # every request. This slows down response time but is perfect for development
6 | # since you don't have to restart the webserver when you make code changes.
7 | config.cache_classes = false
8 |
9 | # Log error messages when you accidentally call methods on nil.
10 | config.whiny_nils = true
11 |
12 | # Show full error reports and disable caching
13 | config.consider_all_requests_local = true
14 | config.action_controller.perform_caching = false
15 |
16 | # Don't care if the mailer can't send
17 | config.action_mailer.raise_delivery_errors = false
18 |
19 | # Print deprecation notices to the Rails logger
20 | config.active_support.deprecation = :log
21 |
22 | # Only use best-standards-support built into browsers
23 | config.action_dispatch.best_standards_support = :builtin
24 |
25 | # Uncomment this to test e-mails in development mode
26 | config.action_mailer.delivery_method = :sendmail
27 |
28 | # Comment this line if testing e-mails in development mode
29 | config.action_mailer.delivery_method = :test
30 |
31 | config.action_mailer.default_url_options = {
32 | :host => "development.bitcoin-central.net"
33 | }
34 |
35 | config.assets.debug = true
36 |
37 | # Used to broadcast invoices public URLs
38 | config.base_url = "http://lvh.me:3000/"
39 | end
40 |
41 |
--------------------------------------------------------------------------------
/config/environments/production.rb:
--------------------------------------------------------------------------------
1 | BitcoinBank::Application.configure do
2 | config.cache_classes = true
3 | config.consider_all_requests_local = false
4 | config.action_controller.perform_caching = true
5 | config.action_dispatch.x_sendfile_header = "X-Sendfile"
6 | config.i18n.fallbacks = true
7 | config.active_support.deprecation = :notify
8 | config.force_ssl = true
9 |
10 | config.action_mailer.delivery_method = :sendmail
11 | config.action_mailer.default_url_options = {
12 | :host => "bitcoin-central.net"
13 | }
14 |
15 | config.middleware.use ::ExceptionNotifier,
16 | :email_prefix => "[BC Exception] ",
17 | :sender_address => %w{no-reply@bitcoin-central.net},
18 | :exception_recipients => %w{support@bitcoin-central.net}
19 |
20 | # Used to broadcast invoices public URLs
21 | config.base_url = "https://bitcoin-central.net/"
22 |
23 | config.assets.compress = true
24 | config.assets.compile = false
25 | config.assets.digest = true
26 | config.serve_static_assets = false
27 | end
28 |
--------------------------------------------------------------------------------
/config/google_analytics.yml:
--------------------------------------------------------------------------------
1 | development:
2 | account: UA-XXXXXXXX-X
3 |
4 | test:
5 | account: UA-XXXXXXXX-X
6 |
--------------------------------------------------------------------------------
/config/initializers/action_mailer.rb:
--------------------------------------------------------------------------------
1 | module ActionMailerDefaults
2 | def mail_with_logo(args, &block)
3 | attachments.inline['bitcoin.png'] = File.read(File.join(Rails.root, "app", "assets", "images", "bitcoin.png"))
4 | mail_without_logo(args, &block)
5 | end
6 |
7 | def self.included(base)
8 | base.class_eval do
9 | default :from => "Bitcoin Central support "
10 | layout 'mailers'
11 | alias_method_chain :mail, :logo
12 | end
13 | end
14 | end
15 |
16 | class BitcoinCentralMailer < ActionMailer::Base
17 | include ActionMailerDefaults
18 | end
19 |
--------------------------------------------------------------------------------
/config/initializers/active_scaffold.rb:
--------------------------------------------------------------------------------
1 | ActiveScaffold.js_framework = :jquery
--------------------------------------------------------------------------------
/config/initializers/backtrace_silencers.rb:
--------------------------------------------------------------------------------
1 | # Be sure to restart your server when you modify this file.
2 |
3 | # You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces.
4 | # Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ }
5 |
6 | # You can also remove all the silencers if you're trying to debug a problem that might stem from framework code.
7 | # Rails.backtrace_cleaner.remove_silencers!
8 |
9 | Rails.backtrace_cleaner.add_silencer { |line| line =~ /config\/initializers\/transaction\.rb/ }
10 |
--------------------------------------------------------------------------------
/config/initializers/big_decimal.rb:
--------------------------------------------------------------------------------
1 | class BigDecimal
2 | def to_d
3 | self
4 | end
5 |
6 | def to_json
7 | to_s
8 | end
9 |
10 | def as_json(options = nil)
11 | self
12 | end
13 | end
14 |
--------------------------------------------------------------------------------
/config/initializers/donations.rb:
--------------------------------------------------------------------------------
1 | unless BitcoinBank.const_defined? :Donations
2 | BitcoinBank.const_set(:Donations, YAML::load(File.open(File.join(Rails.root, "config", "bitcoin.yml")))[Rails.env]['donations'])
3 | end
--------------------------------------------------------------------------------
/config/initializers/inflections.rb:
--------------------------------------------------------------------------------
1 | # Be sure to restart your server when you modify this file.
2 |
3 | # Add new inflection rules using the following format
4 | # (all these examples are active by default):
5 | # ActiveSupport::Inflector.inflections do |inflect|
6 | # inflect.plural /^(ox)$/i, '\1en'
7 | # inflect.singular /^(ox)en/i, '\1'
8 | # inflect.irregular 'person', 'people'
9 | # inflect.uncountable %w( fish sheep )
10 | # end
11 |
--------------------------------------------------------------------------------
/config/initializers/json_serialization.rb:
--------------------------------------------------------------------------------
1 | ActiveRecord::Base.include_root_in_json = false
--------------------------------------------------------------------------------
/config/initializers/liberty_reserve.rb:
--------------------------------------------------------------------------------
1 | unless BitcoinBank.const_defined? :LibertyReserve
2 | BitcoinBank.const_set(:LibertyReserve, YAML::load(File.open(File.join(Rails.root, "config", "liberty_reserve.yml")))[Rails.env])
3 | end
--------------------------------------------------------------------------------
/config/initializers/mime_types.rb:
--------------------------------------------------------------------------------
1 | # Be sure to restart your server when you modify this file.
2 |
3 | # Add new mime types for use in respond_to blocks:
4 | # Mime::Type.register "text/richtext", :rtf
5 | # Mime::Type.register_alias "text/html", :iphone
6 |
7 | Mime::Type.register "image/svg+xml", :svg
8 | Mime::Type.register "image/png", :png
9 |
--------------------------------------------------------------------------------
/config/initializers/monkey_patches.rb:
--------------------------------------------------------------------------------
1 | # https://github.com/rails/rails/issues/2483
2 | # https://github.com/rails/rails/issues/3047
3 |
4 | class ActionDispatch::Session::AbstractStore
5 | def call(env)
6 | # the only place I could find that knows how to mutate out the `:all` was the CookieJar, so we use that before Rack gets an invalid :domain
7 | ActionDispatch::Request.new(env).cookie_jar.handle_options(@default_options)
8 | super
9 | end
10 | end
11 |
--------------------------------------------------------------------------------
/config/initializers/paranoia.rb:
--------------------------------------------------------------------------------
1 | # This forces every model to explicitly whitelist accessible attributes
2 | ActiveRecord::Base.send(:attr_accessible, nil)
3 |
4 | # This is necessary to prevent errors when using AR's DB session store
5 | ActiveRecord::Base.send(:attr_accessible, :session_id)
--------------------------------------------------------------------------------
/config/initializers/recaptcha_keys.rb:
--------------------------------------------------------------------------------
1 | recaptcha_configuration = YAML::load(File.open(File.join(Rails.root, "config", "recaptcha.yml")))[Rails.env]
2 |
3 | ENV['RECAPTCHA_PUBLIC_KEY'] = recaptcha_configuration['public']
4 | ENV['RECAPTCHA_PRIVATE_KEY'] = recaptcha_configuration['private']
--------------------------------------------------------------------------------
/config/initializers/secret_token.rb:
--------------------------------------------------------------------------------
1 | # Be sure to restart your server when you modify this file.
2 |
3 | # Your secret key for verifying the integrity of signed cookies.
4 | # If you change this key, all old signed cookies will become invalid!
5 | # Make sure the secret is at least 30 characters and all random,
6 | # no regular words or you'll be exposed to dictionary attacks.
7 | BitcoinBank::Application.config.secret_token = '1c8d72f49c79fbecef27d20efokzegjeznze654zef2zef651dcdv54dfv21v6582247d5434054bb33864d5e2c06fc89cb6b6e48682d7b40a39042cbbedbf9f0a5'
8 |
--------------------------------------------------------------------------------
/config/initializers/session_store.rb:
--------------------------------------------------------------------------------
1 | BitcoinBank::Application.config.session_store :active_record_store,
2 | :key => "bc-session",
3 | :domain => :all
4 |
--------------------------------------------------------------------------------
/config/initializers/transaction.rb:
--------------------------------------------------------------------------------
1 | module SerializableTransactions
2 | def self.included(base)
3 | base.extend ClassMethods
4 | base.class_eval do
5 | class << self
6 | alias_method_chain :transaction, :isolation
7 | end
8 | end
9 | end
10 |
11 | module ClassMethods
12 | # TODO : Passing args to the transaction_without_isolation breaks test :/
13 | def transaction_with_isolation(*args, &block)
14 | transaction_without_isolation do
15 | ActiveRecord::Base.
16 | connection.
17 | execute "SET SESSION TRANSACTION ISOLATION LEVEL SERIALIZABLE"
18 |
19 | block.call
20 | end
21 | end
22 | end
23 | end
24 |
25 | ActiveRecord::Base.send :include, SerializableTransactions
26 |
--------------------------------------------------------------------------------
/config/initializers/will_paginate.rb:
--------------------------------------------------------------------------------
1 | module WillPaginate::I18nViewHelpers
2 | def will_paginate(collection, options = {})
3 | super(collection,
4 | options.merge(
5 | :previous_label => "← #{I18n.t('will_paginate.previous')}",
6 | :next_label => "#{I18n.t('will_paginate.next')} →"
7 | )
8 | )
9 | end
10 | end
11 |
12 | ActionView::Base.send(:include, WillPaginate::I18nViewHelpers)
--------------------------------------------------------------------------------
/config/liberty_reserve.yml:
--------------------------------------------------------------------------------
1 | development:
2 | account: U8651415
3 | store: Bitcoin Central
4 | success_url: http://85.171.177.102:3000/liberty_reserve_transfers
5 | status_url: http://85.171.177.102:3000/liberty_reserve_transfers
6 | fail_url: http://85.171.177.102:3000/liberty_reserve_transfers/fail
7 | api_uri: https://api.libertyreserve.com/
8 | api_name: Bitcoin Central API
9 | secret_word: MySecWord123
10 |
11 | test:
12 | account: U8651415
13 | store: Bitcoin Central
14 | success_url: http://85.171.177.102:3000/liberty_reserve_transfers
15 | status_url: http://85.171.177.102:3000/liberty_reserve_transfers
16 | fail_url: http://85.171.177.102:3000/liberty_reserve_transfers/fail
17 | api_uri: https://api.libertyreserve.com/
18 | api_name: Bitcoin Central API
19 | secret_word: MySecWord123
20 |
21 |
--------------------------------------------------------------------------------
/config/locales/en/currencies.yml:
--------------------------------------------------------------------------------
1 | en:
2 | currencies:
3 | all:
4 | name: All currencies
5 | btc:
6 | name: Bitcoin
7 | link: http://www.bitcoin.org/
8 | eur:
9 | name: Euro
10 | link: http://www.ecb.int/
11 | lrusd:
12 | name: Liberty Reserve Dollar
13 | link: https://www.libertyreserve.com/?ref=U8651415
14 | lreur:
15 | name: Liberty Reserve Euro
16 | link: https://www.libertyreserve.com/?ref=U8651415
17 | pgau:
18 | name: Pecunix Gold
19 | link: http://www.pecunix.com/
20 | cad:
21 | name: Canadian Dollar
22 | link: http://www.bankofcanada.ca/
23 | inr:
24 | name: Indian Rupee
25 | link: http://www.rbi.org.in/
26 | usd:
27 | name: US Dollar
28 | link: http://www.federalreserve.gov/
29 |
--------------------------------------------------------------------------------
/config/locales/en/emails.yml:
--------------------------------------------------------------------------------
1 | en:
2 | emails:
3 | invoice_payment_notification:
4 | subject: You have received a bitcoin payment
5 | body: "You have received a %{amount} BTC payment (invoice reference : %{reference})"
6 |
7 | withdrawal_processed_notification:
8 | subject: Your payment request has been processed
9 | body: "Your payment request has been processed, you will receive the funds shortly."
10 |
11 | tickets:
12 | view_details_of: "View details of ticket \"%{title}\""
13 | reopen_notification:
14 | subject: Your support ticket has been reopened
15 | create_notification:
16 | subject: A new support ticket has been opened
17 | close_notification:
18 | subject: Your support ticket has been closed
19 | comment_notification:
20 | subject: Your support ticket has been commented
21 |
22 | trade_notification:
23 | subject: Trade orders have been executed
24 | traded: "%{traded_btc} BTC at %{ppc} %{currency} per BTC for a total of %{traded_currency} %{currency}"
25 | bought: Bought
26 | sold: Sold
27 |
--------------------------------------------------------------------------------
/config/locales/fr/currencies.yml:
--------------------------------------------------------------------------------
1 | fr:
2 | currencies:
3 | all:
4 | name: Toutes devises
5 | btc:
6 | name: Bitcoin
7 | link: http://www.bitcoin.org/
8 | eur:
9 | name: Euro
10 | link: http://www.ecb.int/
11 | lrusd:
12 | name: Dollar Liberty Reserve
13 | link: https://www.libertyreserve.com/?ref=U8651415
14 | lreur:
15 | name: Euro Liberty Reserve
16 | link: https://www.libertyreserve.com/?ref=U8651415
17 | pgau:
18 | name: Or Pecunix
19 | link: http://www.pecunix.com/
20 | cad:
21 | name: Dollar Canadien
22 | link: http://www.bankofcanada.ca/
23 | inr:
24 | name: Roupie Indienne
25 | link: http://www.rbi.org.in/
26 | usd:
27 | name: Dollar US
28 | link: http://www.federalreserve.gov/
29 |
--------------------------------------------------------------------------------
/config/locales/fr/emails.yml:
--------------------------------------------------------------------------------
1 | fr:
2 | emails:
3 | invoice_payment_notification:
4 | subject: Vous avez reçu un paiement bitcoin!
5 | body: "Vous avez reçu un paiement de %{amount} BTC en paiement de la facture %{reference}"
6 |
7 | withdrawal_processed_notification:
8 | subject: Votre demande de paiement a été traitée
9 | body: "Votre demande de paiement a été traitée, vous devriez recevoir un virement sous peu."
10 |
11 | tickets:
12 | view_details_of: "Voir les détails du ticket \"%{title}\""
13 | reopen_notification:
14 | subject: Votre ticket a été ré-ouvert
15 | create_notification:
16 | subject: Un nouveau ticket a été ouvert
17 | close_notification:
18 | subject: Votre ticket a été clôturé
19 | comment_notification:
20 | subject: Un commentaire a été ajouté sur votre ticket
21 |
22 | trade_notification:
23 | subject: Vos ordres d'échange ont été exécutés
24 | traded: "%{traded_btc} BTC au prix de %{ppc} %{currency} par BTC pour un total de %{traded_currency} %{currency}"
25 | bought: Achats
26 | sold: Ventes
27 |
28 |
--------------------------------------------------------------------------------
/config/pecunix.yml:
--------------------------------------------------------------------------------
1 | development:
2 | account: support@bitcoin-central.net
3 | secret: secret word is secret
4 |
5 | # Pecunix POSTs here to confirm payment
6 | status_url: http://localhost:3030/third_party_callbacks/px_status
7 |
8 | # Pecunix POSTs here from the users browser when payment succeeded
9 | payment_url: http://localhost:3030/third_party_callbacks/px_payment
10 |
11 | # Pecunix POSTs here from the browser if payment was cancelled
12 | no_payment_url: http://localhost:3030/third_party_callbacks/px_cancel
13 |
14 | test:
15 | account: support@bitcoin-central.net
16 | secret: secret word is secret
17 | status_url: https://bitcoin-central.net/third_party_callbacks/px_status
18 | payment_url: https://bitcoin-central.net/third_party_callbacks/px_payment
19 | no_payment_url: https://bitcoin-central.net/third_party_callbacks/px_cancel
20 |
--------------------------------------------------------------------------------
/config/recaptcha.yml:
--------------------------------------------------------------------------------
1 | development:
2 | public: 6LeFDL4SAAAAAPR_LFOXwMh5eDrdbGR7nmC6ZaB2
3 | private: 6LeFDL4SAAAAAOUxLJFiG3nEu28KU4l1wgSrDk7M
4 |
5 | test:
6 | public: 6LeFDL4SAAAAAPR_LFOXwMh5eDrdbGR7nmC6ZaB2
7 | private: 6LeFDL4SAAAAAOUxLJFiG3nEu28KU4l1wgSrDk7M
8 |
--------------------------------------------------------------------------------
/config/schedule.rb:
--------------------------------------------------------------------------------
1 | job_type :rake, "cd :path && RAILS_ENV=:environment bundle exec rake :task :output"
2 |
3 | every 2.minutes do
4 | rake "bitcoin:synchronize_transactions"
5 | end
6 |
7 | every 5.minutes do
8 | rake "bitcoin:process_pending_invoices"
9 | end
10 |
11 | every 10.minutes do
12 | rake "liberty_reserve:synchronize_transactions"
13 | rake "notifications:trades"
14 | end
15 |
16 | every 30.minutes do
17 | rake "bitcoin:backup_wallet"
18 | end
19 |
20 | every 1.day, :at => '5:30 am' do
21 | rake "bitcoin:backup_db"
22 | end
23 |
24 | every 1.day do
25 | rake "bitcoin:prune_old_pending_invoices"
26 | end
--------------------------------------------------------------------------------
/config/yubico.yml:
--------------------------------------------------------------------------------
1 | development:
2 | api_url: https://api.yubico.com/wsapi/verify
3 | api_id: foo
4 | api_key: bar
5 |
6 | test:
7 | api_url: https://api.yubico.com/wsapi/verify
8 | api_id: foo
9 | api_key: bar
10 |
--------------------------------------------------------------------------------
/db/migrate/20101017190414_add_sessions_table.rb:
--------------------------------------------------------------------------------
1 | class AddSessionsTable < ActiveRecord::Migration
2 | def self.up
3 | create_table :sessions do |t|
4 | t.string :session_id, :null => false
5 | t.text :data
6 | t.timestamps
7 | end
8 |
9 | add_index :sessions, :session_id
10 | add_index :sessions, :updated_at
11 | end
12 |
13 | def self.down
14 | drop_table :sessions
15 | end
16 | end
17 |
--------------------------------------------------------------------------------
/db/migrate/20101017194104_create_users.rb:
--------------------------------------------------------------------------------
1 | class CreateUsers < ActiveRecord::Migration
2 | def self.up
3 | create_table :users do |t|
4 | t.string :account,
5 | :null => false
6 |
7 | t.string :email
8 |
9 | t.string :password,
10 | :null => false
11 |
12 | t.timestamps
13 | end
14 | end
15 |
16 | def self.down
17 | drop_table :users
18 | end
19 | end
20 |
--------------------------------------------------------------------------------
/db/migrate/20101017230001_create_transfers.rb:
--------------------------------------------------------------------------------
1 | class CreateTransfers < ActiveRecord::Migration
2 | def self.up
3 | create_table :transfers do |t|
4 | t.string :type
5 |
6 | t.integer :user_id
7 |
8 | t.string :address
9 |
10 | t.decimal :amount,
11 | :precision => 16,
12 | :scale => 8,
13 | :default => 0
14 |
15 | t.timestamps
16 | end
17 | end
18 |
19 | def self.down
20 | drop_table :transfers
21 | end
22 | end
23 |
--------------------------------------------------------------------------------
/db/migrate/20101022090523_add_last_address_column.rb:
--------------------------------------------------------------------------------
1 | class AddLastAddressColumn < ActiveRecord::Migration
2 | def self.up
3 | add_column :users, :last_address, :string
4 | end
5 |
6 | def self.down
7 | remove_column :users, :last_address
8 | end
9 | end
10 |
--------------------------------------------------------------------------------
/db/migrate/20101123114028_add_currency_to_transfers.rb:
--------------------------------------------------------------------------------
1 | class AddCurrencyToTransfers < ActiveRecord::Migration
2 | def self.up
3 | add_column :transfers, :currency, :string, :nil => false
4 | end
5 |
6 | def self.down
7 | remove_column :transfers, :currency
8 | end
9 | end
10 |
--------------------------------------------------------------------------------
/db/migrate/20101124101527_add_lr_metadata.rb:
--------------------------------------------------------------------------------
1 | class AddLrMetadata < ActiveRecord::Migration
2 | def self.up
3 | add_column :transfers, :lr_transaction_id, :string
4 | add_column :transfers, :lr_transferred_amount, :decimal, :precision => 16, :scale => 8, :default => 0
5 | add_column :transfers, :lr_merchant_fee, :decimal, :precision => 16, :scale => 8, :default => 0
6 | end
7 |
8 | def self.down
9 | remove_column :transfers, :lr_transaction_id
10 | remove_column :transfers, :lr_transferred_amount
11 | remove_column :transfers, :lr_merchant_fee
12 | end
13 | end
14 |
--------------------------------------------------------------------------------
/db/migrate/20101125091027_add_salt_to_users.rb:
--------------------------------------------------------------------------------
1 | class AddSaltToUsers < ActiveRecord::Migration
2 | def self.up
3 | add_column :users, :salt, :string
4 | end
5 |
6 | def self.down
7 | remove_column :users, :salt
8 | end
9 | end
10 |
--------------------------------------------------------------------------------
/db/migrate/20101125140724_add_btc_meta_data.rb:
--------------------------------------------------------------------------------
1 | class AddBtcMetaData < ActiveRecord::Migration
2 | def self.up
3 | add_column :transfers, :bt_tx_id, :string
4 | add_column :transfers, :bt_tx_from, :string
5 | add_column :transfers, :bt_tx_confirmations, :integer, :default => 0
6 | end
7 |
8 | def self.down
9 | remove_column :transfers, :bt_tx_id
10 | remove_column :transfers, :bt_tx_from
11 | remove_column :transfers, :bt_tx_confirmations
12 | end
13 | end
14 |
--------------------------------------------------------------------------------
/db/migrate/20101130120618_create_trade_orders.rb:
--------------------------------------------------------------------------------
1 | class CreateTradeOrders < ActiveRecord::Migration
2 | def self.up
3 | create_table :trade_orders do |t|
4 | t.integer :user_id,
5 | :null => false
6 |
7 | t.decimal :amount,
8 | :precision => 16,
9 | :scale => 8,
10 | :default => 0
11 |
12 | t.decimal :ppc,
13 | :precision => 16,
14 | :scale => 8,
15 | :default => 0
16 |
17 | t.string :currency,
18 | :null => false
19 |
20 | t.string :category,
21 | :null => false
22 |
23 | t.string :status,
24 | :null => false,
25 | :default => "open"
26 |
27 | t.timestamps
28 | end
29 | end
30 |
31 | def self.down
32 | drop_table :trade_orders
33 | end
34 | end
35 |
--------------------------------------------------------------------------------
/db/migrate/20101220214804_add_lr_fields.rb:
--------------------------------------------------------------------------------
1 | class AddLrFields < ActiveRecord::Migration
2 | def self.up
3 | add_column :transfers, :lr_account_id, :string
4 | end
5 |
6 | def self.down
7 | remove_column :transfers, :lr_account_id
8 | end
9 | end
10 |
--------------------------------------------------------------------------------
/db/migrate/20101222002654_add_time_zone_to_users.rb:
--------------------------------------------------------------------------------
1 | class AddTimeZoneToUsers < ActiveRecord::Migration
2 | def self.up
3 | add_column :users, :time_zone, :string
4 | end
5 |
6 | def self.down
7 | remove_column :users, :time_zone
8 | end
9 | end
10 |
--------------------------------------------------------------------------------
/db/migrate/20101222014309_create_trades.rb:
--------------------------------------------------------------------------------
1 | class CreateTrades < ActiveRecord::Migration
2 | def self.up
3 | create_table :trades do |t|
4 | t.integer :purchase_order_id
5 |
6 | t.integer :sale_order_id
7 |
8 | t.decimal :traded_btc,
9 | :precision => 16,
10 | :scale => 8,
11 | :default => 0
12 |
13 | t.decimal :traded_currency,
14 | :precision => 16,
15 | :scale => 8,
16 | :default => 0
17 |
18 | t.decimal :ppc,
19 | :precision => 16,
20 | :scale => 8,
21 | :default => 0
22 |
23 | t.string :currency
24 |
25 | t.timestamps
26 | end
27 | end
28 |
29 | def self.down
30 | drop_table :trades
31 | end
32 | end
33 |
--------------------------------------------------------------------------------
/db/migrate/20101222020005_add_payee_id_to_transfers.rb:
--------------------------------------------------------------------------------
1 | class AddPayeeIdToTransfers < ActiveRecord::Migration
2 | def self.up
3 | add_column :transfers, :payee_id, :integer
4 | end
5 |
6 | def self.down
7 | remove_column :transfers, :payee_id
8 | end
9 | end
10 |
--------------------------------------------------------------------------------
/db/migrate/20101223013915_add_cancelled_at_to_trade_orders.rb:
--------------------------------------------------------------------------------
1 | class AddCancelledAtToTradeOrders < ActiveRecord::Migration
2 | def self.up
3 | add_column :trade_orders, :cancelled_at, :datetime
4 | end
5 |
6 | def self.down
7 | remove_column :trade_orders, :cancelled_at
8 | end
9 | end
10 |
--------------------------------------------------------------------------------
/db/migrate/20101229231455_add_active_to_trade_order.rb:
--------------------------------------------------------------------------------
1 | class AddActiveToTradeOrder < ActiveRecord::Migration
2 | def self.up
3 | add_column :trade_orders, :active, :boolean,
4 | :default => true
5 | end
6 |
7 | def self.down
8 | remove_column :trade_orders, :active
9 | end
10 | end
11 |
--------------------------------------------------------------------------------
/db/migrate/20101229232404_add_ids_to_trades.rb:
--------------------------------------------------------------------------------
1 | class AddIdsToTrades < ActiveRecord::Migration
2 | def self.up
3 | add_column :trades, :seller_id, :integer
4 | add_column :trades, :buyer_id, :integer
5 | end
6 |
7 | def self.down
8 | remove_column :trades, :seller_id
9 | remove_column :trades, :buyer_id
10 | end
11 | end
12 |
--------------------------------------------------------------------------------
/db/migrate/20101230150344_remove_status_from_trade_orders.rb:
--------------------------------------------------------------------------------
1 | class RemoveStatusFromTradeOrders < ActiveRecord::Migration
2 | def self.up
3 | remove_column :trade_orders, :status
4 | end
5 |
6 | def self.down
7 | raise ActiveRecord::IrreversibleMigration
8 | end
9 | end
10 |
--------------------------------------------------------------------------------
/db/migrate/20110101105004_drop_cancelled_at_column.rb:
--------------------------------------------------------------------------------
1 | class DropCancelledAtColumn < ActiveRecord::Migration
2 | def self.up
3 | remove_column :trade_orders, :cancelled_at
4 | end
5 |
6 | def self.down
7 | raise ActiveRecord::IrreversibleMigration
8 | end
9 | end
10 |
--------------------------------------------------------------------------------
/db/migrate/20110107095311_add_dark_pool_attributes.rb:
--------------------------------------------------------------------------------
1 | class AddDarkPoolAttributes < ActiveRecord::Migration
2 | def self.up
3 | add_column :trade_orders, :dark_pool, :boolean,
4 | :default => false,
5 | :null => false
6 |
7 | add_column :trade_orders, :dark_pool_exclusive_match, :boolean,
8 | :default => false,
9 | :null => false
10 | end
11 |
12 | def self.down
13 | remove_column :trade_orders, :dark_pool
14 | remove_column :trade_orders, :dark_pool_exclusive_match
15 | end
16 | end
17 |
--------------------------------------------------------------------------------
/db/migrate/20110120142138_add_admin_flag.rb:
--------------------------------------------------------------------------------
1 | class AddAdminFlag < ActiveRecord::Migration
2 | def self.up
3 | add_column :users, :admin, :boolean, :default => false
4 | end
5 |
6 | def self.down
7 | remove_column :users, :admin
8 | end
9 | end
10 |
--------------------------------------------------------------------------------
/db/migrate/20110121112916_add_secret_token_to_users.rb:
--------------------------------------------------------------------------------
1 | class AddSecretTokenToUsers < ActiveRecord::Migration
2 | def self.up
3 | add_column :users, :secret_token, :string
4 | end
5 |
6 | def self.down
7 | remove_column :users, :secret_token
8 | end
9 | end
10 |
--------------------------------------------------------------------------------
/db/migrate/20110123220843_add_email_to_transfers.rb:
--------------------------------------------------------------------------------
1 | class AddEmailToTransfers < ActiveRecord::Migration
2 | def self.up
3 | add_column :transfers, :email, :string
4 | end
5 |
6 | def self.down
7 | remove_column :transfers, :email
8 | end
9 | end
10 |
--------------------------------------------------------------------------------
/db/migrate/20110126134715_remove_cash_transfer.rb:
--------------------------------------------------------------------------------
1 | class RemoveCashTransfer < ActiveRecord::Migration
2 | def self.up
3 | execute "UPDATE `transfers` SET `transfers`.`type`='Transfer' WHERE `transfers`.`type`='CashTransfer'"
4 | end
5 |
6 | def self.down
7 | end
8 | end
9 |
--------------------------------------------------------------------------------
/db/migrate/20110201144233_add_pecunix_fields.rb:
--------------------------------------------------------------------------------
1 | class AddPecunixFields < ActiveRecord::Migration
2 | def self.up
3 | add_column :transfers, :px_tx_id, :string
4 | add_column :transfers, :px_payer, :string
5 | end
6 |
7 | def self.down
8 | remove_column :transfers, :px_tx_id
9 | remove_column :transfers, :px_payer
10 | end
11 | end
12 |
--------------------------------------------------------------------------------
/db/migrate/20110201210946_add_px_fee.rb:
--------------------------------------------------------------------------------
1 | class AddPxFee < ActiveRecord::Migration
2 | def self.up
3 | add_column :transfers, :px_fee, :decimal, :precision => 16, :scale => 8, :default => 0
4 | end
5 |
6 | def self.down
7 | remove_column :transfers, :px_fee
8 | end
9 | end
10 |
--------------------------------------------------------------------------------
/db/migrate/20110506082222_devise_create_users.rb:
--------------------------------------------------------------------------------
1 | class DeviseCreateUsers < ActiveRecord::Migration
2 | def self.up
3 | change_table(:users) do |t|
4 | # t.database_authenticatable
5 | t.string :encrypted_password, :null => false, :default => ''
6 | t.string :password_salt, :null => false, :default => ''
7 |
8 | t.confirmable
9 | t.recoverable
10 | t.rememberable
11 | t.trackable
12 | t.lockable :lock_strategy => :failed_attempts, :unlock_strategy => :both
13 | t.token_authenticatable
14 | end
15 |
16 | add_index :users, :email, :unique => true
17 |
18 | execute "ALTER TABLE `users` MODIFY COLUMN `password` VARCHAR(255) NULL"
19 | end
20 |
21 | def self.down
22 | change_table :users do |t|
23 | t.remove :encrypted_password
24 | t.remove :password_salt
25 | t.remove :authentication_token
26 | t.remove :confirmation_token
27 | t.remove :confirmed_at
28 | t.remove :confirmation_sent_at
29 | t.remove :reset_password_token
30 | t.remove :remember_token
31 | t.remove :remember_created_at
32 | t.remove :sign_in_count
33 | t.remove :current_sign_in_at
34 | t.remove :last_sign_in_at
35 | t.remove :current_sign_in_ip
36 | t.remove :last_sign_in_ip
37 | t.remove :failed_attempts
38 | t.remove :unlock_token
39 | t.remove :locked_at
40 | end
41 | end
42 | end
43 |
--------------------------------------------------------------------------------
/db/migrate/20110511194431_add_lr_tx_id_index.rb:
--------------------------------------------------------------------------------
1 | class AddLrTxIdIndex < ActiveRecord::Migration
2 | def self.up
3 | add_index :transfers, [:lr_transaction_id],
4 | :name => :index_transfers_on_lr_transaction_id,
5 | :unique => true
6 | end
7 |
8 | def self.down
9 | remove_index :transfers,
10 | :name => :index_transfers_on_lr_transaction_id
11 | end
12 | end
13 |
--------------------------------------------------------------------------------
/db/migrate/20110517105159_create_invoices.rb:
--------------------------------------------------------------------------------
1 | class CreateInvoices < ActiveRecord::Migration
2 | def self.up
3 | create_table :invoices do |t|
4 | t.string :state, :null => false
5 |
6 | t.integer :user_id, :null => false
7 |
8 | t.decimal :amount,
9 | :precision => 16,
10 | :scale => 8,
11 | :default => 0,
12 | :null => false
13 |
14 | t.string :payment_address, :null => false
15 |
16 | t.string :callback_url, :null => false
17 |
18 | t.timestamp :paid_at
19 |
20 | t.timestamps
21 | end
22 |
23 | add_index :invoices, :payment_address, :unique => true
24 | end
25 |
26 | def self.down
27 | drop_table :invoices
28 | end
29 | end
30 |
--------------------------------------------------------------------------------
/db/migrate/20110518094622_add_merchant_flag_to_users.rb:
--------------------------------------------------------------------------------
1 | class AddMerchantFlagToUsers < ActiveRecord::Migration
2 | def self.up
3 | add_column :users, :merchant, :boolean, :default => false
4 | end
5 |
6 | def self.down
7 | remove_column :users, :merchant
8 | end
9 | end
10 |
--------------------------------------------------------------------------------
/db/migrate/20110518211846_add_invoice_reference.rb:
--------------------------------------------------------------------------------
1 | class AddInvoiceReference < ActiveRecord::Migration
2 | def self.up
3 | add_column :invoices, :reference, :string, :null => false
4 | add_index :invoices, :reference, :unique => true
5 | end
6 |
7 | def self.down
8 | remove_column :invoices, :reference
9 | end
10 | end
11 |
--------------------------------------------------------------------------------
/db/migrate/20110519121047_add_comment_and_merchant_ref_to_invoice.rb:
--------------------------------------------------------------------------------
1 | class AddCommentAndMerchantRefToInvoice < ActiveRecord::Migration
2 | def self.up
3 | add_column :invoices, :merchant_reference, :string
4 | add_column :invoices, :merchant_memo, :string
5 | end
6 |
7 | def self.down
8 | remove_column :invoices, :merchant_reference
9 | remove_column :invoices, :merchant_memo
10 | end
11 | end
12 |
--------------------------------------------------------------------------------
/db/migrate/20110521122924_add_auth_token_to_invoices.rb:
--------------------------------------------------------------------------------
1 | class AddAuthTokenToInvoices < ActiveRecord::Migration
2 | def self.up
3 | add_column :invoices, :authentication_token, :string, :null => false
4 | add_index :invoices, :authentication_token, :unique => true
5 | end
6 |
7 | def self.down
8 | remove_column :invoices, :authentication_token
9 | end
10 | end
11 |
--------------------------------------------------------------------------------
/db/migrate/20110521125911_add_item_url_to_invoices.rb:
--------------------------------------------------------------------------------
1 | class AddItemUrlToInvoices < ActiveRecord::Migration
2 | def self.up
3 | add_column :invoices, :item_url, :string
4 | end
5 |
6 | def self.down
7 | remove_column :invoices, :item_url
8 | end
9 | end
10 |
--------------------------------------------------------------------------------
/db/migrate/20110625123015_add_otp_fields.rb:
--------------------------------------------------------------------------------
1 | class AddOtpFields < ActiveRecord::Migration
2 | def self.up
3 | add_column :users, :otp_secret, :string, :length => 16
4 | add_column :users, :require_otp, :boolean, :default => false
5 | end
6 |
7 | def self.down
8 | remove_column :users, :otp_secret
9 | remove_column :users, :require_otp
10 | end
11 | end
12 |
--------------------------------------------------------------------------------
/db/migrate/20110630161800_create_announcements.rb:
--------------------------------------------------------------------------------
1 | class CreateAnnouncements < ActiveRecord::Migration
2 | def self.up
3 | create_table :announcements do |t|
4 | t.string :title
5 | t.text :content
6 | t.boolean :active
7 |
8 | t.timestamps
9 | end
10 | end
11 |
12 | def self.down
13 | drop_table :announcements
14 | end
15 | end
16 |
--------------------------------------------------------------------------------
/db/migrate/20110701083833_add_comment_to_transfers.rb:
--------------------------------------------------------------------------------
1 | class AddCommentToTransfers < ActiveRecord::Migration
2 | def self.up
3 | add_column :transfers, :comment, :string
4 | end
5 |
6 | def self.down
7 | remove_column :transfers, :comment
8 | end
9 | end
10 |
--------------------------------------------------------------------------------
/db/migrate/20110702184056_bitcoin_addresses_refactoring.rb:
--------------------------------------------------------------------------------
1 | class BitcoinAddressesRefactoring < ActiveRecord::Migration
2 | def self.up
3 | rename_column :users, :last_address, :bitcoin_address
4 | add_column :users, :last_address_refresh, :datetime
5 | end
6 |
7 | def self.down
8 | rename_column :users, :bitcoin_address, :last_address
9 | remove_column :users, :last_address_refresh
10 | end
11 | end
12 |
--------------------------------------------------------------------------------
/db/migrate/20110707141245_create_yubikeys.rb:
--------------------------------------------------------------------------------
1 | class CreateYubikeys < ActiveRecord::Migration
2 | def self.up
3 | create_table :yubikeys do |t|
4 | t.integer :user_id, :null => false
5 | t.string :key_id, :null => false
6 |
7 | t.boolean :active, :default => true
8 |
9 | t.timestamps
10 | end
11 | end
12 |
13 | def self.down
14 | drop_table :yubikeys
15 | end
16 | end
17 |
--------------------------------------------------------------------------------
/db/migrate/20110709144427_add_yubikey_flag_to_users.rb:
--------------------------------------------------------------------------------
1 | class AddYubikeyFlagToUsers < ActiveRecord::Migration
2 | def self.up
3 | rename_column :users, :require_otp, :require_ga_otp
4 | rename_column :users, :otp_secret, :ga_otp_secret
5 | add_column :users, :require_yk_otp, :boolean, :default => false
6 | end
7 |
8 | def self.down
9 | rename_column :users, :require_ga_otp, :require_otp
10 | rename_column :users, :ga_otp_secret, :otp_secret
11 | remove_column :users, :require_yk_otp
12 | end
13 | end
14 |
--------------------------------------------------------------------------------
/db/migrate/20110713164217_create_operations.rb:
--------------------------------------------------------------------------------
1 | class CreateOperations < ActiveRecord::Migration
2 | def self.up
3 | rename_table :trades, :operations
4 | add_column :operations, :type, :string
5 | execute "UPDATE operations SET `type`='Trade'"
6 | end
7 |
8 | def self.down
9 | remove_column :operations, :types
10 | rename_table :operations, :trades
11 | end
12 | end
13 |
--------------------------------------------------------------------------------
/db/migrate/20110713165908_create_account_operations.rb:
--------------------------------------------------------------------------------
1 | class CreateAccountOperations < ActiveRecord::Migration
2 | def self.up
3 | rename_table :transfers, :account_operations
4 | add_column :account_operations, :operation_id, :integer
5 | execute "UPDATE `account_operations` SET `type`= NULL WHERE `type` = 'InternalTransfer' OR (amount >= 0 AND `type` LIKE '%Transfer') "
6 | end
7 |
8 | def self.down
9 | remove_column :account_operations, :operation_id
10 | rename_table :account_operations, :transfers
11 | end
12 | end
13 |
--------------------------------------------------------------------------------
/db/migrate/20110713191630_create_accounts.rb:
--------------------------------------------------------------------------------
1 | class CreateAccounts < ActiveRecord::Migration
2 | def self.up
3 | rename_table :users, :accounts
4 | add_column :accounts, :parent_id, :integer
5 | add_column :accounts, :type, :string
6 | rename_column :accounts, :account, :name
7 | rename_column :account_operations, :user_id, :account_id
8 |
9 | execute "UPDATE `accounts` SET `type`='User'"
10 | end
11 |
12 | def self.down
13 | rename_column :account_operations, :account_id, :user_id
14 | rename_column :accounts, :name, :account
15 | remove_column :accounts, :parent_id
16 | remove_column :accounts, :type
17 | rename_table :accounts, :users
18 | end
19 | end
20 |
--------------------------------------------------------------------------------
/db/migrate/20110719172103_add_bank_info_to_transfers.rb:
--------------------------------------------------------------------------------
1 | class AddBankInfoToTransfers < ActiveRecord::Migration
2 | def self.up
3 | add_column :account_operations, :bic, :string
4 | add_column :account_operations, :iban, :string
5 | add_column :account_operations, :full_name_and_address, :text
6 | end
7 |
8 | def self.down
9 | remove_column :account_operations, :bic
10 | remove_column :account_operations, :iban
11 | remove_column :account_operations, :full_name_and_address
12 | end
13 | end
14 |
--------------------------------------------------------------------------------
/db/migrate/20110726190751_add_state_to_account_operations.rb:
--------------------------------------------------------------------------------
1 | class AddStateToAccountOperations < ActiveRecord::Migration
2 | def self.up
3 | add_column :account_operations, :state, :string
4 | execute("UPDATE account_operations SET state='processed' WHERE `type` IS NOT NULL")
5 | end
6 |
7 | def self.down
8 | remove_column :account_operations, :state
9 | end
10 | end
11 |
--------------------------------------------------------------------------------
/db/migrate/20110728104040_create_static_pages.rb:
--------------------------------------------------------------------------------
1 | class CreateStaticPages < ActiveRecord::Migration
2 | def self.up
3 | create_table :static_pages do |t|
4 | t.string :name
5 | t.string :title
6 | t.string :locale
7 | t.text :contents
8 |
9 | t.timestamps
10 | end
11 | end
12 |
13 | def self.down
14 | drop_table :static_pages
15 | end
16 | end
17 |
--------------------------------------------------------------------------------
/db/migrate/20110729211831_create_bank_accounts.rb:
--------------------------------------------------------------------------------
1 | class CreateBankAccounts < ActiveRecord::Migration
2 | def self.up
3 | create_table :bank_accounts do |t|
4 | t.integer :user_id, :null => false
5 | t.string :bic, :null => false
6 | t.string :iban, :null => false
7 | t.text :account_holder
8 | t.string :state
9 |
10 | t.timestamps
11 | end
12 |
13 | remove_column :account_operations, :bic
14 | remove_column :account_operations, :iban
15 | remove_column :account_operations, :full_name_and_address
16 | end
17 |
18 | def self.down
19 | add_column :account_operations, :bic, :string
20 | add_column :account_operations, :iban, :string
21 | add_column :account_operations, :full_name_and_address, :text
22 |
23 | drop_table :bank_accounts
24 | end
25 | end
26 |
--------------------------------------------------------------------------------
/db/migrate/20110729211904_add_bank_account_id_to_transfers.rb:
--------------------------------------------------------------------------------
1 | class AddBankAccountIdToTransfers < ActiveRecord::Migration
2 | def self.up
3 | add_column :account_operations, :bank_account_id, :integer
4 | end
5 |
6 | def self.down
7 | remove_column :account_operations, :bank_account_id
8 | end
9 | end
10 |
--------------------------------------------------------------------------------
/db/migrate/20110806153411_create_tickets.rb:
--------------------------------------------------------------------------------
1 | class CreateTickets < ActiveRecord::Migration
2 | def self.up
3 | create_table :tickets do |t|
4 | t.string :title
5 | t.text :description
6 | t.integer :user_id
7 | t.string :state
8 | t.timestamps
9 | end
10 | end
11 |
12 | def self.down
13 | drop_table :tickets
14 | end
15 | end
16 |
--------------------------------------------------------------------------------
/db/migrate/20110820164434_create_currencies.rb:
--------------------------------------------------------------------------------
1 | class CreateCurrencies < ActiveRecord::Migration
2 | def self.up
3 | create_table :currencies do |t|
4 | t.string :code,
5 | :null => false,
6 | :unique => true
7 |
8 | t.timestamps
9 | end
10 |
11 | %w{eur lrusd lreur pgau btc usd cad inr}.each do |c|
12 | execute "INSERT INTO currencies (code, created_at, updated_at) VALUES ('#{c.to_s.upcase}', NOW(), NOW())"
13 | end
14 | end
15 |
16 | def self.down
17 | drop_table :currencies
18 | end
19 | end
20 |
--------------------------------------------------------------------------------
/db/migrate/20110821125702_create_used_currencies.rb:
--------------------------------------------------------------------------------
1 | class CreateUsedCurrencies < ActiveRecord::Migration
2 | def self.up
3 | create_table :used_currencies do |t|
4 | t.integer :account_id, :null => false
5 | t.integer :currency_id, :null => false
6 | t.boolean :active, :default => true
7 |
8 | t.decimal :daily_limit,
9 | :precision => 16,
10 | :scale => 8,
11 | :default => 0
12 |
13 | t.decimal :monthly_limit,
14 | :precision => 16,
15 | :scale => 8,
16 | :default => 0
17 |
18 | t.boolean :management, :default => false
19 |
20 | t.timestamps
21 | end
22 |
23 | execute "INSERT INTO `used_currencies` (`currency_id`, `account_id`, `daily_limit`, `monthly_limit`, `created_at`, `updated_at`) SELECT currencies.id, accounts.id, NULL, NULL, NOW(), NOW() FROM currencies CROSS JOIN accounts"
24 | end
25 |
26 | def self.down
27 | drop_table :used_currencies
28 | end
29 | end
30 |
--------------------------------------------------------------------------------
/db/migrate/20110821132029_drop_admin_flag.rb:
--------------------------------------------------------------------------------
1 | class DropAdminFlag < ActiveRecord::Migration
2 | def self.up
3 | remove_column :accounts, :admin
4 | end
5 |
6 | def self.down
7 | add_column :accounts, :admin, :boolean, :default => false
8 | end
9 | end
10 |
--------------------------------------------------------------------------------
/db/migrate/20110911205535_create_comments.rb:
--------------------------------------------------------------------------------
1 | class CreateComments < ActiveRecord::Migration
2 | def self.up
3 | create_table :comments do |t|
4 | t.integer :user_id
5 | t.integer :ticket_id
6 | t.text :contents
7 |
8 | t.timestamps
9 | end
10 | end
11 |
12 | def self.down
13 | drop_table :comments
14 | end
15 | end
16 |
--------------------------------------------------------------------------------
/db/migrate/20110914082906_add_user_personal_data_columns.rb:
--------------------------------------------------------------------------------
1 | class AddUserPersonalDataColumns < ActiveRecord::Migration
2 | def self.up
3 | add_column :accounts, :full_name, :string
4 | add_column :accounts, :address, :text
5 | end
6 |
7 | def self.down
8 | remove_column :accounts, :full_name
9 | remove_column :accounts, :address
10 | end
11 | end
12 |
--------------------------------------------------------------------------------
/db/migrate/20110914093520_add_trade_notification_option_to_users.rb:
--------------------------------------------------------------------------------
1 | class AddTradeNotificationOptionToUsers < ActiveRecord::Migration
2 | def self.up
3 | add_column :accounts, :notify_on_trade, :boolean, :default => true
4 | end
5 |
6 | def self.down
7 | remove_column :accounts, :notify_on_trade
8 | end
9 | end
10 |
--------------------------------------------------------------------------------
/db/migrate/20110914131115_add_last_notified_to_users.rb:
--------------------------------------------------------------------------------
1 | class AddLastNotifiedToUsers < ActiveRecord::Migration
2 | def self.up
3 | add_column :accounts, :last_notified_trade_id,
4 | :integer,
5 | :null => false,
6 | :default => 0
7 |
8 | execute "UPDATE accounts SET last_notified_trade_id = (SELECT MAX(operations.id) FROM operations)"
9 | end
10 |
11 | def self.down
12 | remove_column :accounts, :last_notified_trade_id
13 | end
14 | end
15 |
--------------------------------------------------------------------------------
/db/migrate/20111117115222_modify_ppc_default_value.rb:
--------------------------------------------------------------------------------
1 | class ModifyPpcDefaultValue < ActiveRecord::Migration
2 | def self.up
3 | execute "ALTER TABLE `trade_orders` MODIFY `ppc` DECIMAL(16,8) NULL DEFAULT NULL"
4 | end
5 |
6 | def self.down
7 | execute "ALTER TABLE `trade_orders` MODIFY `ppc` DECIMAL(16,8) NULL DEFAULT 0"
8 | end
9 | end
10 |
--------------------------------------------------------------------------------
/db/migrate/20111122160759_add_type_to_trade_orders.rb:
--------------------------------------------------------------------------------
1 | class AddTypeToTradeOrders < ActiveRecord::Migration
2 | def self.up
3 | add_column :trade_orders, :type, :string
4 | #execute "UPDATE `trade_orders` SET `type` = 'LimitOrder' WHERE `type` IS NULL"
5 | end
6 |
7 | def self.down
8 | remove_column :trade_orders, :type
9 | end
10 | end
11 |
--------------------------------------------------------------------------------
/db/migrate/20111129123247_add_max_read_id_to_users.rb:
--------------------------------------------------------------------------------
1 | class AddMaxReadIdToUsers < ActiveRecord::Migration
2 | def self.up
3 | add_column :accounts, :max_read_tx_id, :integer,
4 | :null => false,
5 | :default => 0
6 |
7 | execute 'UPDATE `accounts` SET `max_read_tx_id` = (SELECT MAX(id) FROM `account_operations` WHERE `account_operations`.`account_id` = `accounts`.`id`)'
8 | end
9 |
10 | def self.down
11 | remove_column :accounts, :max_read_tx_id
12 | end
13 | end
14 |
--------------------------------------------------------------------------------
/db/migrate/20111205110307_add_commission_rate_to_users.rb:
--------------------------------------------------------------------------------
1 | class AddCommissionRateToUsers < ActiveRecord::Migration
2 | def self.up
3 | add_column :accounts, :commission_rate, :decimal,
4 | :precision => 16,
5 | :scale => 8
6 | end
7 |
8 | def self.down
9 | remove_column :accounts, :commission_rate
10 | end
11 | end
12 |
--------------------------------------------------------------------------------
/db/seeds.rb:
--------------------------------------------------------------------------------
1 | Admin.create! do |user|
2 | user.password = "password"
3 | user.password_confirmation = "password"
4 | user.email = "admin@localhost.local"
5 | user.skip_captcha = true
6 | user.confirmed_at = DateTime.now
7 | end
8 |
9 | puts "Created \"admin@localhost.local\" user with password \"password\""
--------------------------------------------------------------------------------
/doc/README_FOR_APP:
--------------------------------------------------------------------------------
1 | Use this README file to introduce your application and point to useful places in the API for learning more.
2 | Run "rake doc:app" to generate API documentation for your models, controllers, helpers, and libraries.
3 |
--------------------------------------------------------------------------------
/lib/bitcoin/client.rb:
--------------------------------------------------------------------------------
1 | module Bitcoin
2 | class Client
3 | include Singleton
4 |
5 | def initialize
6 | config_file = File.open(File.join(Rails.root, "config", "bitcoin.yml"))
7 | config = YAML::load(config_file)[Rails.env].symbolize_keys
8 |
9 | @client = JsonWrapper.new(config[:url],
10 | config[:username],
11 | config[:password]
12 | )
13 | end
14 |
15 | def method_missing(method, *args)
16 | @client.request({
17 | :method => method.to_s.gsub(/\_/, ""),
18 | :params => args
19 | }
20 | )
21 | end
22 | end
23 | end
--------------------------------------------------------------------------------
/lib/bitcoin/json_wrapper.rb:
--------------------------------------------------------------------------------
1 | require 'net/http'
2 | require 'addressable/uri'
3 | require 'json'
4 |
5 | module Bitcoin
6 | class JsonWrapper
7 | def initialize(url, username, password)
8 | @address = Addressable::URI.parse(url)
9 | @username = username
10 | @password = password
11 | end
12 |
13 | def request(params)
14 | result = nil
15 |
16 | full_params = params.merge({
17 | :jsonrpc => "2.0",
18 | :id => (rand * 10 ** 12).to_i.to_s
19 | })
20 |
21 | request_body = full_params.to_json
22 |
23 | Net::HTTP.start(@address.host, @address.port) do |connection|
24 | post = Net::HTTP::Post.new(@address.path)
25 | post.body = request_body
26 | post.basic_auth(@username, @password)
27 | result = connection.request(post)
28 | result = JSON.parse(result.body)
29 | end
30 |
31 | if error = result["error"]
32 | raise "#{error["message"]}, request was #{request_body}"
33 | end
34 |
35 | result = result["result"]
36 | result
37 | end
38 | end
39 | end
40 |
--------------------------------------------------------------------------------
/lib/bitcoin/util.rb:
--------------------------------------------------------------------------------
1 | module Bitcoin
2 | module Util
3 | def self.valid_bitcoin_address?(address)
4 | # We don't want leading/trailing spaces to pollute addresses
5 | (address == address.strip) and Bitcoin::Client.instance.validate_address(address)['isvalid']
6 | end
7 |
8 | def self.my_bitcoin_address?(address)
9 | Bitcoin::Client.instance.validate_address(address)['ismine']
10 | end
11 |
12 | def self.get_account(address)
13 | Bitcoin::Client.instance.get_account(address)
14 | end
15 | end
16 | end
--------------------------------------------------------------------------------
/lib/devise/models/ga_otp_authenticatable.rb:
--------------------------------------------------------------------------------
1 | module Devise
2 | module Models
3 | module GaOtpAuthenticatable
4 | extend ActiveSupport::Concern
5 |
6 | included do
7 | before_create :generate_ga_otp_secret
8 | attr_accessor :ga_otp
9 | end
10 |
11 | def ga_provisioning_uri
12 | ROTP::TOTP.new(ga_otp_secret).provisioning_uri(to_label)
13 | end
14 |
15 | def generate_ga_otp_secret
16 | self.ga_otp_secret = ROTP::Base32.random_base32
17 | end
18 |
19 | def valid_ga_otp?(ga_otp)
20 | !ga_otp.blank? && ga_otp.match(/[0-9]{6}/) && ROTP::TOTP.new(ga_otp_secret).verify(ga_otp.to_i)
21 | end
22 | end
23 | end
24 | end
25 |
--------------------------------------------------------------------------------
/lib/devise/models/yk_otp_authenticatable.rb:
--------------------------------------------------------------------------------
1 | module Devise
2 | module Models
3 | module YkOtpAuthenticatable
4 | extend ActiveSupport::Concern
5 |
6 | included do
7 | attr_accessor :yk_otp
8 | end
9 |
10 | def valid_yk_otp?(yk_otp)
11 | yubikeys.any? { |y| y.valid_otp?(yk_otp) }
12 | end
13 | end
14 | end
15 | end
16 |
--------------------------------------------------------------------------------
/lib/devise/strategies/ga_otp_authenticatable.rb:
--------------------------------------------------------------------------------
1 | require 'devise/strategies/database_authenticatable'
2 |
3 | module Devise
4 | module Strategies
5 | class GaOtpAuthenticatable < ::Devise::Strategies::DatabaseAuthenticatable
6 | def authenticate!
7 | resource = mapping.to.find_for_database_authentication(authentication_hash)
8 |
9 | if resource && resource.require_ga_otp
10 | if params[scope].blank? or !resource.valid_ga_otp?(params[scope][:ga_otp])
11 | fail!(:invalid_ga_otp)
12 | end
13 | end
14 | end
15 | end
16 | end
17 | end
18 |
19 | Warden::Strategies.add(:ga_otp_authenticatable, Devise::Strategies::GaOtpAuthenticatable)
20 |
--------------------------------------------------------------------------------
/lib/devise/strategies/yk_otp_authenticatable.rb:
--------------------------------------------------------------------------------
1 | require 'devise/strategies/database_authenticatable'
2 |
3 | module Devise
4 | module Strategies
5 | class YkOtpAuthenticatable < ::Devise::Strategies::DatabaseAuthenticatable
6 | def authenticate!
7 | resource = mapping.to.find_for_database_authentication(authentication_hash)
8 |
9 | if resource && resource.require_yk_otp
10 | if params[scope].blank? or !resource.valid_yk_otp?(params[scope][:yk_otp])
11 | fail!(:invalid_yk_otp)
12 | end
13 | end
14 | end
15 | end
16 | end
17 | end
18 |
19 | Warden::Strategies.add(:yk_otp_authenticatable, Devise::Strategies::YkOtpAuthenticatable)
20 |
--------------------------------------------------------------------------------
/lib/lockfile.rb:
--------------------------------------------------------------------------------
1 | # Naive implementation of a lock file mechanism should be sufficient for
2 | # long running rake tasks
3 | module Lockfile
4 | def self.lock(base_name, &block)
5 | file_name = File.join(Rails.root, "tmp", "#{base_name.to_s}.lock")
6 |
7 | # Kill any lock older than an hour
8 | if File.exists?(file_name)
9 | if File.new(file_name).ctime < DateTime.now.advance(:hours => -1)
10 | File.unlink(file_name)
11 | end
12 | end
13 |
14 | unless File.exists?(file_name)
15 | # Just in case the temp directory does not exist
16 | FileUtils.mkdir_p(File.join(Rails.root, "tmp"))
17 |
18 | File.open(file_name, "w") { |f| f.write("Locked by process #{$$}") }
19 |
20 | begin
21 | block.call
22 | ensure
23 | File.unlink(file_name)
24 | end
25 | end
26 | end
27 | end
28 |
--------------------------------------------------------------------------------
/lib/tasks/.gitkeep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/davout/bitcoin-central/25f056bf8589df213013b012e3d4e5d3e7cf919f/lib/tasks/.gitkeep
--------------------------------------------------------------------------------
/lib/tasks/deployment.rake:
--------------------------------------------------------------------------------
1 | namespace :deployment do
2 | desc "Renders the different static pages from templates under views/static"
3 | task :render_static_pages => :environment do
4 | view_path = Rails.configuration.view_path
5 |
6 | Dir.glob(File.join(view_path, "static/*")).each do |page|
7 | page_name = "#{File.basename(page).gsub(/\.[^\.]+/, "")}.html"
8 | template = File.join("static", File.basename(page))
9 |
10 | File.open(File.join(Rails.root, "public", page_name), "w") do |f|
11 | f.write(ActionView::Base.new(view_path).render(:template => template, :layout => "layouts/static"))
12 | end
13 | end
14 | end
15 |
16 | desc "Generates TOTP secrets for all users which don't have one already"
17 | task :generate_missing_otp_secrets => :environment do
18 | User.where("otp_secret IS NULL").all.each do |u|
19 | u.send(:generate_otp_secret)
20 | u.save(:validate => false)
21 | end
22 | end
23 | end
--------------------------------------------------------------------------------
/lib/tasks/liberty_reserve.rake:
--------------------------------------------------------------------------------
1 | namespace :liberty_reserve do
2 | desc "Fetches the last 20 transactions and check whether they've been mapped correctly to transfers"
3 | task :synchronize_transactions => :environment do
4 | lr = LibertyReserve::Client.instance
5 |
6 | # For each currency fetch transactions,
7 | # for each fetched ID check existence and create if necessary
8 | ["LREUR", "LRUSD"].each do |c|
9 | lr.history(c).each do |t|
10 | Transfer.create_from_lr_transaction_id(t[:lr_transaction_id])
11 | end
12 | end
13 | end
14 | end
--------------------------------------------------------------------------------
/lib/tasks/notifications.rake:
--------------------------------------------------------------------------------
1 | namespace :notifications do
2 | desc "Deliver recent trades notification"
3 | task :trades => :environment do
4 | Lockfile.lock(:notify_trades) do
5 | User.where(:notify_on_trade => true).each do |u|
6 | purchases = Trade.where(:buyer_id => u.id).where("id > ?", u.last_notified_trade_id).all
7 | sales = Trade.where(:seller_id => u.id).where("id > ?", u.last_notified_trade_id).all
8 |
9 | unless purchases.blank? && sales.blank?
10 | UserMailer.trade_notification(u, sales, purchases).deliver
11 | u.update_attribute(:last_notified_trade_id, [purchases.map(&:id), sales.map(&:id)].flatten.max)
12 | end
13 | end
14 | end
15 | end
16 | end
--------------------------------------------------------------------------------
/lib/validators/bitcoin_address_validator.rb:
--------------------------------------------------------------------------------
1 | class BitcoinAddressValidator < ActiveModel::EachValidator
2 | def validate_each(record, field, value)
3 | unless (value.blank? or Bitcoin::Util.valid_bitcoin_address?(value))
4 | record.errors[field] << (I18n.t "errors.invalid")
5 | end
6 | end
7 | end
8 |
--------------------------------------------------------------------------------
/lib/validators/blank_validator.rb:
--------------------------------------------------------------------------------
1 | class BlankValidator < ActiveModel::EachValidator
2 | def validate_each(record, field, value)
3 | unless value.blank?
4 | record.errors[field] << (I18n.t "errors.messages.should_be_blank")
5 | end
6 | end
7 | end
8 |
--------------------------------------------------------------------------------
/lib/validators/iban_validator.rb:
--------------------------------------------------------------------------------
1 | class IbanValidator < ActiveModel::EachValidator
2 | def validate_each(record, field, value)
3 | unless (value.blank? or IBANTools::IBAN.valid?(value))
4 | IBANTools::IBAN.new(value).validation_errors.each { |e| record.errors[field] << I18n.t("errors.messages.#{e}") }
5 | end
6 | end
7 | end
8 |
--------------------------------------------------------------------------------
/lib/validators/maximal_amount_validator.rb:
--------------------------------------------------------------------------------
1 | class MaximalAmountValidator < ActiveModel::EachValidator
2 | def validate_each(record, field, value)
3 | if value && (value > record.account.max_withdraw_for(record.currency))
4 | record.errors[field] << I18n.t("errors.messages.max_amount", :maximum => record.account.max_withdraw_for(record.currency), :currency => record.currency)
5 | end
6 | end
7 | end
8 |
--------------------------------------------------------------------------------
/lib/validators/minimal_amount_validator.rb:
--------------------------------------------------------------------------------
1 | class MinimalAmountValidator < ActiveModel::EachValidator
2 | def validate_each(record, field, value)
3 | if value and (value.abs < Transfer.minimal_amount_for(record.currency))
4 | record.errors[field] << I18n.t("errors.min_amount", :minimum => Transfer.minimal_amount_for(record.currency), :currency => record.currency)
5 | end
6 | end
7 | end
8 |
--------------------------------------------------------------------------------
/lib/validators/minimal_order_amount_validator.rb:
--------------------------------------------------------------------------------
1 | class MinimalOrderAmountValidator < ActiveModel::EachValidator
2 | def validate_each(record, field, value)
3 | if value and (value.abs < 0.01)
4 | record.errors[field] << (I18n.t "errors.min_amount", :minimum=>0.01, :currency=>"BTC")
5 | end
6 | end
7 | end
8 |
--------------------------------------------------------------------------------
/lib/validators/minimal_order_ppc_validator.rb:
--------------------------------------------------------------------------------
1 | class MinimalOrderPpcValidator < ActiveModel::EachValidator
2 | def validate_each(record, field, value)
3 | if value and (value.abs < 0.0001)
4 | record.errors[:base] << (I18n.t "errors.ppc_minimum", :currency => record.currency)
5 | end
6 | end
7 | end
8 |
--------------------------------------------------------------------------------
/lib/validators/negative_validator.rb:
--------------------------------------------------------------------------------
1 | class NegativeValidator < ActiveModel::EachValidator
2 | def validate_each(record, field, value)
3 | if value && (value > 0)
4 | record.errors[field] << I18n.t("errors.messages.should_be_negative")
5 | end
6 | end
7 | end
8 |
9 |
--------------------------------------------------------------------------------
/lib/validators/not_mine_validator.rb:
--------------------------------------------------------------------------------
1 | class NotMineValidator < ActiveModel::EachValidator
2 | def validate_each(record, field, value)
3 | unless value.blank?
4 | if Bitcoin::Util.valid_bitcoin_address?(value)
5 | if Bitcoin::Util.my_bitcoin_address?(value)
6 | if Bitcoin::Util.get_account(value).to_i == record.account.id
7 | record.errors[field] << (I18n.t "errors.not_your_address")
8 | end
9 | end
10 | end
11 | end
12 | end
13 | end
14 |
--------------------------------------------------------------------------------
/lib/validators/url_validator.rb:
--------------------------------------------------------------------------------
1 | class UrlValidator < ActiveModel::EachValidator
2 | def validate_each(record, field, value)
3 | unless value.blank?
4 | record.errors[field] << "Invalid URL" unless URI::regexp(%w(http https)) =~ value
5 | end
6 | end
7 | end
8 |
9 |
--------------------------------------------------------------------------------
/lib/validators/user_balance_validator.rb:
--------------------------------------------------------------------------------
1 | class UserBalanceValidator < ActiveModel::EachValidator
2 | def validate_each(record, field, value)
3 | if record.new_record? and value and (value < 0) and record.account.is_a?(User) and (value.abs > record.account.balance(record.currency))
4 | record.errors[field] << (I18n.t "errors.greater_than_balance", :balance => record.account.balance(record.currency), :currency => record.currency)
5 | end
6 | end
7 | end
8 |
--------------------------------------------------------------------------------
/lib/yubico/client.rb:
--------------------------------------------------------------------------------
1 | require 'net/https'
2 |
3 | module Yubico
4 | class Client
5 | include Singleton
6 |
7 | configuration = YAML::load(File.open(File.join(Rails.root, "config", "yubico.yml")))[Rails.env]
8 |
9 | API_URL = configuration["api_url"]
10 | API_ID = configuration["api_id"]
11 | API_KEY = configuration["api_key"]
12 |
13 | def verify_otp(otp)
14 | uri = URI.parse(API_URL) + 'verify'
15 | uri.query = "id=#{API_ID}&otp=#{otp}"
16 |
17 | http = Net::HTTP.new(uri.host, uri.port)
18 | http.use_ssl = true
19 |
20 | req = Net::HTTP::Get.new(uri.request_uri)
21 | result = http.request(req).body
22 |
23 | status = result[/status=(.*)$/,1].strip
24 |
25 | status == "OK" || (status == "REPLAYED_OTP" && raise(Yubico::ReplayedOTPError))
26 | end
27 | end
28 | end
--------------------------------------------------------------------------------
/lib/yubico/replayed_otp_error.rb:
--------------------------------------------------------------------------------
1 | module Yubico
2 | class ReplayedOTPError < StandardError; end
3 | end
--------------------------------------------------------------------------------
/public/404.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Bitcoin Central
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
HTTP 404 - The requested resource could not be found
13 |
You may have mistyped the address or the resource may have moved.
14 |
15 |
16 |
17 |
18 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/public/422.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | The change you wanted was rejected (422)
5 |
17 |
18 |
19 |
20 |
21 |
22 |
The change you wanted was rejected.
23 |
Maybe you tried to change something you didn't have access to.
24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/public/500.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Bitcoin Central
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
HTTP 500 - Internal server error
13 |
An error has occurred, we apologize for the inconvenience.
14 |
We have been notified and will take a look shortly.
15 |
16 |
17 |
18 |
19 |
22 |
23 |
24 |
--------------------------------------------------------------------------------
/public/maintenance.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Bitcoin Central
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
Bitcoin-Central.net is currently down for maintenance
13 |
14 | We're working hard to get it back online as soon as possible. We apologize for the inconvenience.
15 |
16 |
17 |
18 |
19 |
20 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/public/robots.txt:
--------------------------------------------------------------------------------
1 | # See http://www.robotstxt.org/wc/norobots.html for documentation on how to use the robots.txt file
2 | #
3 | # To ban all spiders from the entire site uncomment the next two lines:
4 | # User-Agent: *
5 | # Disallow: /
6 |
--------------------------------------------------------------------------------
/script/rails:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env ruby1.8
2 | # This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
3 |
4 | APP_PATH = File.expand_path('../../config/application', __FILE__)
5 | require File.expand_path('../../config/boot', __FILE__)
6 | require 'rails/commands'
7 |
--------------------------------------------------------------------------------
/test/functional/accounts_controller_test.rb:
--------------------------------------------------------------------------------
1 | require 'test_helper'
2 |
3 | class AccountsControllerTest < ActionController::TestCase
4 | test "should render deposits page" do
5 | login_with(Factory(:user))
6 | get :deposit
7 | assert_response :success
8 | end
9 |
10 | test "should get pecunix deposit form" do
11 | login_with(Factory(:user))
12 | get :pecunix_deposit_form, :format => :js
13 | assert_response :success
14 | end
15 |
16 | test "should get balances in json" do
17 | login_with(Factory(:user))
18 | get :show, :format => :json
19 | assert_response :success
20 | end
21 | end
22 |
--------------------------------------------------------------------------------
/test/functional/admin/account_operations_controller_test.rb:
--------------------------------------------------------------------------------
1 | require 'test_helper'
2 |
3 | class Admin::AccountOperationsControllerTest < ActionController::TestCase
4 | test "one doesn't just walk into admin interface" do
5 | login_with Factory(:user)
6 | get :index, :user_id => Factory(:user).id
7 |
8 | assert_response :redirect
9 | assert_redirected_to root_path
10 | end
11 |
12 | test "admins get to rob you" do
13 | login_with Factory(:admin)
14 | get :index, :user_id => Factory(:user).id
15 |
16 | assert_response :success
17 | end
18 | end
19 |
--------------------------------------------------------------------------------
/test/functional/admin/announcements_controller_test.rb:
--------------------------------------------------------------------------------
1 | require 'test_helper'
2 |
3 | class Admin::AnnouncementsControllerTest < ActionController::TestCase
4 | end
5 |
--------------------------------------------------------------------------------
/test/functional/admin/currencies_controller_test.rb:
--------------------------------------------------------------------------------
1 | require 'test_helper'
2 |
3 | class Admin::CurrenciesControllerTest < ActionController::TestCase
4 | end
5 |
--------------------------------------------------------------------------------
/test/functional/admin/informations_controller_test.rb:
--------------------------------------------------------------------------------
1 | require 'test_helper'
2 |
3 | class Admin::InformationsControllerTest < ActionController::TestCase
4 | end
5 |
--------------------------------------------------------------------------------
/test/functional/admin/pending_transfers_controller_test.rb:
--------------------------------------------------------------------------------
1 | require 'test_helper'
2 |
3 | class Admin::PendingTransfersControllerTest < ActionController::TestCase
4 | end
5 |
--------------------------------------------------------------------------------
/test/functional/admin/static_pages_controller_test.rb:
--------------------------------------------------------------------------------
1 | require 'test_helper'
2 |
3 | class Admin::StaticPagesControllerTest < ActionController::TestCase
4 | test "should show index properly" do
5 | login_with Factory(:admin)
6 | get :index
7 | assert_response :success
8 | end
9 | end
10 |
--------------------------------------------------------------------------------
/test/functional/admin/tickets_controller_test.rb:
--------------------------------------------------------------------------------
1 | require 'test_helper'
2 |
3 | class Admin::TicketsControllerTest < ActionController::TestCase
4 | end
5 |
--------------------------------------------------------------------------------
/test/functional/admin/users_controller_test.rb:
--------------------------------------------------------------------------------
1 | require 'test_helper'
2 |
3 | class Admin::UsersControllerTest < ActionController::TestCase
4 | test "should get users admin" do
5 | login_with Factory(:admin)
6 | get :index
7 | assert_response :success
8 | end
9 | end
10 |
--------------------------------------------------------------------------------
/test/functional/admin/yubikeys_controller_test.rb:
--------------------------------------------------------------------------------
1 | require 'test_helper'
2 |
3 | class Admin::YubikeysControllerTest < ActionController::TestCase
4 | end
5 |
--------------------------------------------------------------------------------
/test/functional/backup_mailer_test.rb:
--------------------------------------------------------------------------------
1 | require 'test_helper'
2 |
3 | class BackupMailerTest < ActionMailer::TestCase
4 | end
5 |
--------------------------------------------------------------------------------
/test/functional/bank_accounts_controller_test.rb:
--------------------------------------------------------------------------------
1 | require 'test_helper'
2 |
3 | class BankAccountsControllerTest < ActionController::TestCase
4 | end
5 |
--------------------------------------------------------------------------------
/test/functional/comments_controller_test.rb:
--------------------------------------------------------------------------------
1 | require 'test_helper'
2 |
3 | class CommentsControllerTest < ActionController::TestCase
4 | end
5 |
--------------------------------------------------------------------------------
/test/functional/informations_controller_test.rb:
--------------------------------------------------------------------------------
1 | require 'test_helper'
2 |
3 | class InformationsControllerTest < ActionController::TestCase
4 | test "should get frontpage" do
5 | get :welcome
6 | assert_response :success
7 | end
8 | end
9 |
--------------------------------------------------------------------------------
/test/functional/qrcodes_controller_test.rb:
--------------------------------------------------------------------------------
1 | require 'test_helper'
2 |
3 | class QrcodesControllerTest < ActionController::TestCase
4 | # Replace this with your real tests.
5 | test "the truth" do
6 | assert true
7 | end
8 | end
9 |
--------------------------------------------------------------------------------
/test/functional/registrations_controller_test.rb:
--------------------------------------------------------------------------------
1 | require 'test_helper'
2 |
3 | class RegistrationsControllerTest < ActionController::TestCase
4 | def setup
5 | @request.env["devise.mapping"] = Devise.mappings[:user]
6 | end
7 |
8 | test "should sign-in user and redirect to account after sign-up" do
9 | User.any_instance.stubs(:skip_captcha).returns(true)
10 |
11 | assert_difference "ActionMailer::Base.deliveries.size" do
12 | assert_difference "User.count" do
13 | post :create, :user => {
14 | :email => "user@example.com",
15 | :password => "123456",
16 | :password_confirmation => "123456"
17 | }
18 | end
19 |
20 | assert_response :redirect
21 | assert_redirected_to root_path
22 | end
23 | end
24 | end
25 |
--------------------------------------------------------------------------------
/test/functional/static_pages_controller_test.rb:
--------------------------------------------------------------------------------
1 | require 'test_helper'
2 |
3 | class StaticPagesControllerTest < ActionController::TestCase
4 | end
5 |
--------------------------------------------------------------------------------
/test/functional/tickets_controller_test.rb:
--------------------------------------------------------------------------------
1 | require 'test_helper'
2 |
3 | class TicketsControllerTest < ActionController::TestCase
4 | end
5 |
--------------------------------------------------------------------------------
/test/functional/trades_controller_test.rb:
--------------------------------------------------------------------------------
1 | require 'test_helper'
2 |
3 | class TradesControllerTest < ActionController::TestCase
4 | test "should render ticker" do
5 | assert session[:current_user_id].nil?, "We should not be logged-in"
6 |
7 | [:json, :xml].each do |f|
8 | get :ticker, :format => f
9 | assert_response :success
10 | end
11 | end
12 |
13 | test "should render trades list" do
14 | t1 = Factory(:user)
15 | t2 = Factory(:user)
16 |
17 | add_money(t1, 1000, :btc)
18 | add_money(t2, 1000, :eur)
19 |
20 | Factory(:limit_order,
21 | :amount => 1,
22 | :category => "sell",
23 | :ppc => 1,
24 | :user => t1,
25 | :currency => "EUR"
26 | )
27 |
28 | t = Factory(:market_order,
29 | :amount => 1,
30 | :category => "buy",
31 | :user => t2,
32 | :currency => "EUR"
33 | )
34 |
35 | assert_difference "Trade.count" do
36 | t.execute!
37 | end
38 |
39 | login_with(Factory(:user))
40 | get :index
41 | assert_response :success
42 | end
43 | end
44 |
--------------------------------------------------------------------------------
/test/functional/user_mailer_test.rb:
--------------------------------------------------------------------------------
1 | require 'test_helper'
2 |
3 | class UserMailerTest < ActionMailer::TestCase
4 | end
5 |
--------------------------------------------------------------------------------
/test/functional/users_controller_test.rb:
--------------------------------------------------------------------------------
1 | require 'test_helper'
2 |
3 | class UsersControllerTest < ActionController::TestCase
4 | def setup
5 | @user = login_with(Factory(:user))
6 | end
7 |
8 | test "should render account edition form" do
9 | get :edit
10 | assert_response :success
11 | end
12 |
13 | test "should reset google auth otp" do
14 | old_token = @user.ga_otp_secret
15 |
16 | post :reset_ga_otp_secret
17 | assert_response :redirect
18 | assert_redirected_to ga_otp_configuration_user_path
19 |
20 | assert_not_equal old_token, @user.reload.ga_otp_secret
21 | end
22 |
23 | test "should show google auth otp configuration page" do
24 | get :ga_otp_configuration
25 | assert_response :success
26 | end
27 |
28 | test "should render account edition form for manager" do
29 | sign_out(:user)
30 | get :edit
31 | assert_response :redirect
32 |
33 | manager = Factory(:manager)
34 | sign_in(:user, manager)
35 |
36 | get :edit
37 | assert_response :success
38 | end
39 | end
40 |
--------------------------------------------------------------------------------
/test/functional/yubikeys_controller_test.rb:
--------------------------------------------------------------------------------
1 | require 'test_helper'
2 |
3 | class YubikeysControllerTest < ActionController::TestCase
4 | end
5 |
--------------------------------------------------------------------------------
/test/integration/google_authenticator_test.rb:
--------------------------------------------------------------------------------
1 | require 'test_helper'
2 |
3 | class GoogleAuthenticatorTest < ActionDispatch::IntegrationTest
4 | test "should not be able to authenticate without otp" do
5 | u = Factory.build(:user)
6 | u.require_ga_otp = true
7 | u.generate_ga_otp_secret
8 | u.save!
9 |
10 | # Authenticating without OTP will fail
11 | post user_session_path, :user => {
12 | :name => u.name,
13 | :password => u.password
14 | }
15 |
16 | assert_response :success
17 |
18 | # Wrong OTP should fail too
19 | post user_session_path, :user => {
20 | :name => u.name,
21 | :password => u.password,
22 | :ga_otp => "424242"
23 | }
24 |
25 | assert_response :success
26 |
27 | # Correct OTP should work
28 | post user_session_path, :user => {
29 | :name => u.name,
30 | :password => u.password,
31 | :ga_otp => ROTP::TOTP.new(u.ga_otp_secret).now
32 | }
33 |
34 | assert_response :redirect
35 | assert_redirected_to account_path
36 | end
37 | end
38 |
--------------------------------------------------------------------------------
/test/integration/liberty_reserve_sci_test.rb:
--------------------------------------------------------------------------------
1 | require 'test_helper'
2 |
3 | class LibertyReserveSciTest < ActionDispatch::IntegrationTest
4 | test "should create a liberty reserve deposit if nicely asked" do
5 | user = Factory(:user,
6 | :id => 1959,
7 | :email => "lr_recipient@domain.tld",
8 | :password => "password",
9 | :password_confirmation => "password"
10 | )
11 |
12 | params = {
13 | "lr_encrypted2" => "F10A0B287EBD1DDF3471DB1FBA6AE90D7D3B81D7C335E3E51E15B6F6F5360654",
14 | "lr_amnt" => "30.00",
15 | "lr_merchant_ref" => "1959",
16 | "action" => "lr_transfer_success",
17 | "lr_paidto" => "U8651415",
18 | "account_id" => "1959",
19 | "lr_encrypted" => "20EAD57CC98F7069C7420E950D6245EC14201F6ED7142082D5AEE05B92FF9C0B",
20 | "lr_transfer" => "64203620",
21 | "controller" => "third_party_callbacks",
22 | "lr_store" => "Bitcoin Central",
23 | "lr_fee_amnt" => "0.00",
24 | "lr_timestamp" => "2011-26-06 18:51:27",
25 | "lr_currency" => "LRUSD",
26 | "lr_paidby" => "U6509825"
27 | }
28 |
29 | assert_difference "user.account_operations.count" do
30 | post '/third_party_callbacks/lr_create_from_sci', params
31 | assert_response :success
32 | end
33 |
34 | # Test that posting a second time doesn't create another transfer
35 | assert_no_difference "user.account_operations.count" do
36 | post '/third_party_callbacks/lr_create_from_sci', params
37 | assert_response :success
38 | end
39 | end
40 | end
41 |
--------------------------------------------------------------------------------
/test/integration/redirection_after_login_test.rb:
--------------------------------------------------------------------------------
1 | require 'test_helper'
2 |
3 | class RedirectionAfterLoginTest < ActionDispatch::IntegrationTest
4 | test "should redirect to originally requested page after login" do
5 | user = Factory(:user)
6 |
7 | post user_session_path, :user => {
8 | :name => user.email,
9 | :password => user.password
10 | }
11 |
12 | assert_response :redirect
13 | assert_redirected_to account_path
14 |
15 | # The GET is Devise's :X
16 | get destroy_user_session_path
17 |
18 | get account_trade_orders_path
19 | assert_response :redirect
20 | assert_redirected_to new_user_session_path
21 |
22 | follow_redirect!
23 | assert_template 'devise/sessions/new'
24 |
25 | post user_session_path, :user => {
26 | :name => user.email,
27 | :password => user.password
28 | }
29 |
30 | assert_response :redirect
31 | assert_redirected_to account_trade_orders_path
32 | end
33 | end
34 |
--------------------------------------------------------------------------------
/test/performance/browsing_test.rb:
--------------------------------------------------------------------------------
1 | require 'test_helper'
2 | require 'rails/performance_test_help'
3 |
4 | class BrowsingTest < ActionDispatch::PerformanceTest
5 | end
6 |
--------------------------------------------------------------------------------
/test/test_helper.rb:
--------------------------------------------------------------------------------
1 | ENV["RAILS_ENV"] = "test"
2 |
3 | require File.expand_path('../../config/environment', __FILE__)
4 | require 'rails/test_help'
5 |
6 | class ActiveSupport::TestCase
7 | def login_with(user)
8 | sign_in(:user, user)
9 | user
10 | end
11 |
12 | def add_money(user, amount, currency)
13 | o = Factory(:operation)
14 |
15 | o.account_operations << Factory.build(:account_operation,
16 | :amount => amount,
17 | :account => user,
18 | :currency => currency.to_s.upcase
19 | )
20 |
21 | o.account_operations << Factory.build(:account_operation,
22 | :amount => -amount,
23 | :currency => currency.to_s.upcase
24 | )
25 | end
26 |
27 | def assert_destroyed(instance, message = nil)
28 | assert instance.class.find(:all, :conditions => ["id = ?", instance.id]).blank?,
29 | message || "#{instance.class} with ID #{instance.id} should have been destroyed"
30 | end
31 |
32 | def assert_not_destroyed(instance, message = nil)
33 | assert instance.class.find(:first, :conditions => ["id = ?", instance.id]),
34 | message || "#{instance.class} with ID #{instance.id} shouldn't have been destroyed"
35 | end
36 | end
37 |
38 | class ActionController::TestCase
39 | include Devise::TestHelpers
40 | end
41 |
--------------------------------------------------------------------------------
/test/unit/account_test.rb:
--------------------------------------------------------------------------------
1 | require 'test_helper'
2 |
3 | class AccountTest < ActiveSupport::TestCase
4 | test "should automatically create a storage account for each currency" do
5 | assert_difference 'Account.count' do
6 | Account.storage_account_for(:dummy)
7 | end
8 |
9 | # It shouldn't try to create the same account twice though
10 | assert_no_difference 'Account.count' do
11 | Account.storage_account_for(:dummy)
12 | end
13 | end
14 | end
15 |
--------------------------------------------------------------------------------
/test/unit/admin_test.rb:
--------------------------------------------------------------------------------
1 | require 'test_helper'
2 |
3 | class AdminTest < ActiveSupport::TestCase
4 | end
5 |
--------------------------------------------------------------------------------
/test/unit/announcement_test.rb:
--------------------------------------------------------------------------------
1 | require 'test_helper'
2 |
3 | class AnnouncementTest < ActiveSupport::TestCase
4 | test "active scope" do
5 | Factory.create(:announcement)
6 | assert_equal 1, Announcement.active.count
7 | Factory.create(:announcement, :active => false)
8 | assert_equal 1, Announcement.active.count
9 | assert_equal 2, Announcement.count
10 | end
11 | end
12 |
--------------------------------------------------------------------------------
/test/unit/bank_account_test.rb:
--------------------------------------------------------------------------------
1 | require 'test_helper'
2 |
3 | class BankAccountTest < ActiveSupport::TestCase
4 | end
5 |
--------------------------------------------------------------------------------
/test/unit/bitcoin_address_validator_test.rb:
--------------------------------------------------------------------------------
1 | require 'test_helper'
2 |
3 | class BitcoinAddressValidatorTest < ActiveSupport::TestCase
4 | test "bitcoin address validator should delegate to Bitcoin::Client.instance" do
5 | class TestModel
6 | include ActiveModel::Validations
7 | attr_accessor :address
8 | validates :address, :bitcoin_address => true
9 | end
10 |
11 | Bitcoin::Client.instance.expects(:validate_address).with("foo").once.returns({ 'isvalid' => true })
12 | test_instance = TestModel.new
13 | test_instance.address = "foo"
14 | test_instance.valid?
15 | end
16 | end
17 |
--------------------------------------------------------------------------------
/test/unit/comment_test.rb:
--------------------------------------------------------------------------------
1 | require 'test_helper'
2 |
3 | class CommentTest < ActiveSupport::TestCase
4 | end
5 |
--------------------------------------------------------------------------------
/test/unit/currency_test.rb:
--------------------------------------------------------------------------------
1 | require 'test_helper'
2 |
3 | class CurrencyTest < ActiveSupport::TestCase
4 | end
5 |
--------------------------------------------------------------------------------
/test/unit/helpers/accounts_helper_test.rb:
--------------------------------------------------------------------------------
1 | require 'test_helper'
2 |
3 | class AccountsHelperTest < ActionView::TestCase
4 | end
5 |
--------------------------------------------------------------------------------
/test/unit/helpers/admin/account_operations_helper_test.rb:
--------------------------------------------------------------------------------
1 | require 'test_helper'
2 |
3 | class Admin::AccountOperationsHelperTest < ActionView::TestCase
4 | end
5 |
--------------------------------------------------------------------------------
/test/unit/helpers/admin/announcements_helper_test.rb:
--------------------------------------------------------------------------------
1 | require 'test_helper'
2 |
3 | class Admin::AnnouncementsHelperTest < ActionView::TestCase
4 | end
5 |
--------------------------------------------------------------------------------
/test/unit/helpers/admin/currencies_helper_test.rb:
--------------------------------------------------------------------------------
1 | require 'test_helper'
2 |
3 | class Admin::CurrenciesHelperTest < ActionView::TestCase
4 | end
5 |
--------------------------------------------------------------------------------
/test/unit/helpers/admin/informations_helper_test.rb:
--------------------------------------------------------------------------------
1 | require 'test_helper'
2 |
3 | class Admin::InformationsHelperTest < ActionView::TestCase
4 | end
5 |
--------------------------------------------------------------------------------
/test/unit/helpers/admin/pending_transfers_helper_test.rb:
--------------------------------------------------------------------------------
1 | require 'test_helper'
2 |
3 | class Admin::PendingTransfersHelperTest < ActionView::TestCase
4 | end
5 |
--------------------------------------------------------------------------------
/test/unit/helpers/admin/static_pages_helper_test.rb:
--------------------------------------------------------------------------------
1 | require 'test_helper'
2 |
3 | class Admin::StaticPagesHelperTest < ActionView::TestCase
4 | end
5 |
--------------------------------------------------------------------------------
/test/unit/helpers/admin/tickets_helper_test.rb:
--------------------------------------------------------------------------------
1 | require 'test_helper'
2 |
3 | class Admin::TicketsHelperTest < ActionView::TestCase
4 | end
5 |
--------------------------------------------------------------------------------
/test/unit/helpers/admin/users_helper_test.rb:
--------------------------------------------------------------------------------
1 | require 'test_helper'
2 |
3 | class Admin::UsersHelperTest < ActionView::TestCase
4 | end
5 |
--------------------------------------------------------------------------------
/test/unit/helpers/admin/yubikeys_helper_test.rb:
--------------------------------------------------------------------------------
1 | require 'test_helper'
2 |
3 | class Admin::YubikeysHelperTest < ActionView::TestCase
4 | end
5 |
--------------------------------------------------------------------------------
/test/unit/helpers/application_helper_test.rb:
--------------------------------------------------------------------------------
1 | require 'test_helper'
2 |
3 | class ApplicationHelperTest < ActionView::TestCase
4 | test "admin menu options should be for admins" do
5 | assert display_menu?(Factory.build(:admin), :admin => true)
6 | assert !display_menu?(Factory.build(:user), :admin => true)
7 | end
8 |
9 | test "merchant menu options should be for merchants and admins" do
10 | assert display_menu?(Factory.build(:admin), :merchant => true)
11 | assert display_menu?(Factory.build(:user, :merchant => true), :merchant => true)
12 | assert !display_menu?(Factory.build(:user), :merchant=> true)
13 | end
14 |
15 | test "logged-in menu options should not be available publicly" do
16 | assert display_menu?(Factory.build(:user), :logged_in => true)
17 | assert !display_menu?(nil, :logged_in => true)
18 | end
19 |
20 | test "public menu options should be public" do
21 | assert display_menu?(Factory.build(:admin), {})
22 | assert display_menu?(Factory.build(:user, :merchant => true), {})
23 | assert display_menu?(Factory.build(:user), {})
24 | assert display_menu?(nil, {})
25 | end
26 |
27 | test "locale switch link should work as expected" do
28 | assert_equal "https://fr.domain.tld/path.extension?query=string&x=y",
29 | locale_switch_link("fr", "https://en.domain.tld/path.extension?query=string&x=y")
30 |
31 | assert_equal "https://fr.domain.tld/path.extension?query=string&x=y",
32 | locale_switch_link("fr", "https://domain.tld/path.extension?query=string&x=y")
33 | end
34 | end
35 |
--------------------------------------------------------------------------------
/test/unit/helpers/bank_accounts_helper_test.rb:
--------------------------------------------------------------------------------
1 | require 'test_helper'
2 |
3 | class BankAccountsHelperTest < ActionView::TestCase
4 | end
5 |
--------------------------------------------------------------------------------
/test/unit/helpers/bitcoin_transfers_helper_test.rb:
--------------------------------------------------------------------------------
1 | require 'test_helper'
2 |
3 | class BitcoinTransfersHelperTest < ActionView::TestCase
4 | end
5 |
--------------------------------------------------------------------------------
/test/unit/helpers/bitcoin_withdrawals_helper_test.rb:
--------------------------------------------------------------------------------
1 | require 'test_helper'
2 |
3 | class BitcoinWithdrawalsHelperTest < ActionView::TestCase
4 | end
5 |
--------------------------------------------------------------------------------
/test/unit/helpers/charts_helper_test.rb:
--------------------------------------------------------------------------------
1 | require 'test_helper'
2 |
3 | class ChartsHelperTest < ActionView::TestCase
4 | end
5 |
--------------------------------------------------------------------------------
/test/unit/helpers/comments_helper_test.rb:
--------------------------------------------------------------------------------
1 | require 'test_helper'
2 |
3 | class CommentsHelperTest < ActionView::TestCase
4 | end
5 |
--------------------------------------------------------------------------------
/test/unit/helpers/informations_helper_test.rb:
--------------------------------------------------------------------------------
1 | require 'test_helper'
2 |
3 | class InformationsHelperTest < ActionView::TestCase
4 | end
5 |
--------------------------------------------------------------------------------
/test/unit/helpers/invoices_helper_test.rb:
--------------------------------------------------------------------------------
1 | require 'test_helper'
2 |
3 | class InvoicesHelperTest < ActionView::TestCase
4 | end
5 |
--------------------------------------------------------------------------------
/test/unit/helpers/liberty_reserve_transfer_helper_test.rb:
--------------------------------------------------------------------------------
1 | require 'test_helper'
2 |
3 | class LibertyReserveTransferHelperTest < ActionView::TestCase
4 | end
5 |
--------------------------------------------------------------------------------
/test/unit/helpers/liberty_reserve_withdrawals_helper_test.rb:
--------------------------------------------------------------------------------
1 | require 'test_helper'
2 |
3 | class LibertyReserveWithdrawalsHelperTest < ActionView::TestCase
4 | end
5 |
--------------------------------------------------------------------------------
/test/unit/helpers/qrcodes_helper_test.rb:
--------------------------------------------------------------------------------
1 | require 'test_helper'
2 |
3 | class QrcodesHelperTest < ActionView::TestCase
4 | end
5 |
--------------------------------------------------------------------------------
/test/unit/helpers/registrations_helper_test.rb:
--------------------------------------------------------------------------------
1 | require 'test_helper'
2 |
3 | class RegistrationsHelperTest < ActionView::TestCase
4 | end
5 |
--------------------------------------------------------------------------------
/test/unit/helpers/static_pages_helper_test.rb:
--------------------------------------------------------------------------------
1 | require 'test_helper'
2 |
3 | class StaticPagesHelperTest < ActionView::TestCase
4 | end
5 |
--------------------------------------------------------------------------------
/test/unit/helpers/tickets_helper_test.rb:
--------------------------------------------------------------------------------
1 | require 'test_helper'
2 |
3 | class TicketsHelperTest < ActionView::TestCase
4 | end
5 |
--------------------------------------------------------------------------------
/test/unit/helpers/trade_orders_helper_test.rb:
--------------------------------------------------------------------------------
1 | require 'test_helper'
2 |
3 | class TradeOrdersHelperTest < ActionView::TestCase
4 | end
5 |
--------------------------------------------------------------------------------
/test/unit/helpers/trades_helper_test.rb:
--------------------------------------------------------------------------------
1 | require 'test_helper'
2 |
3 | class TradesHelperTest < ActionView::TestCase
4 | end
5 |
--------------------------------------------------------------------------------
/test/unit/helpers/transfers_helper_test.rb:
--------------------------------------------------------------------------------
1 | require 'test_helper'
2 |
3 | class TransfersHelperTest < ActionView::TestCase
4 | end
5 |
--------------------------------------------------------------------------------
/test/unit/helpers/users_helper_test.rb:
--------------------------------------------------------------------------------
1 | require 'test_helper'
2 |
3 | class UsersHelperTest < ActionView::TestCase
4 | end
5 |
--------------------------------------------------------------------------------
/test/unit/helpers/yubikeys_helper_test.rb:
--------------------------------------------------------------------------------
1 | require 'test_helper'
2 |
3 | class YubikeysHelperTest < ActionView::TestCase
4 | end
5 |
--------------------------------------------------------------------------------
/test/unit/manager_test.rb:
--------------------------------------------------------------------------------
1 | require 'test_helper'
2 |
3 | class ManagerTest < ActiveSupport::TestCase
4 | end
5 |
--------------------------------------------------------------------------------
/test/unit/monkey_patches_test.rb:
--------------------------------------------------------------------------------
1 | require 'test_helper'
2 |
3 | class MonkeyPatchesTest < ActiveSupport::TestCase
4 | test "should have SERIALIZABLE isolation level in transactions" do
5 | r = nil
6 |
7 | ActiveRecord::Base.transaction do
8 | r = ActiveRecord::Base.
9 | connection.
10 | execute("SELECT @@GLOBAL.tx_isolation, @@tx_isolation").
11 | to_a.
12 | flatten
13 | end
14 |
15 | assert_equal "SERIALIZABLE", r[1], "MySQL Transactions should run in SERIALIZABLE isolation level"
16 | end
17 |
18 | # IMO this should be fixed at Rails level
19 | # https://github.com/rails/rails/blob/master/activesupport/lib/active_support/json/encoding.rb
20 | # Oh yeah, also #as_json is buggy...
21 | # http://ternarylabs.com/2010/09/07/migrating-to-rails-3-0-gotchas-as_json-bug/
22 | test "BigDecimal should be serialized correctly in JSON" do
23 | d = BigDecimal("10")
24 | assert_equal "10.0", d.to_json
25 | end
26 |
27 | # Apparently it's not enough to override BigDecimal#to_json to get correct
28 | # hash serialization...
29 | test "hash serialization should honor raw BigDecimal serialization override" do
30 | data = { :amount => BigDecimal("10") }
31 | assert_equal "{\"amount\":10.0}", data.to_json
32 | end
33 | end
--------------------------------------------------------------------------------
/test/unit/operation_test.rb:
--------------------------------------------------------------------------------
1 | require 'test_helper'
2 |
3 | class OperationTest < ActiveSupport::TestCase
4 | test "should not be valid if debit and credit are not equal for each currency" do
5 | o = Factory(:operation)
6 |
7 | o.account_operations << Factory.build(:account_operation, :currency => "EUR", :amount => 10.0.to_d)
8 | o.account_operations << Factory.build(:account_operation, :currency => "LREUR", :amount => 10.0.to_d)
9 |
10 | assert !o.valid?
11 |
12 | o.account_operations << Factory.build(:account_operation, :currency => "EUR", :amount => -10.0.to_d)
13 |
14 | assert !o.valid?
15 |
16 | o.account_operations << Factory.build(:account_operation, :currency => "LREUR", :amount => -10.0.to_d)
17 |
18 | assert o.valid?
19 | end
20 | end
21 |
--------------------------------------------------------------------------------
/test/unit/rails_test.rb:
--------------------------------------------------------------------------------
1 | require 'test_helper'
2 |
3 | class RailsTest < ActiveSupport::TestCase
4 | # This should be fixed in Rails itself
5 | # https://github.com/rails/rails/blob/master/activesupport/lib/active_support/core_ext/big_decimal/conversions.rb
6 | test "BigDecimal#to_d should return self" do
7 | d = BigDecimal("10")
8 | assert_equal d.to_d, d, "BigDecimal#to_d did not return self"
9 | end
10 | end
--------------------------------------------------------------------------------
/test/unit/static_page_test.rb:
--------------------------------------------------------------------------------
1 | require 'test_helper'
2 |
3 | class StaticPageTest < ActiveSupport::TestCase
4 | end
5 |
--------------------------------------------------------------------------------
/test/unit/ticket_test.rb:
--------------------------------------------------------------------------------
1 | require 'test_helper'
2 |
3 | class TicketTest < ActiveSupport::TestCase
4 | end
5 |
--------------------------------------------------------------------------------
/test/unit/trade_test.rb:
--------------------------------------------------------------------------------
1 | require 'test_helper'
2 |
3 | class TradeTest < ActiveSupport::TestCase
4 | test "trade shouldn't happen with traded btc or currency being zero" do
5 | u = Factory(:user)
6 | to = Factory.build(:limit_order,
7 | :category => "sell",
8 | :currency => "EUR",
9 | :user_id => "0"
10 | )
11 |
12 | to.save :validate => false
13 |
14 | t = Trade.new do |t|
15 | t.purchase_order = to
16 | t.sale_order = to
17 | t.seller = u
18 | t.buyer = u
19 | t.currency = "EUR"
20 | end
21 |
22 | assert !t.valid?
23 |
24 | t.traded_btc = 1
25 |
26 | assert !t.valid?
27 |
28 | t.traded_btc = 0
29 | t.traded_currency = 1
30 |
31 | assert !t.valid?
32 |
33 | t.traded_btc = 1
34 |
35 | assert t.valid?
36 | end
37 | end
38 |
--------------------------------------------------------------------------------
/test/unit/transfer_test.rb:
--------------------------------------------------------------------------------
1 | require 'test_helper'
2 |
3 | class TransferTest < ActiveSupport::TestCase
4 | test "transfer should fail with very small amount" do
5 | t = Factory.build(:transfer) do |t|
6 | t.amount = 0.0001
7 | t.currency = "LREUR"
8 | t.account = Factory(:user)
9 | end
10 |
11 | assert !t.valid?
12 | assert t.errors[:amount].any? { |e| e =~ /should not be smaller than/ }
13 | end
14 |
15 | test "should return correct class for transfer" do
16 | assert_equal Transfer.class_for_transfer(:eur), WireTransfer
17 | assert_equal Transfer.class_for_transfer(:lrusd), LibertyReserveTransfer
18 | assert_equal Transfer.class_for_transfer(:lreur), LibertyReserveTransfer
19 | assert_equal Transfer.class_for_transfer(:btc), BitcoinTransfer
20 |
21 | assert_raise RuntimeError do
22 | Transfer.class_for_transfer(:bogus)
23 | end
24 | end
25 | end
26 |
--------------------------------------------------------------------------------
/test/unit/url_validator_test.rb:
--------------------------------------------------------------------------------
1 | require 'test_helper'
2 |
3 | class UrlValidatorTest < ActiveSupport::TestCase
4 | test "should consider an invoice invalid with an invalid url" do
5 | Bitcoin::Util.stubs(:valid_bitcoin_address?).returns(true)
6 | Bitcoin::Client.instance.stubs(:get_new_address).returns("foo")
7 |
8 | invoice = Invoice.new({
9 | :user => Factory(:user),
10 | :amount => 100,
11 | :payment_address => '1FXWhKPChEcUnSEoFQ3DGzxKe44MDbatz'
12 | })
13 |
14 | assert !invoice.valid?
15 |
16 | invoice.callback_url = "http://sub.domain.tld:8080/callback"
17 |
18 | assert invoice.valid?
19 | end
20 | end
21 |
--------------------------------------------------------------------------------
/test/unit/used_currency_test.rb:
--------------------------------------------------------------------------------
1 | require 'test_helper'
2 |
3 | class UsedCurrencyTest < ActiveSupport::TestCase
4 | end
5 |
--------------------------------------------------------------------------------
/test/unit/wire_transfer_test.rb:
--------------------------------------------------------------------------------
1 | require 'test_helper'
2 |
3 | class WireTransferTest < ActiveSupport::TestCase
4 | test "should be created in pending state" do
5 | u = Factory(:user)
6 | add_money(u, 1000, :eur)
7 | w = Factory(:wire_transfer, :account => u, :bank_account => Factory(:bank_account, :user => u))
8 | assert w.pending?
9 | end
10 |
11 | test "should get processed correctly" do
12 | u = Factory(:user)
13 | add_money(u, 1000, :eur)
14 | w = Factory(:wire_transfer, :account => u, :bank_account => Factory(:bank_account, :user => u))
15 | w.process!
16 | assert w.processed?
17 | end
18 | end
19 |
--------------------------------------------------------------------------------
/test/unit/yubikey_test.rb:
--------------------------------------------------------------------------------
1 | require 'test_helper'
2 |
3 | class YubikeyTest < ActiveSupport::TestCase
4 | test "should initialize key properly from otp" do
5 | Yubico::Client.instance.expects(:verify_otp).with("cccccccnccfudvebtledcgvnikvbijhhgjutverdlurv").returns(true)
6 |
7 | Yubikey.create! do |y|
8 | y.otp = "cccccccnccfudvebtledcgvnikvbijhhgjutverdlurv"
9 | y.user = Factory(:user)
10 | end
11 | end
12 | end
13 |
--------------------------------------------------------------------------------