In the docs it says: The checksum for a descriptor without one can be computed using the getdescriptorinfo RPC.

I would like to build a recovery tool where many descriptors are imported, calling getdescriptorinfo for each is cumbersome. Manually calculating the checksum would save a lot of time and network calls.

Do I just double sha256 the entire descriptor and convert the first 4 bytes to hex?

Thanks :)

EDIT: I found this, seems quite a bit more complex than a double hash... https://github.com/bitcoin/bitcoin/blob/master/src/script/descriptor.cpp#L95

1 Answer 1


You can take a look at the file bitcoin/test/functional/descriptors.py, there is a function to create the checksum:

def descsum_create(s):
    """Add a checksum to a descriptor without"""
    symbols = descsum_expand(s) + [0, 0, 0, 0, 0, 0, 0, 0]
    checksum = descsum_polymod(symbols) ^ 1
    return s + '#' + ''.join(CHECKSUM_CHARSET[(checksum >> (5 * (7 - i))) & 31] for i in range(8))

It has dependencies to descsum_expand and descsum_polymod but both are included in the same file.

Here is the Python code you will need:

from test_framework.descriptors import descsum_create

descriptor = 'addr(mkmZxiEcEd8ZqjQWVZuC6so5dFMKEFpN2j)'

descriptor_with_checksum = descsum_create(descriptor)



Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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