class Bip70::PaymentRequestCreator
Public Class Methods
run(outputs, merchant_data = '')
click to toggle source
# File lib/bip70/payment_request.rb, line 5 def self.run(outputs, merchant_data = '') outputs = outputs.map{ |output| Payments::Output.new(script: "#{output.fetch(:address)} OP_CHECKSIG", amount: output.fetch(:amount) { 0 }) } payment_details = Payments::PaymentDetails.new(merchant_data: merchant_data, time: Time.now.to_i) data = Payments::PaymentRequest.new(serialized_payment_details: payment_details.serialize_to_string) wrap_in_headers(data) end
Private Class Methods
wrap_in_headers(data)
click to toggle source
# File lib/bip70/payment_request.rb, line 18 def self.wrap_in_headers(data) filename = "req-#{Time.now.to_f}.bitcoinpaymenetrequest" output = <<-EOS Content-Type: application/bitcoin-paymentrequest Content-Disposition: inline; filename=#{filename} Content-Transfer-Encoding: binary Expires: 0 Cache-Control: must-revalidate, post-check=0, pre-check=0 Content-Length: #{data.serialize_to_string.length} #{data.serialize_to_string} EOS end