Skip to main content

Map email to Ripple addresses using the Federation protocol

Project description

ripple-federation-python

What ripple/federation-php does for Python. Provides a very simple mapping between names an Ripple addresses. Integrate into your site to receive Ripple payments at you@yourdomain.org.

Usage

Using werkzeug, for example, you might do:

CORS = {"Access-Control-Allow-Origin": "*"}

from .ripple_federation import Federation, get_ripple_txt
federation = Federation({
    'elsdoerfer.name': {'michael': 'rpLJBGZRT8D9ktgdsYv5AWYtePdyLPrEHy'},
})

@expose('/ripple.txt')
def ripple_txt(request):
    return Response(get_ripple_txt(
        domain=request.host,
        federation_url='https://{}{}'.format(
            request.host, request.urlmap.build('ripple_federation'))
        ),
        mimetype='text/plain',
        headers=CORS)


@expose('/ripple/federation')
def ripple_federation(request):
    return Response(
        json.dumps(federation.endpoint(request.args)),
        mimetype='application/json',
        headers=CORS
    )

To do more than just mapping the name to an address, you can specify callables:

def lookup_user(domain, user):
     ripple, destination_tag = findUser(domain, user)
     return {
        'destination_address': app.config['PAYMENT_ADDRESS'],
        'dt': int(user)
     }

federation = Federation({
    'elsdoerfer.name': lookup_user,
    'elsdoerfer.name': {'michael': callable_allowed_here_as_well},
})

The callable has to return a dict, which will be inserted into the result record, and may also overwrite the standard fields. In this way, you may provide any return values the Federation specification allows.

Other notes

Test your ripple.txt setup here: https://ripple.com/tools/txt/

Note that HTTPS is needed.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ripple-federation-1.1.3.tar.gz (2.7 kB view details)

Uploaded Source

File details

Details for the file ripple-federation-1.1.3.tar.gz.

File metadata

File hashes

Hashes for ripple-federation-1.1.3.tar.gz
Algorithm Hash digest
SHA256 c0051677ff5adb7fb3c19f9ccc09789ad6f81a297f085c96817f21443b741f65
MD5 09b046c61ae752cce272d8fb24199df9
BLAKE2b-256 23e4bcfcbd414ee27c14ff104fd76f7834f4d9d885d220fa9b74c62751ef2c74

See more details on using hashes here.

Provenance

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page