Python script to generate a Ravencoin burn address.

Based on burn-btc By James C. Stroud with some usability improvements.

Requries ravencoinlib: pip install python-ravencoinlib

#!/usr/bin/env python3

import sys
import binascii
import argparse

from hashlib import sha256

from ravencoin.base58 import encode as b58encode
from ravencoin.base58 import decode as b58decode
from ravencoin.wallet import CRavencoinAddress, CBitcoinAddressError

ABET = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"
template_default = "RVNBurnTest"

parser = argparse.ArgumentParser(description='Generate a Ravencoin burn address.')
parser.add_argument("template",help="Template for burn address. Max 28 letters & numbers (no zeros). Longer strings will be truncated",nargs='?',default=template_default)

class BurnError(Exception):

class AlphabetError(BurnError):

def hh256(s):
  s = sha256(s).digest()
  return binascii.hexlify(sha256(s).digest())

def b58ec(s):
  unencoded = bytearray.fromhex(s.decode())
  encoded = b58encode(unencoded)
  return encoded

def b58dc(encoded, trim=0):
  unencoded = b58decode(encoded)[:-trim]
  return unencoded

def burn(s):
  decoded = b58dc(s, trim=4)
  decoded_hex = binascii.hexlify(decoded)
  check = hh256(decoded)[:8]
  coded = decoded_hex + check
  return b58ec(coded)

if __name__ == "__main__":
  args = parser.parse_args()
  template = args.template
  if template[0] != "R":
     raise AlphabetError("Template must begin with the letter R")
  for c in template:
    if c not in ABET:
      raise AlphabetError("Character {} is not valid base58.".format(c))
    tlen = len(template)
    if tlen < 34:
      template = template + ((34 - tlen) * "X")
      template = template[:34]
     burn_address = CRavencoinAddress(burn(template)) 
  except CBitcoinAddressError:
     print("'{}' is not a valid template (Must begin with the letter R followed by a capital letter e.g. 'RV')".format(args.template))

I encountered a situation where it was necessary to refresh the shipping cost estimate on a Magento2 site.

A solution is provided by Alan Storm:

], function(quote, rateRegistry){
    var address = quote.shippingAddress();

    address.trigger_reload = new Date().getTime();

    rateRegistry.set(address.getKey(), null);
    rateRegistry.set(address.getCacheKey(), null);


However a small change is required for Magento 2.3 at least (likely 2.2+):

], function(quote, rateRegistry, cartCache){
    var address = quote.shippingAddress();

    address.trigger_reload = new Date().getTime();

    rateRegistry.set(address.getKey(), null);
    rateRegistry.set(address.getCacheKey(), null);



ElectrumX is a server implementation for the lightweight crypto wallet Electrum. This update adds support for Ravencoin (mainnet and testnet) for use with the electrum-raven client.

Requests is great. But if you’ve ever used it you may have encountered a problem with your app hanging for seemingly no reason.

(If you haven’t encountered that, then you will at some point, and it may well cause you serious pain)

The cause is very simple, yet non obvious, and it lies hidden at the bottom of the quickstart documentation:

You can tell Requests to stop waiting for a response after a given number of seconds with the timeout parameter. Nearly all production code should use this parameter in nearly all requests. Failure to do so can cause your program to hang indefinitely

Yes, the default timeout for a request is infinity

I’m sure there is some logic behind this, but really this should be at the top of the page in bright red flashing letters. So here it is in bright red flashing letters


To avoid problems, then, we should set an appropriate timeout value on all requests

connect_timeout=31 # number of seconds to wait for connection to be established
read_timeout=5 # maximum number of seconds between data reads

r = requests.get('', timeout=(connect_timeout, read_timeout))