DEL: AOPP

This commit is contained in:
Marcos Rodriguez Vélez 2022-01-27 15:59:46 -05:00
parent fe89b10e50
commit 0a76bf78c3
No known key found for this signature in database
GPG Key ID: 0D64671698D11C5C
33 changed files with 8 additions and 463 deletions

View File

@ -52,7 +52,6 @@ import Marketplace from './screen/wallets/marketplace';
import ReorderWallets from './screen/wallets/reorderWallets';
import SelectWallet from './screen/wallets/selectWallet';
import ProvideEntropy from './screen/wallets/provideEntropy';
import AOPP from './screen/wallets/aopp';
import TransactionDetails from './screen/transactions/details';
import TransactionStatus from './screen/transactions/transactionStatus';
@ -484,19 +483,6 @@ const ExportMultisigCoordinationSetupRoot = () => {
);
};
const AOPPStack = createNativeStackNavigator();
const AOPPRoot = () => {
const theme = useTheme();
return (
<AOPPStack.Navigator screenOptions={{ headerHideShadow: true }}>
<AOPPStack.Screen name="SelectWallet" component={SelectWallet} options={SelectWallet.navigationOptions(theme)} />
<AOPPStack.Screen name="AOPP" component={AOPP} options={AOPP.navigationOptions(theme)} />
<AOPPStack.Screen name="SignVerify" component={SignVerify} options={SignVerify.navigationOptions(theme)} />
</AOPPStack.Navigator>
);
};
const RootStack = createNativeStackNavigator();
const NavigationDefaultOptions = { headerShown: false, stackPresentation: isDesktop ? 'containedModal' : 'modal' };
const Navigation = () => {
@ -530,7 +516,6 @@ const Navigation = () => {
<RootStack.Screen name="SelectWallet" component={SelectWallet} />
<RootStack.Screen name="ReceiveDetailsRoot" component={ReceiveDetailsStackRoot} options={NavigationDefaultOptions} />
<RootStack.Screen name="LappBrowserRoot" component={LappBrowserStackRoot} options={NavigationDefaultOptions} />
<RootStack.Screen name="AOPPRoot" component={AOPPRoot} options={NavigationDefaultOptions} />
<RootStack.Screen name="LDKOpenChannelRoot" component={LDKOpenChannelRoot} options={NavigationDefaultOptions} />
<RootStack.Screen

View File

@ -70,11 +70,6 @@
<data android:scheme="bluewallet" />
<data android:scheme="lapp" />
<data android:scheme="blue" />
<data android:scheme="aopp" />
<data android:scheme="bankid" />
<data android:scheme="swish" />
<data android:scheme="http" />
<data android:scheme="https" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />

View File

@ -1,72 +0,0 @@
import Frisbee from 'frisbee';
import url from 'url';
export default class AOPP {
static typeAny = 'any';
static typeP2wpkh = 'p2wpkh';
static typeP2sh = 'p2sh';
static typeP2pkh = 'p2pkh';
static getSegwitByAddressFormat(addressType) {
if (![AOPP.typeP2wpkh, AOPP.typeP2sh, AOPP.typeP2pkh].includes(addressType)) {
throw new Error('Work only for limited types');
}
switch (addressType) {
case 'p2wpkh':
return 'p2wpkh';
case 'p2sh':
return 'p2sh(p2wpkh)';
case 'p2pkh':
return undefined;
}
}
constructor(uri) {
this.uri = uri;
const { protocol, query } = url.parse(uri, true); // eslint-disable-line node/no-deprecated-api
if (protocol !== 'aopp:') throw new Error('Unsupported protocol');
if (query.v !== '0') throw new Error('Unsupported version');
if (!query.msg) throw new Error('Message required');
if (query.msg.lenth > 1024) throw new Error('Message is too big');
if (query.asset && query.asset !== 'btc') throw new Error('Unsupported asset');
if (query.format) {
if (![AOPP.typeAny, AOPP.typeP2wpkh, AOPP.typeP2sh, AOPP.typeP2pkh].includes(query.format)) {
throw new Error('Unsupported address format');
}
} else {
query.format = 'any';
}
if (!query.callback) throw new Error('Callback required');
this.v = Number(query.v);
this.msg = query.msg;
this.format = query.format;
this.callback = query.callback;
// parse callback url
const { hostname } = url.parse(this.callback, true); // eslint-disable-line node/no-deprecated-api
if (!hostname) throw new Error('Wrong callback');
this.callbackHostname = hostname;
this._api = new Frisbee({
headers: {
Accept: 'application/json',
'Content-Type': 'application/json',
},
});
}
async send({ address, signature }) {
const res = await this._api.post(this.callback, {
body: {
version: this.v,
address,
signature,
},
});
if (res.err) throw res.err;
}
}

View File

@ -17,8 +17,7 @@ class DeeplinkSchemaMatch {
lowercaseString.startsWith('lightning:') ||
lowercaseString.startsWith('blue:') ||
lowercaseString.startsWith('bluewallet:') ||
lowercaseString.startsWith('lapp:') ||
lowercaseString.startsWith('aopp:')
lowercaseString.startsWith('lapp:')
);
}
@ -206,15 +205,7 @@ class DeeplinkSchemaMatch {
} else {
const urlObject = url.parse(event.url, true); // eslint-disable-line node/no-deprecated-api
(async () => {
if (urlObject.protocol === 'aopp:') {
completionHandler([
'AOPPRoot',
{
screen: 'AOPP',
params: { uri: event.url },
},
]);
} else if (urlObject.protocol === 'bluewallet:' || urlObject.protocol === 'lapp:' || urlObject.protocol === 'blue:') {
if (urlObject.protocol === 'bluewallet:' || urlObject.protocol === 'lapp:' || urlObject.protocol === 'blue:') {
switch (urlObject.host) {
case 'openlappbrowser': {
console.log('opening LAPP', urlObject.query.url);

View File

@ -31,19 +31,11 @@ type RNGHFlatListProps<T> = Animated.AnimateProps<
}
>;
const AnimatedFlatList = (Animated.createAnimatedComponent(FlatList) as unknown) as <T>(props: RNGHFlatListProps<T>) => React.ReactElement;
const AnimatedFlatList = Animated.createAnimatedComponent(FlatList) as unknown as <T>(props: RNGHFlatListProps<T>) => React.ReactElement;
function DraggableFlatListInner<T>(props: DraggableFlatListProps<T>) {
const {
cellDataRef,
containerRef,
flatListRef,
isTouchActiveRef,
keyToIndexRef,
panGestureHandlerRef,
propsRef,
scrollOffsetRef,
} = useRefs<T>();
const { cellDataRef, containerRef, flatListRef, isTouchActiveRef, keyToIndexRef, panGestureHandlerRef, propsRef, scrollOffsetRef } =
useRefs<T>();
const {
activationDistance,
activeCellOffset,

View File

@ -116,7 +116,6 @@
<string>bluewallet</string>
<string>lapp</string>
<string>blue</string>
<string>aopp</string>
</array>
</dict>
</array>

View File

@ -651,17 +651,10 @@
"sign_placeholder_address": "العنوان",
"sign_placeholder_message": "الرسالة",
"sign_placeholder_signature": "التوقيع",
"sign_aopp_title": "AOPP",
"sign_aopp_confirm": "هل تريد إرسال رسالة موقعة إلى {hostname}؟",
"addresses_title": "العنوان",
"type_change": "تغيير",
"type_receive": "استلام",
"type_used": "مستخدم",
"transactions": "الحوالات"
},
"aopp": {
"title": "اختر عنوانًا",
"send_success": "تم إرسال التوقيع بنجاح",
"send_error": "خطأ في إرسال التوقيع"
}
}

View File

@ -651,17 +651,10 @@
"sign_placeholder_address": "Adresa",
"sign_placeholder_message": "Zpráva",
"sign_placeholder_signature": "Podpis",
"sign_aopp_title": "AOPP",
"sign_aopp_confirm": "Chcete odeslat podepsanou zprávu na adresu {hostname}?",
"addresses_title": "Adresy",
"type_change": "Změnit",
"type_receive": "Příjmout",
"type_used": "Použité",
"transactions": "Transakce"
},
"aopp": {
"title": "Vybrat adresu",
"send_success": "Podpis byl úspěšně odeslán",
"send_error": "Chyba při odesílání podpisu"
}
}

View File

@ -284,8 +284,5 @@
"addresses_title": "Cyfeiriadau",
"type_change": "Newid",
"type_receive": "Derbyn"
},
"aopp": {
"title": "Dewis Cyfeiriad"
}
}

View File

@ -651,17 +651,10 @@
"sign_placeholder_address": "Adresse",
"sign_placeholder_message": "Meldung",
"sign_placeholder_signature": "Signatur",
"sign_aopp_title": "AOPP",
"sign_aopp_confirm": "Senden der signierten Nachricht nach {hostname}?",
"addresses_title": "Adressen",
"type_change": "Wechsel",
"type_receive": "Empfang",
"type_used": "Verwendet",
"transactions": "Transaktionen"
},
"aopp": {
"title": "Adresse wählen",
"send_success": "Signatur erfolgreich gesendet",
"send_error": "Fehler beim Senden der Signatur"
}
}

View File

@ -653,17 +653,10 @@
"sign_placeholder_address": "Address",
"sign_placeholder_message": "Message",
"sign_placeholder_signature": "Signature",
"sign_aopp_title": "AOPP",
"sign_aopp_confirm": "Do you want to send a signed message to {hostname}?",
"addresses_title": "Addresses",
"type_change": "Change",
"type_receive": "Receive",
"type_used": "Used",
"transactions": "Transactions"
},
"aopp": {
"title": "Select Address",
"send_success": "Signature sent successfully",
"send_error": "Signature sending error"
}
}

View File

@ -648,17 +648,10 @@
"sign_placeholder_address": "Dirección",
"sign_placeholder_message": "Mensaje",
"sign_placeholder_signature": "Firma",
"sign_aopp_title": "AOPP",
"sign_aopp_confirm": "¿Quieres enviar un mensaje firmado a {hostname}?",
"addresses_title": "Direcciones",
"type_change": "Cambio",
"type_receive": "Recibir",
"type_used": "Usado",
"transactions": "Transacciones"
},
"aopp": {
"title": "Selecciona la dirección",
"send_success": "Firma enviada correctamente",
"send_error": "Error al enviar la firma"
}
}

View File

@ -652,17 +652,10 @@
"sign_placeholder_address": "Dirección",
"sign_placeholder_message": "Mensaje",
"sign_placeholder_signature": "Firma",
"sign_aopp_title": "AOPP",
"sign_aopp_confirm": "¿Quieres enviar un mensaje firmado a {hostname}?",
"addresses_title": "Direcciones",
"type_change": "Cambio",
"type_receive": "Recibir",
"type_used": "Usado",
"transactions": "Transacciones"
},
"aopp": {
"title": "Seleccionar dirección",
"send_success": "Firma enviada con éxito",
"send_error": "Error de envío de firma"
}
}

View File

@ -652,17 +652,10 @@
"sign_placeholder_address": "آدرس",
"sign_placeholder_message": "پیام",
"sign_placeholder_signature": "امضا",
"sign_aopp_title": "پروتکل اثبات مالکیت آدرس (AOPP)",
"sign_aopp_confirm": "آیا مایل به ارسال پیام امضاشده به {hostname} هستید؟",
"addresses_title": "آدرس‌ها",
"type_change": "باقی‌مانده",
"type_receive": "دریافت",
"type_used": "استفاده‌شده",
"transactions": "تراکنش‌ها"
},
"aopp": {
"title": "انتخاب آدرس",
"send_success": "امضا با موفقیت ارسال شد.",
"send_error": "خطا در ارسال امضا"
}
}

View File

@ -641,17 +641,10 @@
"sign_placeholder_address": "Adresse",
"sign_placeholder_message": "Message",
"sign_placeholder_signature": "Signature",
"sign_aopp_title": "AOPP",
"sign_aopp_confirm": "Voulez vous envoyer un message signé a {hostname}?",
"addresses_title": "Adresses",
"type_change": "Monnaie",
"type_receive": "Réception",
"type_used": "Utilisé",
"transactions": "Transactions"
},
"aopp": {
"title": "Sélectionner l'adresse",
"send_success": "Signature envoyée avec succès",
"send_error": "Erreur lors de l'envoi de la signature"
}
}

View File

@ -637,16 +637,10 @@
"sign_placeholder_address": "כתובת",
"sign_placeholder_message": "הודעה",
"sign_placeholder_signature": "חתימה",
"sign_aopp_confirm": "האם ברצונך לשלוח הודעה חתומה אל {hostname}?",
"addresses_title": "כתובות",
"type_change": "עודף",
"type_receive": "קבלה",
"type_used": "שומש",
"transactions": "פעולות"
},
"aopp": {
"title": "בחירת כתובת",
"send_success": "חתימה נשלחה בהצלחה",
"send_error": "שגיאת שליחת חתימה"
}
}

View File

@ -628,16 +628,10 @@
"sign_placeholder_address": "Cím",
"sign_placeholder_message": "Üzenet",
"sign_placeholder_signature": "Szignatúra",
"sign_aopp_title": "AOPP",
"addresses_title": "Címek",
"type_change": "Váltópénz",
"type_receive": "Fogadás",
"type_used": "Használt",
"transactions": "Tranzakciók"
},
"aopp": {
"title": "Cím kiválasztása",
"send_success": "Szignatúra sikeresen elküldve",
"send_error": "Hiba a szignatúra küldésekor"
}
}

View File

@ -491,10 +491,5 @@
"addresses_title": "アドレス",
"type_change": "チェンジ",
"type_receive": "受取り"
},
"aopp": {
"title": "アドレス選択",
"send_success": "署名は正常に送信されました",
"send_error": "署名送信エラー"
}
}

View File

@ -648,17 +648,10 @@
"sign_placeholder_address": "주소",
"sign_placeholder_message": "메시지",
"sign_placeholder_signature": "서명",
"sign_aopp_title": "AOPP",
"sign_aopp_confirm": "서명된 메시지를 {hostname}으로 보내겠습니까?",
"addresses_title": "주소",
"type_change": "변경",
"type_receive": "받기",
"type_used": "사용됨",
"transactions": "트랜잭션"
},
"aopp": {
"title": "주소 선택",
"send_success": "서명 전송이 성공적으로 이루어졌습니다. ",
"send_error": "서명 보내기 에러"
}
}

View File

@ -618,17 +618,10 @@
"sign_placeholder_address": "Alamat",
"sign_placeholder_message": "Pesanan",
"sign_placeholder_signature": "Tandatangan",
"sign_aopp_title": "AOPP",
"sign_aopp_confirm": "Adakah anda mahu menghantar pesanan bertanda tangan kepada {hostname}?",
"addresses_title": "Alamat",
"type_change": "Ubah",
"type_receive": "Terima",
"type_used": "Digunakan",
"transactions": "Urus Niaga"
},
"aopp": {
"title": "Pilih Alamat",
"send_success": "Tandatangan berjaya dihantar",
"send_error": "Ralat Penghantaran Tandatangan"
}
}

View File

@ -651,17 +651,10 @@
"sign_placeholder_address": "Adres",
"sign_placeholder_message": "Bericht",
"sign_placeholder_signature": "Ondertekening",
"sign_aopp_title": "AOPP",
"sign_aopp_confirm": "Wil je een ondertekende boodschap sturen naar {hostname}",
"addresses_title": "Adressen",
"type_change": "Wisselgeld",
"type_receive": "Ontvang",
"type_used": "Gebruikt",
"transactions": "Transacties"
},
"aopp": {
"title": "Selecteer adres",
"send_success": "Ondertekening succesvol verstuurd",
"send_error": "Fout bij versturen van Ondertekening"
}
}

View File

@ -651,17 +651,10 @@
"sign_placeholder_address": "Adres",
"sign_placeholder_message": "Wiadomość",
"sign_placeholder_signature": "Podpis",
"sign_aopp_title": "AOPP",
"sign_aopp_confirm": "Czy chcesz przesłać podpisaną wiadomość do {hostname}?",
"addresses_title": "Adresy",
"type_change": "Reszta",
"type_receive": "Otrzymaj",
"type_used": "Używany",
"transactions": "Transakcje"
},
"aopp": {
"title": "Wybierz adres",
"send_success": "Podpis wysłany z powodzeniem",
"send_error": "Błąd wysyłania podpisu"
}
}

View File

@ -651,17 +651,10 @@
"sign_placeholder_address": "Endereço",
"sign_placeholder_message": "Mensagem",
"sign_placeholder_signature": "Assinatura",
"sign_aopp_title": "AOPP",
"sign_aopp_confirm": "Deseja enviar uma mensagem assinada para {hostname}?",
"addresses_title": "Endereços",
"type_change": "Troco",
"type_receive": "Receber",
"type_used": "Usado",
"transactions": "Transações"
},
"aopp": {
"title": "Selecionar endereço",
"send_success": "Assinatura enviada com sucesso",
"send_error": "Erro no envio da assinatura"
}
}

View File

@ -651,17 +651,10 @@
"sign_placeholder_address": "Адрес",
"sign_placeholder_message": "Сообщение",
"sign_placeholder_signature": "Подпись",
"sign_aopp_title": "AOPP",
"sign_aopp_confirm": "Отправить подписанное сообщение на {hostname}?",
"addresses_title": "Адреса",
"type_change": "Сдача",
"type_receive": "Получение",
"type_used": "Использован",
"transactions": "Транзакции"
},
"aopp": {
"title": "Выберите адрес",
"send_success": "Подпись успешно отправлена",
"send_error": "Ошибка отправки подписи"
}
}

View File

@ -648,17 +648,10 @@
"sign_placeholder_address": "ලිපිනය",
"sign_placeholder_message": "පණිවිඩය",
"sign_placeholder_signature": "අත්සන",
"sign_aopp_title": "AOPP",
"sign_aopp_confirm": "ඔබට {hostname} වෙත අත්සන් කළ පණිවිඩයක් යැවීමට අවශ්‍යද?",
"addresses_title": "ලිපිනයන්",
"type_change": "වෙනස් කරන්න",
"type_receive": "පිළිගන්න",
"type_used": "භාවිතා කර ඇත",
"transactions": "ගනුදෙනු"
},
"aopp": {
"title": "ලිපිනය තෝරන්න",
"send_success": "අත්සන සාර්ථකව යවන ලදි",
"send_error": "අත්සන යැවීමේ දෝෂයකි"
}
}

View File

@ -642,17 +642,10 @@
"sign_placeholder_address": "Naslov",
"sign_placeholder_message": "Sporočilo",
"sign_placeholder_signature": "Podpis",
"sign_aopp_title": "AOPP",
"sign_aopp_confirm": "Ali želite podpisano sporočilo poslati na {hostname}?",
"addresses_title": "Naslovi",
"type_change": "Vračilo",
"type_receive": "Prejemni",
"type_used": "Uporabljen",
"transactions": "Transakcije"
},
"aopp": {
"title": "Izberite Naslov",
"send_success": "Podpis uspešno poslan",
"send_error": "Napaka pri pošiljanju podpisa"
}
}

View File

@ -405,16 +405,10 @@
"sign_placeholder_address": "Адреса",
"sign_placeholder_message": "Повідомлення",
"sign_placeholder_signature": "Підпис",
"sign_aopp_confirm": "Ви хочете надіслати підписане повідомлення на адресу {hostname}?",
"addresses_title": "Адреси",
"type_change": "Здача",
"type_receive": "Отримати",
"type_used": "Використаний",
"transactions": "Транзакцій"
},
"aopp": {
"title": "Виберіть Адреси",
"send_success": "Підпис успішно надіслано",
"send_error": "Помилка надсилання підпису"
}
}

View File

@ -554,8 +554,5 @@
"addresses_title": "地址",
"type_change": "改变",
"type_receive": "接收"
},
"aopp": {
"title": "选择地址"
}
}

View File

@ -554,8 +554,5 @@
"addresses_title": "地址",
"type_change": "改變",
"type_receive": "接收"
},
"aopp": {
"title": "選擇地址"
}
}

View File

@ -1,66 +0,0 @@
import React, { useEffect, useContext } from 'react';
import { ActivityIndicator, Alert, StyleSheet } from 'react-native';
import { useRoute, useTheme, useNavigation } from '@react-navigation/native';
import ReactNativeHapticFeedback from 'react-native-haptic-feedback';
import { BlueStorageContext } from '../../blue_modules/storage-context';
import { SafeBlueArea } from '../../BlueComponents';
import navigationStyle from '../../components/navigationStyle';
import loc from '../../loc';
import AOPPClient from '../../class/aopp';
import selectWallet from '../../helpers/select-wallet';
const AOPP = () => {
const { colors } = useTheme();
const navigation = useNavigation();
const { uri } = useRoute().params;
const { name } = useRoute();
const { wallets } = useContext(BlueStorageContext);
useEffect(() => {
(async () => {
let aopp;
try {
aopp = new AOPPClient(uri);
} catch (e) {
ReactNativeHapticFeedback.trigger('notificationError', { ignoreAndroidSystemSettings: false });
Alert.alert(loc.errors.error, e.message);
return navigation.pop();
}
let availableWallets = wallets.filter(w => w.allowSignVerifyMessage());
if (aopp.format !== AOPPClient.typeAny) {
const segwitType = AOPPClient.getSegwitByAddressFormat(aopp.format);
availableWallets = availableWallets.filter(w => w.segwitType === segwitType);
}
const wallet = await selectWallet(navigation.navigate, name, false, availableWallets, 'Onchain wallet is required to sign a message');
if (!wallet) return navigation.pop();
const address = await wallet.getAddressAsync();
navigation.navigate('SignVerify', {
walletID: wallet.getID(),
address,
message: aopp.msg,
aoppURI: uri,
});
})();
}, []); // eslint-disable-line react-hooks/exhaustive-deps
return (
<SafeBlueArea style={[styles.center, { backgroundColor: colors.elevated }]}>
<ActivityIndicator />
</SafeBlueArea>
);
};
const styles = StyleSheet.create({
center: {
justifyContent: 'center',
alignItems: 'center',
},
});
AOPP.navigationOptions = navigationStyle({}, opts => ({ ...opts, title: loc.aopp.title }));
export default AOPP;

View File

@ -12,24 +12,20 @@ import {
TouchableWithoutFeedback,
View,
} from 'react-native';
import { useRoute, useTheme, useNavigation } from '@react-navigation/native';
import { useRoute, useTheme } from '@react-navigation/native';
import ReactNativeHapticFeedback from 'react-native-haptic-feedback';
import { Icon } from 'react-native-elements';
import Share from 'react-native-share';
import AOPP from '../../class/aopp';
import { BlueDoneAndDismissKeyboardInputAccessory, BlueFormLabel, BlueSpacing10, BlueSpacing20, SafeBlueArea } from '../../BlueComponents';
import navigationStyle from '../../components/navigationStyle';
import { FContainer, FButton } from '../../components/FloatButtons';
import { BlueStorageContext } from '../../blue_modules/storage-context';
import loc from '../../loc';
import confirm from '../../helpers/confirm';
const SignVerify = () => {
const { colors } = useTheme();
const { wallets, sleep } = useContext(BlueStorageContext);
const { params } = useRoute();
const navigation = useNavigation();
const [isKeyboardVisible, setIsKeyboardVisible] = useState(false);
const [address, setAddress] = useState(params.address ?? '');
const [message, setMessage] = useState(params.message ?? '');
@ -72,9 +68,8 @@ const SignVerify = () => {
setLoading(true);
await sleep(10); // wait for loading indicator to appear
let newSignature;
const useSegwit = Boolean(params.aoppURI);
try {
newSignature = wallet.signMessage(message, address, useSegwit);
newSignature = wallet.signMessage(message, address);
setSignature(newSignature);
setIsShareVisible(true);
} catch (e) {
@ -82,33 +77,6 @@ const SignVerify = () => {
Alert.alert(loc.errors.error, e.message);
}
if (!params.aoppURI) return setLoading(false);
let aopp;
try {
aopp = new AOPP(params.aoppURI);
} catch (e) {
ReactNativeHapticFeedback.trigger('notificationError', { ignoreAndroidSystemSettings: false });
Alert.alert(loc.errors.error, e.message);
}
if (
!(await confirm(
loc.addresses.sign_aopp_title,
loc.formatString(loc.addresses.sign_aopp_confirm, { hostname: aopp.callbackHostname }),
))
)
return setLoading(false);
try {
await aopp.send({ address, signature: newSignature });
Alert.alert(loc._.success, loc.aopp.send_success);
navigation.dangerouslyGetParent().pop();
} catch (e) {
ReactNativeHapticFeedback.trigger('notificationError', { ignoreAndroidSystemSettings: false });
Alert.alert(loc.errors.error, loc.aopp.send_error);
}
setLoading(false);
};
@ -228,11 +196,7 @@ const SignVerify = () => {
{!isKeyboardVisible && (
<>
<FContainer inline>
<FButton
onPress={handleSign}
text={params.aoppURI ? loc.addresses.sign_sign_submit : loc.addresses.sign_sign}
disabled={loading}
/>
<FButton onPress={handleSign} text={loc.addresses.sign_sign} disabled={loading} />
<FButton onPress={handleVerify} text={loc.addresses.sign_verify} disabled={loading} />
</FContainer>
<BlueSpacing10 />

View File

@ -1,85 +0,0 @@
import http from 'http';
import assert from 'assert';
import { HDLegacyP2PKHWallet, HDSegwitP2SHWallet } from '../../class';
import AOPP from '../../class/aopp';
let server;
let POST = '';
beforeAll(async () => {
// start https server, wait for POST requests and decode them
server = http
.createServer((req, res) => {
if (req.method !== 'POST') return;
let body = '';
req.on('data', data => (body += data));
req.on('end', () => (POST = JSON.parse(body)));
res.writeHead(200);
res.end('ok');
})
.listen(19616);
});
afterAll(() => {
server.close();
});
describe('AOPP', () => {
it('can validate uri', async () => {
const a = new AOPP('aopp:?v=0&msg=vasp-chosen-msg&asset=btc&format=p2wpkh&callback=https://vasp.com/proofs/vasp-chosen-token');
assert.strictEqual(a.v, 0);
assert.strictEqual(a.msg, 'vasp-chosen-msg');
assert.strictEqual(a.format, 'p2wpkh');
assert.strictEqual(a.callback, 'https://vasp.com/proofs/vasp-chosen-token');
assert.strictEqual(a.callbackHostname, 'vasp.com');
// wrong version
assert.throws(() => new AOPP('aopp:?v=1&msg=vasp-chosen-msg&asset=btc&format=p2wpkh&callback=https://vasp.com/'));
// wrong asset
assert.throws(() => new AOPP('aopp:?v=0&msg=vasp-chosen-msg&asset=bch&format=p2wpkh&callback=https://vasp.com/'));
// wrong format
assert.throws(() => new AOPP('aopp:?v=0&msg=vasp-chosen-msg&asset=btc&format=erc20&callback=https://vasp.com/'));
});
it('can cast address format to our internal segwitType', () => {
assert.throws(() => AOPP.getSegwitByAddressFormat('any'));
assert.throws(() => AOPP.getSegwitByAddressFormat('blablabla'));
assert.strictEqual(AOPP.getSegwitByAddressFormat('p2wpkh'), 'p2wpkh');
assert.strictEqual(AOPP.getSegwitByAddressFormat('p2sh'), 'p2sh(p2wpkh)');
assert.strictEqual(AOPP.getSegwitByAddressFormat('p2pkh'), undefined);
});
it('can sign and send signature using segwit address', async () => {
const mnemonic = 'abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about';
const hd = new HDSegwitP2SHWallet();
hd.setSecret(mnemonic);
const address = hd._getExternalAddressByIndex(0);
const a = new AOPP('aopp:?v=0&msg=Vires+in+Numeris&asset=btc&format=any&callback=http%3A%2F%2Flocalhost:19616');
const signature = hd.signMessage(a.msg, address);
await a.send({ address, signature });
assert.strictEqual(POST.version, 0);
assert.strictEqual(POST.address, address);
assert.ok(POST.signature);
});
it('can sign and send signature using legacy address', async () => {
const mnemonic = 'abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about';
const hd = new HDLegacyP2PKHWallet();
hd.setSecret(mnemonic);
const address = hd._getExternalAddressByIndex(0);
const a = new AOPP('aopp:?v=0&msg=Vires+in+Numeris&asset=btc&format=any&callback=http%3A%2F%2Flocalhost:19616');
const signature = hd.signMessage(a.msg, address);
await a.send({ address, signature });
assert.strictEqual(POST.version, 0);
assert.strictEqual(POST.address, address);
assert.ok(POST.signature);
});
});

View File

@ -285,20 +285,6 @@ describe('unit - DeepLinkSchemaMatch', function () {
},
],
},
{
argument: {
url: 'aopp:?v=0&msg=vasp-chosen-msg&asset=btc&format=p2wpkh&callback=https://vasp.com/proofs/vasp-chosen-token',
},
expected: [
'AOPPRoot',
{
screen: 'AOPP',
params: {
uri: 'aopp:?v=0&msg=vasp-chosen-msg&asset=btc&format=p2wpkh&callback=https://vasp.com/proofs/vasp-chosen-token',
},
},
],
},
];
const asyncNavigationRouteFor = async function (event) {