You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
CentOS 7
Python 3.6 with grpcio 1.25.0
btcwallet version 0.11.0-alpha
How to reproduce the bug
This is the code that can be used for reproducing the bug:
frommnemonicimportMnemonicimportosimportgrpcimportloggingfromcrypto.api_pb2_grpcimportWalletServiceStub, WalletLoaderServiceStub, VersionServiceStubimportcrypto.api_pb2asreqfrombase64importb64encodelogger=logging.getLogger(__name__)
logger.setLevel(logging.INFO)
classUsernamePasswordCallCredentials(grpc.AuthMetadataPlugin):
"""Metadata wrapper for raw access token credentials."""def__init__(self, username, password):
self._username=usernameself._password=passworddef__call__(self, context, callback):
credentials="{}:{}".format(self._username, self._password).encode()
basic_auth="Basic {}".format(b64encode(credentials).decode('ascii'))
metadata= (('authorization', basic_auth),)
callback(metadata, None)
classBitcoinProcessor:
"""Class used for defining Bitcoin operations The class uses gRPC API with btcwallet to access the bitcoin wallets and perform transactions :param hostname: The hostname to which to connect :param port: Port number :param username: Defined in btcwallet.conf. Usually the same username that is used to connect to the btcd API :param password: Defined in btcwallet.conf. Usually the same password that is used to connect to the btcd API """def__init__(
self, hostname, port, username, password,
secure=True,
ca_path='/data/btc/.btcwallet/ec-ca.crt',
cert_path='/data/btc/.btcwallet/client.cert',
key_path='/data/btc/.btcwallet/client.key'
):
self.http_credentials=grpc.metadata_call_credentials(
UsernamePasswordCallCredentials(username, password))
ifsecure:
certs= [os.path.abspath(ca_path), os.path.abspath(key_path), os.path.abspath(cert_path)]
cert_data=list()
forfileincerts:
withopen(file, 'rb') asf:
cert_data.append(f.read())
creds=grpc.ssl_channel_credentials(cert_data[0], cert_data[1], cert_data[2])
self.ic=grpc.secure_channel(hostname+':'+str(port), creds)
else:
self.ic=grpc.insecure_channel(hostname+":"+str(port))
def__del__(self):
self.ic.close()
defversion(self):
"""Gets the API version :return: The response from the gRPC API with the corresponding version description """stub=VersionServiceStub(self.ic)
try:
response=stub.Version.with_call(req.VersionRequest(), credentials=self.http_credentials)
exceptgrpc.RpcErrorase:
logger.info('Version failed with {0}: {1}'.format(e.code(), e.details()))
returnNonereturnresponsedefopen_wallet(self, public_passphrase=''):
"""Opens a pre-existing wallet :param public_passphrase: The public passphrase. If its length is zero, an insecure default is used instead. :return: OpenWalletResponse if successful and None in case of error """stub=WalletLoaderServiceStub(self.ic)
message=req.OpenWalletRequest(
public_passphrase=public_passphrase.encode('utf-8')
)
try:
response=stub.OpenWallet.with_call(message, credentials=self.http_credentials)
exceptgrpc.RpcErrorase:
logger.info('OpenWallet failed with {0}: {1}'.format(e.code(), e.details()))
returnNoneelse:
logger.info("Wallet opened:", response)
returnresponse
When the gRPC server is enabled with the --experimantalrpclisten flag it seems that it first registers the server Version and WalletLoader services and then starts the server. But after the wallet is loaded it tries to register the Wallet service and it fails because the gRPC server is already listening. Has this logic worked before? I don't think you can register gRPC services dynamically at runtime. Looking at git logs this implementation has been added to the codebase around 5 years ago 497ffc1 .
Maybe @jrick can shed some light on this since he's the one who implemented the gRPC features.
Environment
CentOS 7
Python 3.6 with grpcio 1.25.0
btcwallet version 0.11.0-alpha
How to reproduce the bug
This is the code that can be used for reproducing the bug:
Running the code:
Debug-level output from btcwallet:
Opening the wallet using the legacy RPC works properly. I see the following output from btcwallet in legacy mode:
and I can use btcctl to get the current balance:
The text was updated successfully, but these errors were encountered: