code: def sign_bitcoin(self, message, compressed=False):
          
          if isinstance(message, str):
              msg_in = bytes(message, 'ascii')
          elif isinstance(message, bytes):
              msg_in = message
          else:
              raise TypeError("message must be either str or bytes!")
  
          msg = b"\x18Bitcoin Signed Message:\n" + bytes([len(msg_in)]) + msg_in
          msg_hash = hashlib.sha256(msg).digest()
  
          sig = self.sign(msg_hash)
          comp_adder = 4 if compressed else 0
          magic = 27 + sig.recovery_id + comp_adder
  
          return base64.b64encode(bytes([magic]) + bytes(sig))
docs: Signs a message using this private key such that it
          is compatible with bitcoind, bx, and other Bitcoin
          clients/nodes/utilities.
  
          Note:
              0x18 + b\"Bitcoin Signed Message:" + newline + len(message) is
              prepended to the message before signing.
  
          Args:
              message (bytes or str): Message to be signed.
              compressed (bool): True if the corresponding public key will be
                used in compressed format. False if the uncompressed version
                is used.
  
          Returns:
              bytes: A Base64-encoded byte string of the signed message.
              The first byte of the encoded message contains information
              about how to recover the public key. In bitcoind parlance,
              this is the magic number containing the recovery ID and
              whether or not the key was compressed or not.