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

Signer device qr #613

Merged
merged 6 commits into from
Jul 12, 2023
Merged
Show file tree
Hide file tree
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
2 changes: 2 additions & 0 deletions sphinx/application/common/resources/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ dependencies {
implementation deps.androidx.annotation
implementation deps.androidx.appCompat
implementation deps.androidx.constraintLayout
implementation deps.bip39.sdk
implementation deps.jna.sdk

implementation deps.lottie.sdk
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="to">Para sa/kay</string>
<string name="from">Mula sa/kay</string>
Expand Down Expand Up @@ -198,6 +197,27 @@
<string name="delete_chat_media">Media</string>
<string name="delete_chat_files">Files</string>
<string name="manage_storage_deleted_all_files">All files</string>
<string name="network_check_title">Suriin ang iyong network</string>
<string name="network_check_message">Bago magsimula kailangan mong kumonekta sa \"sphinxkey\" WiFi network. Kung hindi, hindi mo mase-set up ang iyong aparato. Nakakonekta ka ba sa network na ito??</string>
<string name="network_name_title">WiFi network</string>
<string name="network_name_message">Mangyaring tukuyin ang iyong WiFi network</string>
<string name="network_password_title">WiFi password</string>
<string name="network_password_message">Enter the WiFi password for %s</string>
<string name="lightning_node_ip_title">IP ng lightning node</string>
<string name="lightning_node_url_title">Lightning Node URL</string>
<string name="lightning_node_ip_message">Ilagay ang IP ng iyong lightning node</string>
<string name="lightning_node_url_message">Enter the URL of your lightning node</string>
<string name="lightning_node_port_title">Lightning node Port</string>
<string name="lightning_node_port_message">Ilagay ang numbero ng Port ng iyong lightning node</string>
<string name="store_mnemonic">I-imbak ng ligtas ang iyong Mnemonic</string>
<string name="sending_seed">Sending seed to hardware</string>
<string name="error_setting_up_signing_device">There was an error setting up signing device: %s</string>
<string name="signing_device_successfully_set">Matagumpay na naipadala ang binhi sa hardware</string>
<string name="setup_signing_device">I-setup ang Signing Device</string>
<string name="configure_signing_device">I-configure ang Signing Device</string>
<string name="mnemonic_copied_to_clipboard">Ang mga Mnemonic na salita ay nakopya na sa clipboard</string>
<string name="bitcoin_network">Bitcoin Network</string>
<string name="select_bitcoin_network">Piliin ang Bitcoin Network</string>


</resources>
Original file line number Diff line number Diff line change
Expand Up @@ -125,11 +125,28 @@
<string name="delete_chat_files">Archivos</string>
<string name="manage_storage_deleted_all_files">Todos los archivos</string>


<string name="video_sats_per_minute">Sats por minuto</string>




<string name="alias_allowed_characters">Solo se permiten letras, números y\nguiones bajos en el alias de la tribu</string>

<string name="network_check_title">Verifica tu conexión WiFi</string>
<string name="network_check_message">Antes de comenzar tenes que conectarte a la red WiFi \"sphinxkey\". De lo contrario no vas a poder configurar tu dispositivo. ¿Estás actualmente conectado a esta red?</string>
<string name="network_name_title">Red WiFi</string>
<string name="network_name_message">Por favor especifica la red WiFi</string>
<string name="network_password_title">Contraseña de WiFi</string>
<string name="network_password_message">Ingresa la contraseña de WiFi para %s</string>
<string name="lightning_node_ip_title">IP del nodo de lightning</string>
<string name="lightning_node_url_title">URL del nodo de lightning</string>
<string name="lightning_node_ip_message">Ingresa la IP del nodo de lightning</string>
<string name="lightning_node_url_message">Ingresa la URL del nodo de lightning</string>
<string name="lightning_node_port_title">Puerto del nodo de lightning</string>
<string name="lightning_node_port_message">Ingresa el número de puerto del nodo de lightning</string>
<string name="store_mnemonic">Guarda tus palabras de seguridad cuidadosamente</string>
<string name="sending_seed">Enviando seed al dispositivo</string>
<string name="error_setting_up_signing_device">Ocurrió un error configurando el dispositivo de firma: %s</string>
<string name="signing_device_successfully_set">Seed envíado al dispositivo con éxito</string>
<string name="setup_signing_device">Configurar Dispositivo de Firma</string>
<string name="configure_signing_device">Configurar Dispositivo de Firma</string>
<string name="mnemonic_copied_to_clipboard">Palabras de seguridad copiadas al portapapeles</string>
<string name="bitcoin_network">Red de Bitcoin</string>
<string name="select_bitcoin_network">Seleccioná la red de Bitcoin</string>
</resources>
Original file line number Diff line number Diff line change
Expand Up @@ -125,4 +125,27 @@
<string name="manage_storage_deleted_all_files">All files</string>

<string name="alias_allowed_characters">Only letters, numbers and underscore\nare allowed in tribe aliases</string>

<string name="network_check_title">Check your network</string>
<string name="network_check_message">Before starting you need to connect to \"sphinxkey\" WiFi network. Otherwise you won’t be able to setup your device. Are you connected to this network?</string>
<string name="network_name_title">WiFi network</string>
<string name="network_name_message">Please specify your WiFi network</string>
<string name="network_password_title">WiFi password</string>
<string name="network_password_message">Enter the WiFi password for %s</string>
<string name="lightning_node_ip_title">Lightning node IP</string>
<string name="lightning_node_url_title">Lightning Node URL</string>
<string name="lightning_node_ip_message">Enter the IP of your lightning node</string>
<string name="lightning_node_url_message">Enter the URL of your lightning node</string>
<string name="lightning_node_port_title">Lightning node Port</string>
<string name="lightning_node_port_message">Enter the Port number of your lightning node</string>
<string name="store_mnemonic">Store your Mnemonic securely</string>
<string name="sending_seed">Sending seed to hardware</string>
<string name="error_setting_up_signing_device">There was an error setting up signing device: %s</string>
<string name="signing_device_successfully_set">Seed sent to hardware successfully</string>
<string name="setup_signing_device">Setup Signing Device</string>
<string name="configure_signing_device">Configure Signing Device</string>
<string name="mnemonic_copied_to_clipboard">Mnemonic words copied to clipboard</string>
<string name="bitcoin_network">Bitcoin Network</string>
<string name="select_bitcoin_network">Select Bitcoin Network</string>

</resources>
Original file line number Diff line number Diff line change
Expand Up @@ -124,4 +124,27 @@

<string name="video_sats_per_minute">Sats per minute</string>
<string name="alias_allowed_characters">Only letters, numbers and underscore\nare allowed in tribe aliases</string>

<string name="network_check_title">Check your network</string>
<string name="network_check_message">Before starting you need to connect to \"sphinxkey\" WiFi network. Otherwise you won’t be able to setup your device. Are you connected to this network?</string>
<string name="network_name_title">WiFi network</string>
<string name="network_name_message">Please specify your WiFi network</string>
<string name="network_password_title">WiFi password</string>
<string name="network_password_message">Enter the WiFi password for %s</string>
<string name="lightning_node_ip_title">Lightning node IP</string>
<string name="lightning_node_url_title">Lightning Node URL</string>
<string name="lightning_node_ip_message">Enter the IP of your lightning node</string>
<string name="lightning_node_url_message">Enter the URL of your lightning node</string>
<string name="lightning_node_port_title">Lightning node Port</string>
<string name="lightning_node_port_message">Enter the Port number of your lightning node</string>
<string name="store_mnemonic">Store your Mnemonic securely</string>
<string name="sending_seed">Sending seed to hardware</string>
<string name="error_setting_up_signing_device">There was an error setting up signing device: %s</string>
<string name="signing_device_successfully_set">Seed sent to hardware successfully</string>
<string name="setup_signing_device">Setup Signing Device</string>
<string name="configure_signing_device">Configure Signing Device</string>
<string name="mnemonic_copied_to_clipboard">Mnemonic words copied to clipboard</string>
<string name="bitcoin_network">Bitcoin Network</string>
<string name="select_bitcoin_network">Select Bitcoin Network</string>

</resources>
Original file line number Diff line number Diff line change
Expand Up @@ -243,4 +243,28 @@
<string name="delete_chat_files">Files</string>

<string name="alias_allowed_characters">Only letters, numbers and underscore\nare allowed in tribe aliases</string>

<string name="network_check_title">Check your network</string>
<string name="network_check_message">Before starting you need to connect to \"sphinxkey\" WiFi network. Otherwise you won’t be able to setup your device. Are you connected to this network?</string>
<string name="network_name_title">WiFi network</string>
<string name="network_name_message">Please specify your WiFi network</string>
<string name="network_password_title">WiFi password</string>
<string name="network_password_message">Enter the WiFi password for %s</string>
<string name="lightning_node_ip_title">Lightning node IP</string>
<string name="lightning_node_url_title">Lightning Node URL</string>
<string name="lightning_node_ip_message">Enter the IP of your lightning node</string>
<string name="lightning_node_url_message">Enter the URL of your lightning node</string>
<string name="lightning_node_port_title">Lightning node Port</string>
<string name="lightning_node_port_message">Enter the Port number of your lightning node</string>
<string name="store_mnemonic">Store your Mnemonic securely</string>
<string name="sending_seed">Sending seed to hardware</string>
<string name="error_setting_up_signing_device">There was an error setting up signing device: %s</string>
<string name="signing_device_successfully_set">Seed sent to hardware successfully</string>
<string name="setup_signing_device">Setup Signing Device</string>
<string name="configure_signing_device">Configure Signing Device</string>
<string name="mnemonic_copied_to_clipboard">Mnemonic words copied to clipboard</string>
<string name="bitcoin_network">Bitcoin Network</string>
<string name="select_bitcoin_network">Select Bitcoin Network</string>


</resources>
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
package chat.sphinx.wrapper_common.lightning

@Suppress("NOTHING_TO_INLINE")
inline fun String.toLightningNodeLink(): LightningNodeLink? =
try {
LightningNodeLink(this)
} catch (e: IllegalArgumentException) {
null
}

inline val String.isValidLightningNodeLink: Boolean
get() = isNotEmpty() && matches("^${LightningNodeLink.REGEX}\$".toRegex())

@Suppress("NOTHING_TO_INLINE")
inline fun String.isBitcoinNetwork(): Boolean =
this == "bitcoin"


@JvmInline
value class LightningNodeLink(val value: String) {

companion object {
const val REGEX = "sphinx\\.chat:\\/\\/\\?action=glyph&mqtt=.*&network=.*"
const val LIGHTNING_MQTT = "mqtt"
const val LIGHTNING_NETWORK = "network"
}

init {
require(value.isValidLightningNodeLink) {
"Invalid Lightning Node Link"
}
}

inline val lightningMqtt : String
get() = (getComponent(LIGHTNING_MQTT) ?: "").trim()

inline val lightningNetwork : String
get() = (getComponent(LIGHTNING_NETWORK) ?: "").trim()

fun getComponent(k: String): String? {
val components = value.replace("sphinx.chat://", "").split("&")
for (component in components) {
val subComponents = component.split("=")
val key:String? = if (subComponents.isNotEmpty()) subComponents.elementAtOrNull(0) else null
val value:String? = if (subComponents.size > 1) subComponents.elementAtOrNull(1) else null

if (key == k) return value
}
return null
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ class SendSeedDto {
var seed: String? = null
var ssid: String? = null
var pass: String? = null
var lightningNodeIP: String? = null
var lightningNodePort: String? = null
var lightningNodeUrl: String? = null
var pubkey: String? = null
var network: String = "regtest"
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class NetworkQueryCrypterImpl(
seedDto: SendSeedDto,
): Flow<LoadResponse<Any, ResponseError>> =
networkRelayCall.post(
url = String.format(ENDPOINT_POST_ENCRYPTED_SEED, "{\"seed\":\"${seedDto.seed}\",\"ssid\":\"${seedDto.ssid}\",\"pass\":\"${seedDto.pass}\",\"broker\":\"${seedDto.lightningNodeIP}:${seedDto.lightningNodePort}\",\"pubkey\":\"${seedDto.pubkey}\",\"network\":\"${seedDto.network}\"}"),
url = String.format(ENDPOINT_POST_ENCRYPTED_SEED, "{\"seed\":\"${seedDto.seed}\",\"ssid\":\"${seedDto.ssid}\",\"pass\":\"${seedDto.pass}\",\"broker\":\"${seedDto.lightningNodeUrl}\",\"pubkey\":\"${seedDto.pubkey}\",\"network\":\"${seedDto.network}\"}"),
responseJsonClass = Any::class.java,
requestBodyJsonClass = Map::class.java,
requestBody = mapOf(Pair("", "")),
Expand Down
7 changes: 7 additions & 0 deletions sphinx/screens/dashboard/dashboard/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -50,28 +50,35 @@ dependencies {
implementation project(path: ':sphinx:application:common:resources')
implementation project(path: ':sphinx:application:common:swipe-reveal-layout')


implementation project(path: ':sphinx:application:data:concepts:repositories:concept-repository-actions')
implementation project(path: ':sphinx:application:data:concepts:repositories:concept-repository-chat')
implementation project(path: ':sphinx:application:data:concepts:concept-image-loader')
implementation project(path: ':sphinx:application:data:concepts:concept-background-login')
implementation project(path: ':sphinx:application:data:concepts:concept-wallet')
implementation project(path: ':sphinx:application:data:concepts:repositories:concept-repository-dashboard-android')
implementation project(path: ':sphinx:activity:concepts:concept-user-colors-helper')
implementation project(path: ':sphinx:application:network:concepts:queries:concept-network-query-lightning')
implementation project(path: ':sphinx:application:network:concepts:queries:concept-network-query-version')
implementation project(path: ':sphinx:application:network:concepts:queries:concept-network-query-authorize-external')
implementation project(path: ':sphinx:application:network:concepts:queries:concept-network-query-people')
implementation project(path: ':sphinx:application:network:concepts:queries:concept-network-query-redeem-badge-token')
implementation project(path: ':sphinx:application:network:concepts:queries:concept-network-query-crypter')
implementation project(path: ':sphinx:application:network:concepts:concept-socket-io')
implementation project(path: ':sphinx:screens-detail:scanner:scanner-view-model-coordinator')
implementation project(path: ':sphinx:screens-detail:tribes-discover:tribes-discover-view-model-coordinator')
implementation project(path: ':sphinx:service:concepts:concept-service-notification')
implementation project(path: ':sphinx:application:common:logger')


api project(path: ':sphinx:service:concepts:concept-service-media-player')

implementation deps.androidx.swipeRefreshLayout
implementation deps.androidx.recyclerView
implementation deps.androidx.lifecycle.hilt
implementation deps.google.hilt
implementation deps.bip39.sdk
implementation deps.jna.sdk
implementation deps.lottie.sdk
implementation deps.square.moshi
kapt kaptDeps.google.hilt
Expand Down
Loading