Skip to content

Commit

Permalink
ADD: SignVerify screen
Browse files Browse the repository at this point in the history
  • Loading branch information
limpbrains committed Mar 23, 2021
1 parent 8a3bda0 commit a56a97e
Show file tree
Hide file tree
Showing 7 changed files with 296 additions and 4 deletions.
13 changes: 13 additions & 0 deletions Navigation.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import WalletExport from './screen/wallets/export';
import ExportMultisigCoordinationSetup from './screen/wallets/exportMultisigCoordinationSetup';
import ViewEditMultisigCosigners from './screen/wallets/viewEditMultisigCosigners';
import WalletXpub from './screen/wallets/xpub';
import SignVerify from './screen/wallets/signVerify';
import BuyBitcoin from './screen/wallets/buyBitcoin';
import HodlHodl from './screen/wallets/hodlHodl';
import HodlHodlViewOffer from './screen/wallets/hodlHodlViewOffer';
Expand Down Expand Up @@ -385,6 +386,17 @@ const WalletXpubStackRoot = () => {
);
};

const SignVerifyStack = createStackNavigator();
const SignVerifyStackRoot = () => {
const theme = useTheme();

return (
<SignVerifyStack.Navigator name="SignVerifyRoot" screenOptions={defaultStackScreenOptions} initialRouteName="SignVerify">
<SignVerifyStack.Screen name="SignVerify" component={SignVerify} options={SignVerify.navigationOptions(theme)} />
</SignVerifyStack.Navigator>
);
};

const WalletExportStack = createStackNavigator();
const WalletExportStackRoot = () => {
const theme = useTheme();
Expand Down Expand Up @@ -485,6 +497,7 @@ const Navigation = () => {
/>
<RootStack.Screen name="ViewEditMultisigCosignersRoot" component={ViewEditMultisigCosignersRoot} options={{ headerShown: false }} />
<RootStack.Screen name="WalletXpubRoot" component={WalletXpubStackRoot} options={{ headerShown: false }} />
<RootStack.Screen name="SignVerifyRoot" component={SignVerifyStackRoot} options={{ headerShown: false }} />
<RootStack.Screen name="BuyBitcoin" component={BuyBitcoin} options={BuyBitcoin.navigationOptions(theme)} />
<RootStack.Screen name="Marketplace" component={Marketplace} options={Marketplace.navigationOptions(theme)} />
<RootStack.Screen name="SelectWallet" component={SelectWallet} options={{ headerLeft: null }} />
Expand Down
4 changes: 4 additions & 0 deletions class/wallets/lightning-custodian-wallet.js
Original file line number Diff line number Diff line change
Expand Up @@ -605,6 +605,10 @@ export class LightningCustodianWallet extends LegacyWallet {
return true;
}

allowSignVerifyMessage() {
return false;
}

/**
* Example return:
* { destination: '03864ef025fde8fb587d989186ce6a4a186895ee44a926bfc370e2c366597a3f8f',
Expand Down
4 changes: 4 additions & 0 deletions class/wallets/watch-only-wallet.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ export class WatchOnlyWallet extends LegacyWallet {
);
}

allowSignVerifyMessage() {
return false;
}

getAddress() {
if (this.isAddressValid(this.secret)) return this.secret; // handling case when there is an XPUB there
if (this._hdWalletInstance) throw new Error('Should not be used in watch-only HD wallets');
Expand Down
21 changes: 17 additions & 4 deletions components/FloatButtons.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,20 @@ const ICON_MARGIN = 7;

const cStyles = StyleSheet.create({
root: {
position: 'absolute',
alignSelf: 'center',
height: '6.3%',
minHeight: 44,
},
rootAbsolute: {
position: 'absolute',
bottom: 30,
},
rootInline: {},
rootPre: {
position: 'absolute',
bottom: -1000,
},
rootPost: {
bottom: 30,
borderRadius: BORDER_RADIUS,
flexDirection: 'row',
overflow: 'hidden',
Expand All @@ -42,7 +46,11 @@ export const FContainer = forwardRef((props, ref) => {
};

return (
<View ref={ref} onLayout={onLayout} style={[cStyles.root, newWidth ? cStyles.rootPost : cStyles.rootPre]}>
<View
ref={ref}
onLayout={onLayout}
style={[cStyles.root, props.inline ? cStyles.rootInline : cStyles.rootAbsolute, newWidth ? cStyles.rootPost : cStyles.rootPre]}
>
{newWidth
? React.Children.toArray(props.children)
.filter(Boolean)
Expand All @@ -61,6 +69,7 @@ export const FContainer = forwardRef((props, ref) => {

FContainer.propTypes = {
children: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.element), PropTypes.element]),
inline: PropTypes.bool,
};

const buttonFontSize =
Expand Down Expand Up @@ -95,6 +104,9 @@ export const FButton = ({ text, icon, width, first, last, ...props }) => {
text: {
color: colors.buttonAlternativeTextColor,
},
textDisabled: {
color: colors.formBorder,
},
});
const style = {};

Expand All @@ -109,7 +121,7 @@ export const FButton = ({ text, icon, width, first, last, ...props }) => {
return (
<TouchableOpacity style={[bStyles.root, bStylesHook.root, style]} {...props}>
<View style={bStyles.icon}>{icon}</View>
<Text numberOfLines={1} style={[bStyles.text, bStylesHook.text]}>
<Text numberOfLines={1} style={[bStyles.text, props.disabled ? bStylesHook.textDisabled : bStylesHook.text]}>
{text}
</Text>
</TouchableOpacity>
Expand All @@ -122,4 +134,5 @@ FButton.propTypes = {
width: PropTypes.number,
first: PropTypes.bool,
last: PropTypes.bool,
disabled: PropTypes.bool,
};
12 changes: 12 additions & 0 deletions loc/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"no": "No",
"save": "Save",
"seed": "Seed",
"success": "Success",
"wallet_key": "Wallet key",
"invalid_animated_qr_code_fragment" : "Invalid animated QRCode fragment. Please try again.",
"file_saved": "File ({filePath}) has been saved in your Downloads folder.",
Expand Down Expand Up @@ -561,5 +562,16 @@
"MAX": "Max",
"sat_byte": "sat/byte",
"sats": "sats"
},
"addresses": {
"sign_title": "Sign/Verify message",
"sign_help": "Here you can create or verify a cryptographic signature based on a Bitcoin address",
"sign_sign": "Sign",
"sign_verify": "Verify",
"sign_signature_correct": "Verification Succeeded!",
"sign_signature_incorrect": "Verification Failed!",
"sign_placeholder_address": "Address",
"sign_placeholder_message": "Message",
"sign_placeholder_signature": "Signature"
}
}
14 changes: 14 additions & 0 deletions screen/wallets/details.js
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,14 @@ const WalletDetails = () => {
secret: wallet.getSecret(),
},
});
const navigateToSignVerify = () =>
navigate('SignVerifyRoot', {
screen: 'SignVerify',
params: {
walletID: wallet.getID(),
address: wallet.getAllExternalAddresses()[0], // works for both single address and HD wallets
},
});

const renderMarketplaceButton = () => {
return Platform.select({
Expand Down Expand Up @@ -552,6 +560,12 @@ const WalletDetails = () => {
<BlueSpacing20 />
<SecondButton onPress={navigateToIsItMyAddress} testID="IsItMyAddress" title={loc.is_it_my_address.title} />
</>
{wallet.allowSignVerifyMessage() && (
<>
<BlueSpacing20 />
<SecondButton onPress={navigateToSignVerify} testID="SignVerify" title={loc.addresses.sign_title} />
</>
)}
<BlueSpacing20 />
<BlueSpacing20 />
<TouchableOpacity onPress={handleDeleteButtonTapped} testID="DeleteButton">
Expand Down
Loading

0 comments on commit a56a97e

Please sign in to comment.