Problem with Rekeying

I am learning how to rekey accounts to create multi-sig wallets. I developed code, which is on GitHub to rekey address ADDA to ADDB. Running the rekey.py script from the terminal produced the following result.

(algoenv) Brians-MacBook-Pro:node brianhaney$ python3 rekey.py
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/algosdk/v2client/algod.py", line 82, in algod_request
    resp = urlopen(req)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/urllib/request.py", line 222, in urlopen
    return opener.open(url, data, timeout)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/urllib/request.py", line 531, in open
    response = meth(req, response)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/urllib/request.py", line 641, in http_response
    'http', request, response, code, msg, hdrs)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/urllib/request.py", line 569, in error
    return self._call_chain(*args)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/urllib/request.py", line 503, in _call_chain
    result = func(*args)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/urllib/request.py", line 649, in http_error_default
    raise HTTPError(req.full_url, code, msg, hdrs, fp)
urllib.error.HTTPError: HTTP Error 400: Bad Request

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "rekey.py", line 53, in <module>
    txinfo = sign_and_send(txn, passphrase, client)
  File "rekey.py", line 46, in sign_and_send
    client.send_transaction(stxn)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/algosdk/v2client/algod.py", line 215, in send_transaction
    encoding.msgpack_encode(txn), **kwargs
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/algosdk/v2client/algod.py", line 237, in send_raw_transaction
    return self.algod_request("POST", req, data=txn, **kwargs)["txId"]
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/algosdk/v2client/algod.py", line 89, in algod_request
    raise error.AlgodHTTPError(e, code)
algosdk.error.AlgodHTTPError: TransactionPool.Remember: transaction 5U25DK73JUS6R54MC5DZXYZ4JSLYHZOUQ2IGTP424EPWW7OYK3BA: should have been authorized by ADDB but was actually authorized by ADDA

It appears the rekey worked despite the return error because there was a transaction made (TXID). However, I am unclear as to why the error was produced, given the successful result.

I checked the address in the mobile wallet, which shows ADDA had been rekeyed. Additionally, in the mobile wallet, the following error presents when attempting to send Algo from ADDA.

Error connected ledger device cannont sign transactions for this account. In order to do so, please connect ADDB.

However, I am not sure how to connect to ADDB or what the error means. When I open the ADDB address in the mobile wallet I am not able to send transactions from ADDA. So, I have three questions I would sincerely appreciate any help answering.

  1. What caused the script to return an error?

  2. How do I send Algo from ADDA, given it has been re-keyed to ADDB?

  3. How do you rekey to a multi-sig wallet as opposed to a single-sig wallet?

Thanks!

Update

There is documentation on rekeying to a multi-sig wallet, as opposed to a single-sig wallet. I used these docs to formulate the general model for rekeying in Python that I used. The documentation states:

The following transaction will fail because, by default, goal attempts to add the authorization using the --from parameter. However, the protocol will reject this because it is expecting the authorization from $ADDR_B due to the confirmed rekeying transaction above.

However, it is unclear whether rekeying requires sending an authorized transaction as the documentation continues.

Sending from the authorized address of Account “A” requires:

  • Construct an unsigned transaction from $ADDR_A
  • Sign using authorized address $ADDR_B
  • Send authorized transaction

Update

I watched @paul 's video on rekeying. I’ve learned a couple things and please correct me if I’m mistaken.

  1. The Algorand Mobile Wallet does not support transactions from rekeyed addresses.
  2. Transactions from rekeyed addresses must be manual, done through code.

Hacking through this problem, I also sent a transaction from ADDA to ADDB and signing the transaction with the passphrase of ADDB. However, the transaction was rejected with an error.

(algoenv) Brians-MacBook-Pro:node brianhaney$ python3 rekey.py
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/algosdk/v2client/algod.py", line 82, in algod_request
    resp = urlopen(req)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/urllib/request.py", line 222, in urlopen
    return opener.open(url, data, timeout)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/urllib/request.py", line 531, in open
    response = meth(req, response)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/urllib/request.py", line 641, in http_response
    'http', request, response, code, msg, hdrs)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/urllib/request.py", line 569, in error
    return self._call_chain(*args)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/urllib/request.py", line 503, in _call_chain
    result = func(*args)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/urllib/request.py", line 649, in http_error_default
    raise HTTPError(req.full_url, code, msg, hdrs, fp)
urllib.error.HTTPError: HTTP Error 400: Bad Request

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "rekey.py", line 21, in <module>
    params = client.suggested_params()
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/algosdk/v2client/algod.py", line 314, in suggested_params
    res = self.algod_request("GET", req, **kwargs)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/algosdk/v2client/algod.py", line 89, in algod_request
    raise error.AlgodHTTPError(e, code)
algosdk.error.AlgodHTTPError: invalid input: unable to parse base32 digest data 'txid': illegal base32 data at input byte 0

Hello

I’ll get right to it sir