export const TYPE_BITCOIN = "bitcoin" ; export const TYPE_LIGHTNING = "lightning" ; const prefixByType = { [ TYPE_BITCOIN ] : "bitcoin:" , } ; export const getFullUri = ( { input , amount , memo , uppercase = false , prefix = true , type = TYPE_BITCOIN , } ) : string => { if ( type === TYPE_LIGHTNING ) { return uppercase ? input . toUpperCase ( ) : input ; } const uriPrefix = prefix ? prefixByType [ type ] : "" ; const uri = `${ uriPrefix }${ input }` ; const params = new URLSearchParams ( ) ; if ( amount ) params . append ( "amount" , `${ satsToBTC ( amount ) }` ) ; if ( memo ) { params . append ( "message" , encodeURI ( memo ) ) ; return `${ uri }?${ params . toString ( ) }` ; } return uri + ( params . toString ( ) ? "?" + params . toString ( ) : "" ) ; } ; export const satsToBTC = ( satsAmount ) : number => satsAmount / 10 ** 8 ;