From 398cebbab2701b13d6bb2934b015635772e6e37c Mon Sep 17 00:00:00 2001 From: 813492291816 Date: Mon, 7 Nov 2022 17:46:24 -0500 Subject: [PATCH] Add label argument to createChan API endpoint --- src/api.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/api.py b/src/api.py index c31457b0..37de2759 100644 --- a/src/api.py +++ b/src/api.py @@ -779,10 +779,13 @@ class BMRPCDispatcher(object): return queues.apiAddressGeneratorReturnQueue.get() @command('createChan') - def HandleCreateChan(self, passphrase): + def HandleCreateChan(self, passphrase, label=None): """ Creates a new chan. passphrase must be base64 encoded. Returns the corresponding Bitmessage address. + + :param str passphrase: base64 encoded passphrase + :param str label: label to set for the chan """ passphrase = self._decode(passphrase, "base64") @@ -791,8 +794,9 @@ class BMRPCDispatcher(object): # It would be nice to make the label the passphrase but it is # possible that the passphrase contains non-utf-8 characters. try: - passphrase.decode('utf-8') - label = str_chan + ' ' + passphrase + if label is None: + passphrase.decode('utf-8') + label = str_chan + ' ' + passphrase except UnicodeDecodeError: label = str_chan + ' ' + repr(passphrase)