Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add label argument to createChan API endpoint #2104

Open
wants to merge 1 commit into
base: v0.6
Choose a base branch
from
Open
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
10 changes: 7 additions & 3 deletions src/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -779,10 +779,13 @@ def HandleGetDeterministicAddress(
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")
Expand All @@ -791,8 +794,9 @@ def HandleCreateChan(self, passphrase):
# 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)

Expand Down