In production environement peatio is configured to force the user to use HTTPS to access the service (Rails option config.force_ssl = true
). This is a good security practice, reducing the risk of people to get there password or Cookie stolen by a man in the middle.
Then if you do a request to peatio inside the cluster in HTTP you will get the following response:
$ curl -i peatio-rails:8080
HTTP/1.1 301 Moved Permanently
Content-Type: text/html
Location: https://peatio-rails:8080/
Transfer-Encoding: chunked
Rails redirects you to the same url in https which is not valid since the protocol used is HTTP.
To bypass this problem you need to mimic the fact that you are doing a request from the proxy, adding the folloing header:
curl -H "X-Forwarded-Proto: https" peatio-rails:8080
WARNING: the user must NOT reuse the previous address.
member = Member.find_by(uid: "U123456789")
account = member.accounts.find_by(currency: "eth")
account.payment_address.destroy!
Then a new address will be generated one the fly when the user will request it, or you can run the following command to manually trigger the generation:
account.payment_address
Peatio contains internal mechanism to transfer funds from a user to an other. Here is an example how to use this feature, this could be used by the platform administrator to do manual settlements:
def create_transfer(transfer_attrs)
include API::V2::Management::Helpers
Transfer.transaction do
transfer = Transfer.create!(transfer_attrs.slice(:key, :kind, :desc))
transfer_attrs[:operations].map do |op_pair|
shared_params = { currency: op_pair[:currency],
reference: transfer }
debit_params = op_pair[:account_src]
.merge(debit: op_pair[:amount])
.merge(shared_params)
.compact
credit_params = op_pair[:account_dst]
.merge(credit: op_pair[:amount])
.merge(shared_params)
.compact
create_operation!(debit_params)
create_operation!(credit_params)
end
end
end
transfer_attrs = {
key: Time.now.to_i, # This should be unique.
kind: "member-transfer",
desc: "Internal money transfers between members on 2019-06-21T16:11:06",
operations: [
{
currency: :btc,
amount: 10,
account_src: {
code: 202,
uid: "U674918561"
},
account_dst: {
code: 202,
uid: "U334105020"
}
},
{
currency: :btc,
amount: 5,
account_src: {
code: 202,
uid: "U334105020"
},
account_dst: {
code: 202,
uid: "U674918561"
}
}
]
}
create_transfer(transfer_attrs)
Migrations are pending. To resolve this issue, run in a rails pod:
bundle exec rake db:migrate