Bitcoin Forum

Bitcoin => Development & Technical Discussion => Topic started by: krashfire on June 19, 2024, 05:37:16 AM



Title: Generating your own BTC and ETH Wallet
Post by: krashfire on June 19, 2024, 05:37:16 AM
I saw some comments looking for a sample btc wallet with private and public key so you can run your programs on some samples or you just want to create a wallet so you can be anonymous.


 i created the btc program that can generate 10 sets of btc address that can give you the btc and eth address from 1 hexadecimal private key.

you can download it here.

https://github.com/KrashKrash/btc-addr-generator


result:

Code:

----------------------------------------
--------- Crypto Address Set 9 ---------

  Private Key (Hexadecimal): e7d0e560866f6937e5e88ada34c618591fb18bb82d79f92b344405cadcc34596
  Private Key (Decimal): 104853355314434413654784855654564514135795858537712704988978113470536008025494

  Uncompressed Bitcoin Address:
  - Bitcoin Address: 1MfYXZomYUCuohussdVB589Pk5F7fny8o2
  - Private Key (WIF): 5KaP1YEDyn9B8Fro1jm8mwYiRivXBmkjGG7GE8QZ8i4E4BgSfdE
  - Public Key: 0471541d2a80ae53183b511bc69411926eae7a871b36c7fac0c335a2db64156be3e0fff493eed9d00d4e0a873b28a3e5f315ab8a7924cd202e7e53647e2be04694

  Compressed Bitcoin Address:
  - Bitcoin Address: 1JcAnTReAwE2c77wXoxNYpffGKQWXPLHC5
  - Private Key (WIF): L4zL9NqNHcF5h2an6FjoKMkyr83EEYY1YMgeCwgxq2DEcgwAauNt
  - Public Key: 0271541d2a80ae53183b511bc69411926eae7a871b36c7fac0c335a2db64156be3

  P2SH Bitcoin Address:
  - Bitcoin Address: 3NMZT7JD6NXHtscJzj9mVkWKtbXqCce5nb

  Bech32 Bitcoin Address:
  - Bitcoin Address: bc1qcysd6vyhc7x732xf7p3jkjh0lazgc0tffwt9fc

  Ethereum Address:
  - Ethereum Address: 0xb334353fb3a4a26ef5388e9554eac930a3f28318

----------------------------------------



Title: Re: Generating your own BTC and ETH Wallet
Post by: alexeyneu on June 19, 2024, 07:57:57 AM
Code:
    private_key = ecdsa.SigningKey.generate(curve=curve)

not good. what's used for rng seed here? you'll never know. It should be system-dependent at least like in bitcoin core  they use last windows messages to do so


src/qt/winshutdownmonitor.cpp

Code:
bool WinShutdownMonitor::nativeEventFilter(const QByteArray &eventType, void *pMessage, long *pnResult)
{
       Q_UNUSED(eventType);

       MSG *pMsg = static_cast<MSG *>(pMessage);

       // Seed OpenSSL PRNG with Windows event data (e.g.  mouse movements and other user interactions)
       if (RAND_event(pMsg->message, pMsg->wParam, pMsg->lParam) == 0) {
            // Warn only once as this is performance-critical
            static bool warned = false;
            if (!warned) {
                LogPrintf("%s: OpenSSL RAND_event() failed to seed OpenSSL PRNG with enough data.\n", __func__);
                warned = true;
            }
       }

       switch(pMsg->message)
       {
         .....

it's '17 bitcoin but sure it stays the same. File was unvisited for 5 years or so that time.


Title: Re: Generating your own BTC and ETH Wallet
Post by: apogio on June 19, 2024, 04:36:56 PM
I like the idea and the implementation. I haven't checked the technical aspect of the code, but the structure and the outcome look good.

I have a similar BASH script in my signature. You can check it out in case you find it interesting too.


Title: Re: Generating your own BTC and ETH Wallet
Post by: Forsyth Jones on June 19, 2024, 11:07:47 PM
Interesting, but I'll give you some opinions and if you want, you can implement them in your code to get better and better:

Do you know the BIP39 iancolaman (https://iancoleman.io/bip39/) website? It's a website that generates a mnemonic, seed, xprivs, derived keys, addresses, etc. It would be great to have a tool like this without needing to be on the website. It's possible to create this all in a script and run it on your machine.

It'd also be interesting for the script to generate all types of existing bitcoin addresses:

Code:
legacy - p2pkh
p2sh-segwit - p2wpkh-p2sh
bech32 - p2wpkh (native segwit v0)
bech32m - p2tr (taproot - native segwit v1)

Another similar interesting site for you to base yourself on, each with one more or less functionality:

https://bitcoiner.guide/seed/
https://gugger.guru/cryptography-toolkit/#!/hd-wallet

I don't advise anyone to generate wallets based on scripts we find out there, especially from strangers (unless you know how to review the code), as a bug could happen that could make you lose your funds.

But as long as you only use it for learning and testing, it's fine.

There are several similar scripts that we can find here on the forum and on this board.



Title: Re: Generating your own BTC and ETH Wallet
Post by: krashfire on June 20, 2024, 07:56:33 AM
I like the idea and the implementation. I haven't checked the technical aspect of the code, but the structure and the outcome look good.

I have a similar BASH script in my signature. You can check it out in case you find it interesting too.
thank you. ❤️


Title: Re: Generating your own BTC and ETH Wallet
Post by: krashfire on June 20, 2024, 07:57:37 AM
Interesting, but I'll give you some opinions and if you want, you can implement them in your code to get better and better:

Do you know the BIP39 iancolaman (https://iancoleman.io/bip39/) website? It's a website that generates a mnemonic, seed, xprivs, derived keys, addresses, etc. It would be great to have a tool like this without needing to be on the website. It's possible to create this all in a script and run it on your machine.

It'd also be interesting for the script to generate all types of existing bitcoin addresses:

Code:
legacy - p2pkh
p2sh-segwit - p2wpkh-p2sh
bech32 - p2wpkh (native segwit v0)
bech32m - p2tr (taproot - native segwit v1)

Another similar interesting site for you to base yourself on, each with one more or less functionality:

https://bitcoiner.guide/seed/
https://gugger.guru/cryptography-toolkit/#!/hd-wallet

I don't advise anyone to generate wallets based on scripts we find out there, especially from strangers (unless you know how to review the code), as a bug could happen that could make you lose your funds.

But as long as you only use it for learning and testing, it's fine.

There are several similar scripts that we can find here on the forum and on this board.


you mean like a stand alone? ahh. nice... ok. i will get back to you on this. interesting.