krtschmr / monero

Ruby client to connect to the Monero RPC
MIT License
24 stars 12 forks source link

NoMethodError: undefined method `confirmations=' #12

Closed rearden-steel closed 5 years ago

rearden-steel commented 5 years ago

I am getting this error while asking for transfers:

2.4.1 :008 > RPC::Wallet.get_all_incoming_transfers
NoMethodError: undefined method `confirmations=' for #<RPC::IncomingTransfer:0x007fdc8903b5e8>
Did you mean?  confirmations
    from /Users//.rvm/gems/ruby-2.4.1/gems/monero-0.0.0.8/lib/rpc/incoming_transfer.rb:8:in `block in initialize'
    from /Users//.rvm/gems/ruby-2.4.1/gems/monero-0.0.0.8/lib/rpc/incoming_transfer.rb:7:in `each'
    from /Users//.rvm/gems/ruby-2.4.1/gems/monero-0.0.0.8/lib/rpc/incoming_transfer.rb:7:in `initialize'
    from /Users//.rvm/gems/ruby-2.4.1/gems/monero-0.0.0.8/lib/rpc/wallet.rb:100:in `new'
    from /Users//.rvm/gems/ruby-2.4.1/gems/monero-0.0.0.8/lib/rpc/wallet.rb:100:in `block (2 levels) in get_transfers'

But if I add this class manually and specify it in RPC.config.transfer_clazz, it works:

2.4.1 :015 >   class IncomingTransfer
2.4.1 :016?>   
2.4.1 :017 >         attr_accessor :address, :amount, :double_spend_seen, :fee, :height, :note,
2.4.1 :018 >           :payment_id, :subaddr_index, :timestamp, :txid, :type, :unlock_time,
2.4.1 :019 >           :destinations, :confirmations, :suggested_confirmations_threshold
2.4.1 :020?>   
2.4.1 :021 >         def initialize(args={})
2.4.1 :022?>           args.each do |k,v|
2.4.1 :023 >                 self.send("#{k}=", v)
2.4.1 :024?>             end
2.4.1 :025?>         end
2.4.1 :026?>   
2.4.1 :027 >         def confirmed?
2.4.1 :028?>           confirmations >= 10
2.4.1 :029?>         end
2.4.1 :030?>   
2.4.1 :031 >         def pending?
2.4.1 :032?>           height == 0
2.4.1 :033?>         end
2.4.1 :034?>   
2.4.1 :035 >       end
 => :pending? 
2.4.1 :036 > RPC.config.transfer_clazz="IncomingTransfer"
 => "IncomingTransfer" 
2.4.1 :037 > RPC::Wallet.get_all_incoming_transfers(min_height: 1087400)
 => [#<IncomingTransfer:0x007fdc8698ddb0
....
krtschmr commented 5 years ago

we didn't updated the gem on rubygems.org yet

please use

gem "monero", github: "krtschmr/monero"

this should work then