chaintope / bitcoinrb

The implementation of the bitcoin protocol for ruby.
MIT License
61 stars 19 forks source link

Bitcoin::Wallet::Base.current_wallet return wrong value when it include '-' in dir name. #35

Closed JunOkumura closed 5 years ago

JunOkumura commented 5 years ago

Bitcoin::Wallet::Base Line 51: wallet_id = path.delete(path_prefix + '/wallet').delete("/").to_i It is failed when path_prefix include '-'.

Steps to Reproduce

irb(main):001:0>"/bitcoinrb-grpc/.bitcoinrb/regtest/db/wallet/wallet1/".delete("/bitcoinrb-grpc/.bitcoinrb/regtest/db/wallet/" + '/wallet').delete('/').to_i
=> -1

Expect

example: "/bitcoinrb-grpc/.bitcoinrb/regtest/db/wallet/wallet1/".delete("/bitcoinrb-grpc/.bitcoinrb/regtest/db/wallet/" + '/wallet').delete('/').to_i result: 1

Actual

result: -1 application failed.

That is wrong use to String#delete. String#delete can use range character.

irb(main):001:0> "12345".delete("1-3")
=> "45"