So besides looking for those fancy vanity addresses,
is there a way to generate a valid address using a specific string, without needing the private or public keys?
I’m thinking about placing a permanent address on the blockchain by sending some leftover coins there.
I’m talking about doing this with Python 3, maybe using some kind of brute-force approach?
creating a valid address from a specific string
15 replies 112 views
Yes. Do this (no brute force necessary):
1. Avoid invalid characters (0OIl) in the string you are using
2. Your string has to be small enough to not exceed the standard address length (160 bit hash when decoded)
3. Convert your string to bytes and pad it with zeros until it is 160 bits (20 bytes)
4. Encode the result using Base58check (feed the 160-bit result to the encoder as if you are feeding the RIPEMD160 hash of a public key, it should add the address version byte to it and compute and append the checksum as well)
Please don't, you would be creating an unspendable UTXO that will remain in the UTXO set forever. Use OP_RETURN if you want to insert an arbitrary message into the chain...
I need the result address to have the string, not the bytes before base58check encoding.
An address cannot be an arbitrary string because the address itself is not stored in the block chain. Block chain explorers and wallets analyze a transaction to construct the address. As @pooya87 described, a legacy address is constructed from a 160-bit hash, plus a version and a checksum. The version and checksum are mostly out of your control.
The best you can do is an address like 1BitcoinEaterAddressDontSendf59kuE.
Also, segwit and taproot addresses have similar limitations.
You just given example of arbitrary string in blockchain as an address.
Yes, that is what I want to do. My own string in address. I don't need pvk nor pubkey.
Let's say I have "MyString" and I need to see it in address. Starting characters and ending can be any.
So, for example, I base58decode_check("MyStringChecksum"), I am getting bytes, add some at the end for proper length and checksum, and at the end base58encode_check the bytes giving me what I want.
I just don't know how to code that (mostly in Python 3).
I know the theory, I need working example of conversion.
I think you are simply looking for something like this.
Result :
If the String is bigger you will get a list of address output. Otherwise it will be just 1 address. Example
Is that what you want ?
Seems like yes, is there any python code to do that?
This library does not provide this function...
And how it is supposed to answer the question?
You don't have to brute force anything, since you only build a valid (burn) address, no key.
I've used a tool like that in the past, but I've accessed it as an online page where you wrote like "1Whatever" and it was creating an address starting with this.
Maybe searching the net for creating a burn address for bitcoin would give you results.
Or maybe you can check out what I've found via web search and I didn't check (I'm not familiar with python):
* https://gist.github.com/dancodery/e26890a60cd676ca8ca3af8c247d0bb8
* https://gist.github.com/spaceexpanse/b9b7ab1f88b85cc5b3e1509ec1c7441e
In a post from some time ago I shared this script, I think, but I couldn't find the link. You just have to respect the structure and not include characters that aren't in base58. I did it as a mini brute force to cover the bytes destined for the checksum so I could include more vanity characters.
Seems like exactly what I am looking for.
Will merit once I verify the script.
What to put in goal/prefix variables?
EDIT: it didn't found for me for few minutes (that's also too long).
But this script works [ https://gist.github.com/dancodery/e26890a60cd676ca8ca3af8c247d0bb8 ]:
Why you said it. The library has already the wrapper defined for this purpose. You just need 2 lines of code in python3 for your purpose, nothing else.
If you want to know the inside implementation of how it is done, then here is the defined function from the file secp256k1.py which is responsible.
goal = "1bitcointaLkforumburnLegacyaddress"
prefix = "1BitcoinTALKforumBurnLegacyaddr"
Basically, the prefix represents the minimum number of characters in the search target. And goal represents the ideal target.
If it takes a while to find a string, your burnaddress probably covers too much space in the checksum, which will make it take longer to find the ideal checksum to complete your address. The normal thing to do is to leave a little space for the checksum by reducing the length of the prefix string to find it quickly.
I am getting:
Tried the same way you have posted here.
Steps:
1. Git clone or download this to any Folder in your pc. https://github.com/iceland2k14/secp256k1
2. cd to same folder and then run python commands or scripts you desire. That will work.
The reason for failure is that you might have another library with the same name secp256k1 from some other repo.
Yep! It works! Thank you very much!
Related topics
- Need Help! Funds Gone / Wrong Address 10
- Vanitygen: Create Your Own Bitcoin Address with This Tool 19
- Bitcoin Core displaying coins (UTXOs) in a new tab 13
- Are you in favor of BIP-110? Let's get a Bitcoin poll going. 0
- Erlay seems to have some issues here’s a better proposal for a bitcoin protocol without invites 3
- New Optional Hourglass Implementation is Live 3