2

I've been trying the find the code in Vanitygen that does checks whether the generated address starts with the expected pattern.

Vanitygen repo: https://github.com/samr7/vanitygen

What I currently know:

4
+50

Recall that vanitygen allows you to list several patterns and search for addresses that match any of them. It looks to me like for each prefix, we compute the range of hash160 values that, after base58 encoding, would match the desired prefix. (Conveniently, the checksum only affects the end of the address, so we don't have to worry about it.) These ranges are put into an AVL tree. Then vg_prefix_avl_search takes a generated hash160 and searches the tree to see whether it matches any of the desired ranges. Note this means that base58 encoding doesn't actually have to be done at all for addresses that won't match.

If we are in regex matching mode instead, then the relevant code is in vg_regex_test which is pretty straightforward: compute the base58 encoding and match against the given regexes.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.