grin-wallet icon indicating copy to clipboard operation
grin-wallet copied to clipboard

owner_api panic if "open_wallet" is not called first

Open bladedoyle opened this issue 4 years ago • 2 comments

Describe the bug The owner-API panics when calling "retrieve_summary_info" if "open_wallet" is not called first.

20210114 10:07:24.259 ERROR grin_util::logger - 
thread 'tokio-runtime-worker' panicked at 'index 32 out of range for slice of length 0': /home/bdoyle/.cargo/registry/src/github.com-1ecc6299db9ec823/grin_core-5.0.1/src/libtx/secp_ser.rs:129   0: grin_util::logger::send_panic_to_log::{{closure}}
             at /home/bdoyle/.cargo/registry/src/github.com-1ecc6299db9ec823/grin_util-5.0.1/src/logger.rs:317
   1: std::panicking::rust_panic_with_hook
             at /rustc/04488afe34512aa4c33566eb16d8c912a3ae04f9/src/libstd/panicking.rs:530
   2: rust_begin_unwind
             at /rustc/04488afe34512aa4c33566eb16d8c912a3ae04f9/src/libstd/panicking.rs:437
   3: core::panicking::panic_fmt
             at /rustc/04488afe34512aa4c33566eb16d8c912a3ae04f9/src/libcore/panicking.rs:85
   4: core::slice::slice_index_len_fail
             at /rustc/04488afe34512aa4c33566eb16d8c912a3ae04f9/src/libcore/slice/mod.rs:2974
   5: <core::ops::range::Range<usize> as core::slice::SliceIndex<[T]>>::index
             at /rustc/04488afe34512aa4c33566eb16d8c912a3ae04f9/src/libcore/slice/mod.rs:3156
   6: core::slice::<impl core::ops::index::Index<I> for [T]>::index
             at /rustc/04488afe34512aa4c33566eb16d8c912a3ae04f9/src/libcore/slice/mod.rs:2955
   7: <alloc::vec::Vec<T> as core::ops::index::Index<I>>::index
             at /rustc/04488afe34512aa4c33566eb16d8c912a3ae04f9/src/liballoc/vec.rs:1975
   8: grin_core::libtx::secp_ser::option_seckey_serde::deserialize::{{closure}}::{{closure}}
             at /home/bdoyle/.cargo/registry/src/github.com-1ecc6299db9ec823/grin_core-5.0.1/src/libtx/secp_ser.rs:129
   9: core::result::Result<T,E>::and_then
             at /rustc/04488afe34512aa4c33566eb16d8c912a3ae04f9/src/libcore/result.rs:729
  10: grin_core::libtx::secp_ser::option_seckey_serde::deserialize::{{closure}}
             at /home/bdoyle/.cargo/registry/src/github.com-1ecc6299db9ec823/grin_core-5.0.1/src/libtx/secp_ser.rs:125
  11: core::result::Result<T,E>::and_then
             at /rustc/04488afe34512aa4c33566eb16d8c912a3ae04f9/src/libcore/result.rs:729
  12: grin_core::libtx::secp_ser::option_seckey_serde::deserialize
             at /home/bdoyle/.cargo/registry/src/github.com-1ecc6299db9ec823/grin_core-5.0.1/src/libtx/secp_ser.rs:124
  13: grin_wallet_api::types::_::<impl serde::de::Deserialize for grin_wallet_api::types::Token>::deserialize
             at /home/bdoyle/dev/grin-wallet/api/src/types.rs:40
  14: serde_json::value::from_value
             at /home/bdoyle/.cargo/registry/src/github.com-1ecc6299db9ec823/serde_json-1.0.57/src/value/mod.rs:1006
  15: <dyn grin_wallet_api::owner_rpc::OwnerRpc as easy_jsonrpc_mw::Handler>::handle
             at /home/bdoyle/dev/grin-wallet/api/src/owner_rpc.rs:356
  16: easy_jsonrpc_mw::handle_call
...
...

To Reproduce Using wallet_v3.py library: https://github.com/grinfans/grin.py

import os
from wallet_v3 import WalletV3

api_url="http://localhost:3420/v3/owner"
api_user="grin"
wallet_password = "abc"
api_secret="owner_api_secret"

wallet = WalletV3(api_url, api_user, api_secret)
shared_ecdh_key = wallet.init_secure_api()
#token = wallet.open_wallet(None, wallet_password)
result = wallet.retrieve_summary_info(refresh=True)
print(result)

Expected behavior An error message and not crash

bladedoyle avatar Jan 14 '21 18:01 bladedoyle

Note: I continue to see a wallet thread panic for this case even with the above fix.

bladedoyle avatar Mar 08 '21 20:03 bladedoyle

Same way to reproduce it?

quentinlesceller avatar Mar 08 '21 22:03 quentinlesceller