def test_encode_bis_url_legacy(verbose=False): recipient = "8342c1610de5d7aa026ca7ae6d21bd99b1b3a4654701751891f08742" amount = "1.234" operation = "" openfield = "" bis_url = BismuthUtil.create_bis_url(recipient, amount, operation, openfield, legacy=True) assert bis_url == "bis://pay/8342c1610de5d7aa026ca7ae6d21bd99b1b3a4654701751891f08742/1.234///Bg#w)r%}J-4Ct__J|z#_" recipient = "8342c1610de5d7aa026ca7ae6d21bd99b1b3a4654701751891f08742" amount = "1.234" operation = "token:transfer" openfield = "test:1" bis_url = BismuthUtil.create_bis_url(recipient, amount, operation, openfield, legacy=True) assert bis_url == "bis://pay/8342c1610de5d7aa026ca7ae6d21bd99b1b3a4654701751891f08742/1.234/bZ={AZaQ>wVQzC~WpV/bY*jNIxz/>H!cQZ*|L=^XYba0XP&1" recipient = "8342c1610de5d7aa026ca7ae6d21bd99b1b3a4654701751891f08742" amount = "1.234" operation = "token:transfer" openfield = 'test:1:{"Message":"Test message"}' bis_url = BismuthUtil.create_bis_url(recipient, amount, operation, openfield, legacy=True) assert bis_url == "bis://pay/8342c1610de5d7aa026ca7ae6d21bd99b1b3a4654701751891f08742/1.234/bZ={AZaQ>wVQzC~WpV/bY*jNIx#wXB28s;b75y?B03^eWpi{OZDn(FVP|C`eE/#04XIp(|p18$+t~x+8E0"
def test_encode_bis_url_new(verbose=False): recipient = "8342c1610de5d7aa026ca7ae6d21bd99b1b3a4654701751891f08742" amount = "1.234" operation = "" openfield = "" bis_url = BismuthUtil.create_bis_url(recipient, amount, operation, openfield, legacy=False) assert bis_url == "bis://8342c1610de5d7aa026ca7ae6d21bd99b1b3a4654701751891f08742/1.234///g2ietw==" recipient = "8342c1610de5d7aa026ca7ae6d21bd99b1b3a4654701751891f08742" amount = "1.234" operation = "token:transfer" openfield = "test:1" bis_url = BismuthUtil.create_bis_url(recipient, amount, operation, openfield, legacy=False) assert bis_url == "bis://8342c1610de5d7aa026ca7ae6d21bd99b1b3a4654701751891f08742/1.234/dG9rZW46dHJhbnNmZXI=/dGVzdDox/ldW-ig==" recipient = "8342c1610de5d7aa026ca7ae6d21bd99b1b3a4654701751891f08742" amount = "1.234" operation = "token:transfer" openfield = 'test:1:{"Message":"Test message"}' bis_url = BismuthUtil.create_bis_url(recipient, amount, operation, openfield, legacy=True) assert bis_url == "bis://pay/8342c1610de5d7aa026ca7ae6d21bd99b1b3a4654701751891f08742/1.234/bZ={AZaQ>wVQzC~WpV/bY*jNIx#wXB28s;b75y?B03^eWpi{OZDn(FVP|C`eE/#04XIp(|p18$+t~x+8E0"
async def receive(self, params=None): _ = self.locale.translate if not self.bismuth_vars["address"]: await self.message( _("Error:") + " " + _("No Wallet"), _("Load your wallet first"), "danger", ) return # print(self.bismuth.wallet()) if self.bismuth._wallet._locked: self.message( _("Error:") + " " + _("Encrypted wallet"), _("You have to unlock your wallet first"), "danger", ) return address = self.bismuth_vars["server"]["address"] self.settings["page_title"] = _("Receive BIS") bisurl = "" # print("address", self.get_query_argument('address', 'no')) if self.get_query_argument("address", False): address = self.get_query_argument("address") amount = "{:0.8f}".format(float(self.get_query_argument("amount", 0))) data = self.get_query_argument("data", "") self.bismuth_vars["params"]["address"] = address self.bismuth_vars["params"]["amount"] = amount self.bismuth_vars["params"]["data"] = data bisurl = BismuthUtil.create_bis_url(address, amount, "", data) self.render( "transactions_receive.html", bismuth=self.bismuth_vars, address=address, bisurl=bisurl, )
def test_bisurl(verbose=False): url = BismuthUtil.create_bis_url( "abcdef0123456789abcdef0123456789abcdef0123456789abcdef01", 0, "op:test", "openfield_data") if verbose: print("url1", url) assert ( url == "bis://pay/abcdef0123456789abcdef0123456789abcdef0123456789abcdef01/0/Z*V$vWpi`/Z*XO9W@%+?WM5=qbYT/c89#&9#h%MeO(h*k}9I|" ) url = BismuthUtil.create_bis_url( "abcdef0123456789abcdef0123456789abcdef0123456789abcdef01", 0, "bgvp:vote", "0:8ZmHckBjxb0DB8skooVAMw==") if verbose: print("url2", url) assert ( url == "bis://pay/abcdef0123456789abcdef0123456789abcdef0123456789abcdef01/0/VrO=6I(Bb#Wd/FgiF|ZAfElLTY$oFhoK)b8ByJRzXd7Jv{/e&RE#IbWW*)0CtVGcN-=" )
async def receive(self, params=None): query_params = self.extract_params() address = self.bismuth_vars['server']['address'] _ = self.locale.translate self.settings["page_title"] = _("Receive BIS") bisurl = '' if query_params.get('address', False): address = query_params['address'] bisurl = BismuthUtil.create_bis_url(address, query_params['amount'], '', query_params['data']) self.render("transactions_receive.html", bismuth=self.bismuth_vars, address=address, bisurl=bisurl)