Giter Site home page Giter Site logo

support for Injective about bip_utils HOT 6 CLOSED

Jackson-DKMG avatar Jackson-DKMG commented on August 15, 2024
support for Injective

from bip_utils.

Comments (6)

ebellocchia avatar ebellocchia commented on August 15, 2024

Hi, I have to add it. If it is like the other coins built on Cosmos it shoud be pretty quick.

Regards,
Emanuele

from bip_utils.

Jackson-DKMG avatar Jackson-DKMG commented on August 15, 2024

Thanks for the quick reply!
That would be awesome.

from bip_utils.

ebellocchia avatar ebellocchia commented on August 15, 2024

Hello, I added Injective as a coin.

Please note that Injective uses a different algorithm for encoding the address with respect to other Cosmos-based coins, as you can see in the code snippet from their docs. So I added a specific address encoder/decoder just for it.
With my implementation, I get the same addresses of Cosmostation wallet, which I always use as reference for Cosmos-based coins.

I don't know if the cosmpy library uses the Injective algorithm or just the standard Cosmos algorithm for encoding the address. I took a quick look and found no trace of it in the code. So, if you get different addresses with respect to cosmpy it's because of that.

from bip_utils.

Jackson-DKMG avatar Jackson-DKMG commented on August 15, 2024

Hello,

Great and thanks a lot
This works as intended, although indeed when using Cosmpy the result is still wrong:

from cosmpy.aerial.wallet import LocalWallet
from cosmpy.crypto.keypairs import PrivateKey, PublicKey

bip44_mst_ctx = Bip44.FromSeed(seed_bytes, Bip44Coins.INJECTIVE)
bip44_acc_ctx = bip44_mst_ctx.Purpose().Coin().Account(0)
bip44_chg_ctx = bip44_acc_ctx.Change(Bip44Changes.CHAIN_EXT)

bip44_addr_ctx = bip44_chg_ctx.AddressIndex(0)   #index 0 appears to be the right one here

print(bip44_addr_ctx.PublicKey().ToAddress())  # --> CORRECT ADDRESS

print(LocalWallet(PrivateKey(bip44_addr_ctx.PrivateKey().Raw().ToBytes()), prefix='inj')) #--> WRONG ADDRESS

I've ran a number of tests this morning but couldn't find a solution. I'll try some more and open an issue with the Cosmpy team if still no success.

from bip_utils.

ebellocchia avatar ebellocchia commented on August 15, 2024

That's because it uses the standard Cosmos algorithm, to get the same result with bip_utils:

print(LocalWallet(PrivateKey(bip44_addr_ctx.PrivateKey().Raw().ToBytes()), prefix="inj"))
# Same address
print(AtomAddrEncoder.EncodeKey(
    bip44_addr_ctx.PublicKey().Bip32Key().KeyObject(),
    hrp="inj"
))

from bip_utils.

Jackson-DKMG avatar Jackson-DKMG commented on August 15, 2024

Indeed
I'll mention this in the issue.

from bip_utils.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.