Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions examples.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,14 @@ echo '### The same, on testnet, with a fallback address mk2QpYatsKicvFVuTAQLBryy
./lightning-address.py encode $TIMESTAMP --currency=tb --fallback=mk2QpYatsKicvFVuTAQLBryyccRXMUaGHP --description-hashed="$LONG_DESCRIPTION" $(to_btc 24) $RHASH $PRIVKEY
echo

echo '### The same, on signet, with a fallback address mk2QpYatsKicvFVuTAQLBryyccRXMUaGHP'
./lightning-address.py encode $TIMESTAMP --currency=tbs --fallback=mk2QpYatsKicvFVuTAQLBryyccRXMUaGHP --description-hashed="$LONG_DESCRIPTION" $(to_btc 24) $RHASH $PRIVKEY
echo

echo '### The same, on regtest, with a fallback address mk2QpYatsKicvFVuTAQLBryyccRXMUaGHP'
./lightning-address.py encode $TIMESTAMP --currency=bcrt --fallback=mk2QpYatsKicvFVuTAQLBryyccRXMUaGHP --description-hashed="$LONG_DESCRIPTION" $(to_btc 24) $RHASH $PRIVKEY
echo

echo '### On mainnet, with fallback address 1RustyRX2oai4EYYDpQGWvEL62BBGqN9T with extra routing info to go via nodes 029e03a901b85534ff1e92c43c74431f7ce72046060fcf7a95c37e148f78c77255 then 039e03a901b85534ff1e92c43c74431f7ce72046060fcf7a95c37e148f78c77255'
./lightning-address.py encode $TIMESTAMP --route=029e03a901b85534ff1e92c43c74431f7ce72046060fcf7a95c37e148f78c77255/0102030405060708/1/20/3/039e03a901b85534ff1e92c43c74431f7ce72046060fcf7a95c37e148f78c77255/030405060708090a/2/30/4 --fallback=1RustyRX2oai4EYYDpQGWvEL62BBGqN9T --description-hashed="$LONG_DESCRIPTION" $(to_btc 24) $RHASH $PRIVKEY
echo
Expand Down
10 changes: 6 additions & 4 deletions lnaddr.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ def bitarray_to_u5(barr):
def encode_fallback(fallback, currency):
""" Encode all supported fallback addresses.
"""
if currency == 'bc' or currency == 'tb':
if currency == 'bc' or currency == 'tb' or currency == 'tbs' or currency == 'bcrt':
fbhrp, witness = bech32_decode(fallback)
if fbhrp:
if fbhrp != currency:
Expand All @@ -100,7 +100,7 @@ def encode_fallback(fallback, currency):
raise NotImplementedError("Support for currency {} not implemented".format(currency))

def parse_fallback(fallback, currency):
if currency == 'bc' or currency == 'tb':
if currency == 'bc' or currency == 'tb' or currency == 'tbs' or currency == 'bcrt':
wver = fallback[0:5].uint
if wver == 17:
addr=base58.b58encode_check(bytes([base58_prefix_map[currency][0]])
Expand All @@ -119,8 +119,10 @@ def parse_fallback(fallback, currency):

# Map of classical and witness address prefixes
base58_prefix_map = {
'bc' : (0, 5),
'tb' : (111, 196)
'bc' : (0, 5),
'tb' : (111, 196),
'tbs' : (111, 196),
'bcrt': (111, 196),
}

def is_p2pkh(currency, prefix):
Expand Down