1200wd / bitcoinlib

Bitcoin and other Cryptocurrencies Library for Python. Includes a fully functional wallet, Mnemonic key generation and management and connection with various service providers to receive and send blockchain and transaction information.
http://bitcoinlib.readthedocs.io/
GNU General Public License v3.0
614 stars 204 forks source link

How to Connect vid LitecoindClient #301

Closed superggn closed 1 year ago

superggn commented 1 year ago

I want to connect to a third-party node without modifying the providers.json config, but in this way:

from bitcoinlib.services.litecoind import LitecoindClient
# this url is my own full node, not third party shared node
base_url = 'http://test:test@119.3.223.121:19332'
ldc = LitecoindClient(base_url=base_url)
txid = '9a509c68d230eda1e2dde539b47ae55db673af8df2dd3cb330d13c962d24dcb5'
t = ldc.gettransaction(txid)
print(t)

How can I do it?

Btw here's my third-party node info(it's a shared node)

url = 'https://ltc.getblock.io/39e5b219-1c6f-4ad2-8a59-9484c314c782/mainnet/'

The 39e5b219-1c6f-4ad2-8a59-9484c314c782 is my api-key, no need for other auth (it's a test api-key, and I'll delete it from my backoffice when this is solved, so no worry about the security)

superggn commented 1 year ago

here's what I tried

mccwdev commented 1 year ago

This looks like a problem with Litecoind client expecting a password when it is not needed in this case.

superggn commented 1 year ago

I see, so it is still a valid practice to connect to a third-party node via LitecoindClient. I'll use self-hosted node temporarily before this problem solved then

mccwdev commented 1 year ago

The Litecoind and Bitcoind service client have been updated. The url can have different formats and no username or password is required when using an API key. See dc985d6c9985881fd2e5e4d7b2fa3a326b997bdc and bd2cb442d2c11828e44226151d640ffedca4a461

However I'm not able to test with getblock.io specific as they charge large fees to spin up a server.

superggn commented 1 year ago

Hi @mccwdev , you can go here(https://getblock.io/) find "get start for free" to test or you can just use my test config, I already got the free one

  "litecoin": {
    "provider": "litecoind",
    "network": "litecoin",
    "client_class": "LitecoindClient",
    "provider_coin_id": "",
    "url": "https://ltc.getblock.io/39e5b219-1c6f-4ad2-8a59-9484c314c782/mainnet/",
    "api_key": "",
    "priority": 10,
    "denominator": 100000000,
    "network_overrides": null
  },

when I got time I'll also have a test, but unfortunately I can not apply this new version on out production environment, cause I saw the python version requirement is 3.9 (or 3.10?). Got a lower python3 version on our server(sad).

mccwdev commented 1 year ago

Thanks I will give it a try.

The library should work with python 3.7 and 3.8, I've made some update to the setup to avoid issues with the new numpy version.