def invitation_success(self, sigkeypayload, cid, _debug_when_done):
        if not sigkeypayload.startswith("i0:"):
            raise ValueError("expected i0:, got '%r'" % sigkeypayload[:20])
        their_verfkey = VerifyKey(sigkeypayload[3:3+32])
        encoded_payload = their_verfkey.verify(sigkeypayload[3+32:])
        payload = json.loads(encoded_payload.decode("utf-8"))

        self.db.update(
            "UPDATE addressbook SET"
            " invitation_state=?, wormhole=?, wormhole_payload=?,"
            " when_accepted=?,"
            " acked=1,"  # TODO: faked. add a roundtrip?
            " latest_offered_mailbox_json=?,"
            " their_channel_record_json=?,"
            " they_used_new_channel_key=?, their_verfkey=?"
            " WHERE id=?",
            (invitation.INVITE_COMPLETE, None, None,
             time.time(),
             json.dumps(payload.get("mailbox")),
             json.dumps(payload["channel"]),
             0, their_verfkey.encode().encode("hex"),
             cid), "addressbook", cid)
        self.maybe_accept_mailbox(cid)
        self.db.commit()
        log.msg("addressbook entry added for petname=%r" %
                self.petname_for_cid(cid))
        if _debug_when_done:
            eventually(_debug_when_done.callback, cid)
dataset/ETHPy150Open warner/petmail/petmail/agent.py/Agent.invitation_success/original