Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions lib/errors.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,8 @@ def initialize(message, payment_id, txid)
@payment_id = payment_id
@txid = txid
end

class WalletPrivateSeedNotFoundError < StandardError
end
end
end
12 changes: 9 additions & 3 deletions lib/pi_network.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,12 @@ class PiNetwork
attr_reader :base_url
attr_reader :from_address

def initialize(api_key, wallet_private_key, options = {})
validate_private_seed_format!(wallet_private_key)
def initialize(api_key, options = {})
wallet_private_seed = options[:wallet_private_seed]
validate_private_seed_format!(wallet_private_seed) if wallet_private_seed.present?

@api_key = api_key
@account = load_account(wallet_private_key)
@account = load_account(wallet_private_seed)
@base_url = options[:base_url] || "https://api.minepi.com"

@open_payments = {}
Expand Down Expand Up @@ -57,6 +59,10 @@ def create_payment(payment_data)
end

def submit_payment(payment_id)
raise Errors::WalletPrivateSeedNotFoundError.new(
"You need to initialize the SDK with wallet_private_seed to call this method."
) if self.account.nil?

payment = @open_payments[payment_id]

if payment.nil? || payment["identifier"] != payment_id
Expand Down
2 changes: 1 addition & 1 deletion pinetwork.gemspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Gem::Specification.new do |s|
s.name = "pinetwork"
s.version = "0.1.2"
s.version = "0.2.0"
s.summary = "Pi Network Ruby"
s.description = "Pi Network backend library for Ruby-based webservers."
s.authors = ["Pi Core Team"]
Expand Down