From d0dd554e3868c1fada556e44a94715d6a9e10f4e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Sa=C5=82aban?= Date: Thu, 18 Oct 2018 23:20:27 +0200 Subject: [PATCH 1/2] Add new RPC error code pending as PR --- monero/backends/jsonrpc.py | 5 +++-- monero/exceptions.py | 3 +++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/monero/backends/jsonrpc.py b/monero/backends/jsonrpc.py index d7c5efd..b0df597 100644 --- a/monero/backends/jsonrpc.py +++ b/monero/backends/jsonrpc.py @@ -361,7 +361,8 @@ _err2exc = { -16: exceptions.TransactionNotPossible, -17: exceptions.NotEnoughMoney, -20: exceptions.AmountIsZero, - -37: exceptions.NotEnoughUnlockedMoney, # PR pending: https://github.com/monero-project/monero/pull/3197 - -38: exceptions.NoDaemonConnection, # PR 3197 + -37: exceptions.NotEnoughUnlockedMoney, + -38: exceptions.NoDaemonConnection, + -43: exceptions.WalletIsNotDeterministic, # https://github.com/monero-project/monero/pull/4653 -32601: MethodNotFound, } diff --git a/monero/exceptions.py b/monero/exceptions.py index ef2bca3..389fbb5 100644 --- a/monero/exceptions.py +++ b/monero/exceptions.py @@ -38,3 +38,6 @@ class TransactionNotFound(AccountException): class SignatureCheckFailed(MoneroException): pass + +class WalletIsNotDeterministic(MoneroException): + pass From f5c16b58ef376b2633e33bc7232dcf944d60cf8f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Sa=C5=82aban?= Date: Thu, 18 Oct 2018 23:26:47 +0200 Subject: [PATCH 2/2] Make walletdump not crash on non-deterministic wallets --- utils/walletdump.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/utils/walletdump.py b/utils/walletdump.py index 90595b9..bdf6b5f 100755 --- a/utils/walletdump.py +++ b/utils/walletdump.py @@ -4,7 +4,8 @@ import logging import operator import re -from monero.backends.jsonrpc import JSONRPCWallet +from monero import exceptions +from monero.backends.jsonrpc import JSONRPCWallet, RPCError from monero.wallet import Wallet def url_data(url): @@ -54,6 +55,10 @@ print( addr=a2str(masteraddr), total=w.balance(), unlocked=w.balance(unlocked=True))) +try: + seed = w.seed() +except (exceptions.WalletIsNotDeterministic, RPCError): # FIXME: Remove RPCError once PR#4563 is merged in monero + seed = '[--- wallet is not deterministic and has no seed ---]' print( "Keys:\n" \ " private spend: {ssk}\n" \ @@ -65,7 +70,7 @@ print( svk=w.view_key(), psk=masteraddr.spend_key(), pvk=masteraddr.view_key(), - seed=w.seed() + seed=seed )) if len(w.accounts) > 1: