From 2b24b905ce6ee38b9310e1a18ee44aba2ac7133e Mon Sep 17 00:00:00 2001 From: Rob Clarkson Date: Wed, 28 Jun 2023 17:29:52 +1200 Subject: [PATCH 01/27] add card pin number controls --- class/wallets/lightning-custodian-wallet.js | 204 ++++++++------------ screen/boltcard/details.js | 123 ++++++++---- 2 files changed, 164 insertions(+), 163 deletions(-) diff --git a/class/wallets/lightning-custodian-wallet.js b/class/wallets/lightning-custodian-wallet.js index d9bb0b41f4..f2ad0a91fe 100644 --- a/class/wallets/lightning-custodian-wallet.js +++ b/class/wallets/lightning-custodian-wallet.js @@ -76,6 +76,21 @@ export class LightningCustodianWallet extends LegacyWallet { return login; } + buildCardName() { + let login, password; + if (this.secret.indexOf('blitzhub://') !== -1) { + login = this.secret.replace('blitzhub://', '').split(':')[0]; + password = this.secret.replace('blitzhub://', '').split(':')[1]; + } else if(this.secret.indexOf('lndhub://') !== -1) { + login = this.secret.replace('lndhub://', '').split(':')[0]; + password = this.secret.replace('lndhub://', '').split(':')[1]; + } else { + login = this.secret.replace('boltcardhub://', '').split(':')[0]; + password = this.secret.replace('boltcardhub://', '').split(':')[1]; + } + return login+':'+password; + } + timeToRefreshBalance() { return (+new Date() - this._lastBalanceFetch) / 1000 > 300; // 5 min } @@ -706,18 +721,6 @@ export class LightningCustodianWallet extends LegacyWallet { return this.createcardurl; } - let login, password; - if (this.secret.indexOf('blitzhub://') !== -1) { - login = this.secret.replace('blitzhub://', '').split(':')[0]; - password = this.secret.replace('blitzhub://', '').split(':')[1]; - } else if(this.secret.indexOf('lndhub://') !== -1) { - login = this.secret.replace('lndhub://', '').split(':')[0]; - password = this.secret.replace('lndhub://', '').split(':')[1]; - } else { - login = this.secret.replace('boltcardhub://', '').split(':')[0]; - password = this.secret.replace('boltcardhub://', '').split(':')[1]; - } - const response = await this._api.post('/createboltcard', { headers: { 'Access-Control-Allow-Origin': '*', @@ -725,7 +728,7 @@ export class LightningCustodianWallet extends LegacyWallet { Authorization: 'Bearer' + ' ' + this.access_token, }, body: { - card_name: login+':'+password + card_name: buildCardName() } }); @@ -751,19 +754,6 @@ export class LightningCustodianWallet extends LegacyWallet { return this.cardKeys; } - - let login, password; - if (this.secret.indexOf('blitzhub://') !== -1) { - login = this.secret.replace('blitzhub://', '').split(':')[0]; - password = this.secret.replace('blitzhub://', '').split(':')[1]; - } else if(this.secret.indexOf('lndhub://') !== -1) { - login = this.secret.replace('lndhub://', '').split(':')[0]; - password = this.secret.replace('lndhub://', '').split(':')[1]; - } else { - login = this.secret.replace('boltcardhub://', '').split(':')[0]; - password = this.secret.replace('boltcardhub://', '').split(':')[1]; - } - const response = await this._api.post('/getcardkeys', { headers: { 'Access-Control-Allow-Origin': '*', @@ -771,7 +761,7 @@ export class LightningCustodianWallet extends LegacyWallet { Authorization: 'Bearer' + ' ' + this.access_token, }, body: { - card_name: login+':'+password + card_name: this.buildCardName() } }); @@ -801,18 +791,6 @@ export class LightningCustodianWallet extends LegacyWallet { return this.wipeData; } - let login, password; - if (this.secret.indexOf('blitzhub://') !== -1) { - login = this.secret.replace('blitzhub://', '').split(':')[0]; - password = this.secret.replace('blitzhub://', '').split(':')[1]; - } else if(this.secret.indexOf('lndhub://') !== -1) { - login = this.secret.replace('lndhub://', '').split(':')[0]; - password = this.secret.replace('lndhub://', '').split(':')[1]; - } else { - login = this.secret.replace('boltcardhub://', '').split(':')[0]; - password = this.secret.replace('boltcardhub://', '').split(':')[1]; - } - const response = await this._api.post('/wipecard', { headers: { 'Access-Control-Allow-Origin': '*', @@ -820,7 +798,7 @@ export class LightningCustodianWallet extends LegacyWallet { Authorization: 'Bearer' + ' ' + this.access_token, }, body: { - card_name: login+':'+password + card_name: this.buildCardName() } }); @@ -865,18 +843,6 @@ export class LightningCustodianWallet extends LegacyWallet { if(!this.cardDetails) await this.getCardDetails(); - let login, password; - if (this.secret.indexOf('blitzhub://') !== -1) { - login = this.secret.replace('blitzhub://', '').split(':')[0]; - password = this.secret.replace('blitzhub://', '').split(':')[1]; - } else if(this.secret.indexOf('lndhub://') !== -1) { - login = this.secret.replace('lndhub://', '').split(':')[0]; - password = this.secret.replace('lndhub://', '').split(':')[1]; - } else { - login = this.secret.replace('boltcardhub://', '').split(':')[0]; - password = this.secret.replace('boltcardhub://', '').split(':')[1]; - } - console.log('enable bool', status); const response = await this._api.post('/updatecard', { headers: { @@ -886,7 +852,7 @@ export class LightningCustodianWallet extends LegacyWallet { }, body: { enable: status, - card_name: login+':'+password, + card_name: this.buildCardName(), tx_max: this.cardDetails.tx_limit_sats, day_max: this.cardDetails.day_limit_sats, } @@ -905,23 +871,11 @@ export class LightningCustodianWallet extends LegacyWallet { return this.cardEnabled = status; } - async updateCard(tx_max) { + async updateCard(tx_max, usePin, pinNumber) { await this.checkLogin(); if(!this.cardDetails) await this.getCardDetails(); - let login, password; - if (this.secret.indexOf('blitzhub://') !== -1) { - login = this.secret.replace('blitzhub://', '').split(':')[0]; - password = this.secret.replace('blitzhub://', '').split(':')[1]; - } else if(this.secret.indexOf('lndhub://') !== -1) { - login = this.secret.replace('lndhub://', '').split(':')[0]; - password = this.secret.replace('lndhub://', '').split(':')[1]; - } else { - login = this.secret.replace('boltcardhub://', '').split(':')[0]; - password = this.secret.replace('boltcardhub://', '').split(':')[1]; - } - let cardEnabled = 'false'; if(this.cardDetails.lnurlw_enable == 'Y') { cardEnabled = 'true'; @@ -935,8 +889,10 @@ export class LightningCustodianWallet extends LegacyWallet { }, body: { enable: cardEnabled, - card_name: login+':'+password, + card_name: this.buildCardName(), tx_max: tx_max, + card_pin_number: pinNumber, + use_pin: usePin, //dont update the day_limit_says day_max: this.cardDetails.day_limit_sats, } @@ -962,18 +918,6 @@ export class LightningCustodianWallet extends LegacyWallet { return this.cardDetails; } - let login, password; - if (this.secret.indexOf('blitzhub://') !== -1) { - login = this.secret.replace('blitzhub://', '').split(':')[0]; - password = this.secret.replace('blitzhub://', '').split(':')[1]; - } else if(this.secret.indexOf('lndhub://') !== -1) { - login = this.secret.replace('lndhub://', '').split(':')[0]; - password = this.secret.replace('lndhub://', '').split(':')[1]; - } else { - login = this.secret.replace('boltcardhub://', '').split(':')[0]; - password = this.secret.replace('boltcardhub://', '').split(':')[1]; - } - const response = await this._api.post('/getcard', { headers: { 'Access-Control-Allow-Origin': '*', @@ -981,7 +925,7 @@ export class LightningCustodianWallet extends LegacyWallet { Authorization: 'Bearer' + ' ' + this.access_token, }, body: { - card_name: login+':'+password + card_name: this.buildCardName() } }); @@ -1019,6 +963,60 @@ export class LightningCustodianWallet extends LegacyWallet { return (this.cardDetails = json); } + async togglePin(enable) { + const response = await this._api.post('/togglePin', { + headers: { + 'Access-Control-Allow-Origin': '*', + 'Content-Type': 'application/json', + Authorization: 'Bearer' + ' ' + this.access_token, + }, + body: { + card_name: this.buildCardName(), + enable_pin: enable + } + }); + + const json = response.body; + + if (typeof json === 'undefined') { + throw new Error('API failure: ' + response.err + ' ' + JSON.stringify(response.body)); + } + + if (json && json.error) { + throw new Error('API error: ' + json.message + ' (code ' + json.code + ')'); + } + + console.log('togglePin response', [json]); + return json; + } + + async savePinNumber(pinNumber) { + const response = await this._api.post('/updatePin', { + headers: { + 'Access-Control-Allow-Origin': '*', + 'Content-Type': 'application/json', + Authorization: 'Bearer' + ' ' + this.access_token, + }, + body: { + card_name: this.buildCardName(), + pin_number: pinNumber + } + }); + + const json = response.body; + + if (typeof json === 'undefined') { + throw new Error('API failure: ' + response.err + ' ' + JSON.stringify(response.body)); + } + + if (json && json.error) { + throw new Error('API error: ' + json.message + ' (code ' + json.code + ')'); + } + + console.log('togglePin response', [json]); + return json; + } + async regenerateCardUrl() { await this.checkLogin(); @@ -1035,52 +1033,10 @@ export class LightningCustodianWallet extends LegacyWallet { } async pushNotificationToken() { - // if(this.notificationTokenPushed) { - // //token has already been pushed for this wallet - // return false; - // } return Notifications.majorTomToGroundControl([], [], [], [this.getLogin()]); - // return (this.notificationTokenPushed = true); - // return true; + } -} - -/* - - - -pending tx: - - [ { amount: 0.00078061, - account: '521172', - address: '3F9seBGCJZQ4WJJHwGhrxeGXCGbrm5SNpF', - category: 'receive', - confirmations: 0, - blockhash: '', - blockindex: 0, - blocktime: 0, - txid: '28a74277e47c2d772ee8a40464209c90dce084f3b5de38a2f41b14c79e3bfc62', - walletconflicts: [], - time: 1535024434, - timereceived: 1535024434 } ] - - -tx: - - [ { amount: 0.00078061, - account: '521172', - address: '3F9seBGCJZQ4WJJHwGhrxeGXCGbrm5SNpF', - category: 'receive', - confirmations: 5, - blockhash: '0000000000000000000edf18e9ece18e449c6d8eed1f729946b3531c32ee9f57', - blockindex: 693, - blocktime: 1535024914, - txid: '28a74277e47c2d772ee8a40464209c90dce084f3b5de38a2f41b14c79e3bfc62', - walletconflicts: [], - time: 1535024434, - timereceived: 1535024434 } ] - - */ +} \ No newline at end of file diff --git a/screen/boltcard/details.js b/screen/boltcard/details.js index 659208a540..c254ba3f19 100644 --- a/screen/boltcard/details.js +++ b/screen/boltcard/details.js @@ -8,10 +8,12 @@ import { StyleSheet, Text, TouchableOpacity, - View + View, + TouchableWithoutFeedback } from 'react-native'; import { + BlueListItem, BlueButton, BlueFormTextInput, BlueText @@ -19,6 +21,7 @@ import { import { BlueStorageContext } from '../../blue_modules/storage-context'; import alert from '../../components/Alert'; import navigationStyle from '../../components/navigationStyle'; +import { ListItem } from 'react-native-elements'; @@ -72,22 +75,24 @@ const BoltCardDetails = () => { const [details, setDetails] = useState({}); const [editMode, setEditMode] = useState(false); const [cardKeys, setCardKeys] = useState(); + const [usePin, setUsePin] = useState(); + const [pinNumber, setPinNumber] = useState(); const [txMax, setTxMax] = useState(0); const fetchCardDetails = async (w, reload = false) => { - setLoading(true); - w.getCardDetails(reload) - .then(response => { - setDetails(response); - saveToDisk(); - setLoading(false); - }) - .catch(err => { - console.log('ERROR', err.message); - alert(err.message); - goBack(); - }); + setLoading(true); + w.getCardDetails(reload) + .then(response => { + setDetails(response); + saveToDisk(); + setLoading(false); + }) + .catch(err => { + console.log('ERROR', err.message); + alert(err.message); + goBack(); + }); // w.getcardkeys().then(response => { // setCardKeys(response); @@ -107,10 +112,11 @@ const BoltCardDetails = () => { if(details && details.tx_limit_sats) { setTxMax(details.tx_limit_sats); } + }, [details]); const updateCard = () => { - wallet.updateCard(txMax).then(response => { + wallet.updateCard(txMax, usePin, pinNumber).then(response => { console.log('UPDATE CARD RESPONSE ', response); fetchCardDetails(wallet, true); setEditMode(false); @@ -136,7 +142,27 @@ const BoltCardDetails = () => { }); } - + const saveCardPinNumber = () => { + wallet.savePinNumber(pinNumber).then(response => { + console.log('saveCardPinNumber RESPONSE ', response); + fetchCardDetails(wallet, true); + }).catch(err => { + console.log('ERROR', err.message); + alert(err.message); + }); + } + + const togglePin = (enabled) => { + setUsePin(enabled); + wallet.togglePin(enabled).then(response => { + console.log('togglePin RESPONSE ', response); + }).catch(err => { + console.log('ERROR', err.message); + alert(err.message); + }); + + setUsePin(false); + } return( @@ -167,7 +193,7 @@ const BoltCardDetails = () => { }} /> : - {details.tx_limit_sats} sats + {details.tx_limit_sats} sats } } @@ -205,35 +231,54 @@ const BoltCardDetails = () => { } + {!editMode && details && details.lnurlw_enable && + <> + Set card pin number + + + {usePin && <> + Set card pin number + + saveCardPinNumber()} + /> + } + + + } {!editMode && details && details.lnurlw_enable && <> Card Enable / Disable - { !wallet.getWipeData() && - <> - {!editMode && - - {details.lnurlw_enable == 'Y' ? - { - enableCard('false') - }} - backgroundColor={colors.redBG} - /> - : - { - enableCard('true') - }} - /> - } - + + {details.lnurlw_enable == 'Y' ? + { + enableCard('false') + }} + backgroundColor={colors.redBG} + /> + : + { + enableCard('true') + }} + /> } - - + } } From 7c5042dc75d9f031df278f4ef6c6daa90925fbdb Mon Sep 17 00:00:00 2001 From: Chloe Jung Date: Mon, 17 Jul 2023 16:42:53 +1200 Subject: [PATCH 02/27] Add pin enabled and pin limit sats on the card details screen. Allow to edit --- class/wallets/lightning-custodian-wallet.js | 5 +- screen/boltcard/details.js | 104 +++++++++++++++----- 2 files changed, 82 insertions(+), 27 deletions(-) diff --git a/class/wallets/lightning-custodian-wallet.js b/class/wallets/lightning-custodian-wallet.js index d9bb0b41f4..cb84ef169f 100644 --- a/class/wallets/lightning-custodian-wallet.js +++ b/class/wallets/lightning-custodian-wallet.js @@ -889,6 +889,7 @@ export class LightningCustodianWallet extends LegacyWallet { card_name: login+':'+password, tx_max: this.cardDetails.tx_limit_sats, day_max: this.cardDetails.day_limit_sats, + enable_pin: this.cardDetails.enable_pin ? 'true' : 'false' } }); @@ -905,7 +906,7 @@ export class LightningCustodianWallet extends LegacyWallet { return this.cardEnabled = status; } - async updateCard(tx_max) { + async updateCard(tx_max, pin_enable = 'false', pin_limit_sats = 0) { await this.checkLogin(); if(!this.cardDetails) await this.getCardDetails(); @@ -939,6 +940,8 @@ export class LightningCustodianWallet extends LegacyWallet { tx_max: tx_max, //dont update the day_limit_says day_max: this.cardDetails.day_limit_sats, + enable_pin: pin_enable, + pin_limit_sats: pin_limit_sats } }); diff --git a/screen/boltcard/details.js b/screen/boltcard/details.js index 659208a540..51c0edf393 100644 --- a/screen/boltcard/details.js +++ b/screen/boltcard/details.js @@ -10,6 +10,7 @@ import { TouchableOpacity, View } from 'react-native'; +import { CheckBox } from 'react-native-elements'; import { BlueButton, @@ -74,11 +75,14 @@ const BoltCardDetails = () => { const [cardKeys, setCardKeys] = useState(); const [txMax, setTxMax] = useState(0); + const [pinEnabled, setPinEnabled] = useState(false); + const [pinLimitSats, setPinLimitSats] = useState(0); const fetchCardDetails = async (w, reload = false) => { setLoading(true); w.getCardDetails(reload) .then(response => { + // console.log('details', response); setDetails(response); saveToDisk(); setLoading(false); @@ -107,10 +111,16 @@ const BoltCardDetails = () => { if(details && details.tx_limit_sats) { setTxMax(details.tx_limit_sats); } + if(details && details.pin_enable) { + setPinEnabled(details.pin_enable == "Y" ? true : false); + } + if(details && details.pin_limit_sats) { + setPinLimitSats(details.pin_limit_sats); + } }, [details]); const updateCard = () => { - wallet.updateCard(txMax).then(response => { + wallet.updateCard(txMax, pinEnabled, pinEnabled ? pinLimitSats : details.pin_limit_sats).then(response => { console.log('UPDATE CARD RESPONSE ', response); fetchCardDetails(wallet, true); setEditMode(false); @@ -146,31 +156,73 @@ const BoltCardDetails = () => { {loading ? Loading.... : - <> - {details && details.uid && - <> - Card UID - {details.uid} - - } - {details && details.tx_limit_sats && - <> - Transaction limit - {editMode - ? - { - var newVal = value.replace(/[^0-9]/, ''); - setTxMax(newVal); - }} - /> - : - {details.tx_limit_sats} sats - } - - } + <> + + {details && details.uid && + <> + Card UID + {details.uid} + + } + {details && details.tx_limit_sats && + <> + Transaction limit + {editMode + ? + { + var newVal = value.replace(/[^0-9]/, ''); + setTxMax(newVal); + }} + /> + : + {details.tx_limit_sats} sats + } + + } + {details && details.pin_enable && + <> + {editMode + ? + {setPinEnabled(!pinEnabled)}} + title="Enable PIN" + containerStyle={{marginLeft: 0, marginRight: 0}} + /> + : + <> + Pin Enabled + {details.pin_enable == 'Y' ? 'YES' : 'NO'} + + } + + } + {details && pinEnabled && details.pin_limit_sats && + <> + Pin Limit Sats + {editMode + ? + { + var newVal = value.replace(/[^0-9]/, ''); + setPinLimitSats(newVal); + }} + /> + : + <> + {details.pin_limit_sats} sats + + } + + } + + { wallet.getWipeData() ? From a8cfbceaccc778e9ce7eeec7d54eb425d522f0ff Mon Sep 17 00:00:00 2001 From: Chloe Jung Date: Tue, 18 Jul 2023 11:17:28 +1200 Subject: [PATCH 03/27] Add PIN limit field --- class/wallets/lightning-custodian-wallet.js | 12 ++-- screen/boltcard/details.js | 77 +++++++++++++-------- 2 files changed, 57 insertions(+), 32 deletions(-) diff --git a/class/wallets/lightning-custodian-wallet.js b/class/wallets/lightning-custodian-wallet.js index 79ec2c94f9..7fe4c5e568 100644 --- a/class/wallets/lightning-custodian-wallet.js +++ b/class/wallets/lightning-custodian-wallet.js @@ -872,7 +872,7 @@ export class LightningCustodianWallet extends LegacyWallet { return this.cardEnabled = status; } - async updateCard(tx_max, usePin, pinNumber) { + async updateCard(tx_max, pinLimitSats) { await this.checkLogin(); if(!this.cardDetails) await this.getCardDetails(); @@ -882,6 +882,11 @@ export class LightningCustodianWallet extends LegacyWallet { cardEnabled = 'true'; } + let enablePin = 'false'; + if(this.cardDetails.pin_enable == 'Y') { + enablePin = 'true'; + } + const response = await this._api.post('/updatecard', { headers: { 'Access-Control-Allow-Origin': '*', @@ -892,11 +897,10 @@ export class LightningCustodianWallet extends LegacyWallet { enable: cardEnabled, card_name: this.buildCardName(), tx_max: tx_max, - card_pin_number: pinNumber, //dont update the day_limit_says day_max: this.cardDetails.day_limit_sats, - enable_pin: pin_enable, - pin_limit_sats: pin_limit_sats + enable_pin: enablePin, + pin_limit_sats: pinLimitSats } }); diff --git a/screen/boltcard/details.js b/screen/boltcard/details.js index 94e78bdb9e..9f17b7f80c 100644 --- a/screen/boltcard/details.js +++ b/screen/boltcard/details.js @@ -117,13 +117,13 @@ const BoltCardDetails = () => { if(details && details.pin_enable) { setUsePin(details.pin_enable == 'Y' ? true : false); } - // if(details && details.pin_limit_sats) { - // setPinLimitSats(details.pin_limit_sats); - // } + if(details && details.pin_limit_sats) { + setPinLimitSats(details.pin_limit_sats); + } }, [details]); const updateCard = () => { - wallet.updateCard(txMax, usePin, pinNumber).then(response => { + wallet.updateCard(txMax, pinLimitSats).then(response => { console.log('UPDATE CARD RESPONSE ', response); fetchCardDetails(wallet, true); setEditMode(false); @@ -181,30 +181,51 @@ const BoltCardDetails = () => { Loading.... : <> - {details && details.uid && - <> - Card UID - {details.uid} - - } - {details && details.tx_limit_sats && - <> - Transaction limit - {editMode - ? - { - var newVal = value.replace(/[^0-9]/, ''); - setTxMax(newVal); - }} - /> - : - {details.tx_limit_sats} sats - } - - } + + {details && details.uid && + <> + Card UID + {details.uid} + + } + {details && details.tx_limit_sats && + <> + Transaction limit + {editMode + ? + { + var newVal = value.replace(/[^0-9]/, ''); + setTxMax(newVal); + }} + /> + : + {details.tx_limit_sats} sats + } + + } + {details && details.pin_limit_sats && + <> + PIN limit + {editMode + ? + { + var newVal = value.replace(/[^0-9]/, ''); + setPinLimitSats(newVal); + }} + /> + : + {details.pin_limit_sats} sats + } + + } + + { wallet.getWipeData() ? From 3a3866e2fa30e6dc81503b19cce0f0c70f981012 Mon Sep 17 00:00:00 2001 From: Chloe Jung Date: Tue, 18 Jul 2023 13:42:16 +1200 Subject: [PATCH 04/27] Add a react native toast message. Before saving PIN, check if the PIN is 4 digit number. --- App.js | 2 ++ package-lock.json | 15 +++++++++++++ package.json | 1 + screen/boltcard/details.js | 43 +++++++++++++++++++++++++++----------- 4 files changed, 49 insertions(+), 12 deletions(-) diff --git a/App.js b/App.js index e7765b3d01..0e79339304 100644 --- a/App.js +++ b/App.js @@ -16,6 +16,7 @@ import { } from 'react-native'; import { NavigationContainer, CommonActions } from '@react-navigation/native'; import { SafeAreaProvider } from 'react-native-safe-area-context'; +import Toast from 'react-native-toast-message'; import { navigationRef } from './NavigationService'; import * as NavigationService from './NavigationService'; import ReactNativeHapticFeedback from 'react-native-haptic-feedback'; @@ -382,6 +383,7 @@ const App = () => { + ); }; diff --git a/package-lock.json b/package-lock.json index 48a063d1c2..1c3e81cacb 100644 --- a/package-lock.json +++ b/package-lock.json @@ -96,6 +96,7 @@ "react-native-share": "8.2.1", "react-native-svg": "13.8.0", "react-native-tcp-socket": "5.6.2", + "react-native-toast-message": "^2.1.6", "react-native-tor": "0.1.8", "react-native-vector-icons": "9.2.0", "react-native-watch-connectivity": "1.1.0", @@ -20777,6 +20778,15 @@ "ieee754": "^1.1.13" } }, + "node_modules/react-native-toast-message": { + "version": "2.1.6", + "resolved": "https://registry.npmjs.org/react-native-toast-message/-/react-native-toast-message-2.1.6.tgz", + "integrity": "sha512-VctXuq20vmRa9AE13acaNZhrLcS3FaBS2zEevS3+vhBsnVZYG0FIlWIis9tVnpnNxUb3ART+BWtwQjzSttXTng==", + "peerDependencies": { + "react": "*", + "react-native": "*" + } + }, "node_modules/react-native-tor": { "version": "0.1.8", "integrity": "sha512-rRArwpqTQoUrQ3WQxc1WLkk1Eg/yjiwU775AxnSt6E7Nfy1V9H6+R9reMD5PJ/39qcuDYv3F7i3MR8Rjy7lOZA==", @@ -41138,6 +41148,11 @@ } } }, + "react-native-toast-message": { + "version": "2.1.6", + "resolved": "https://registry.npmjs.org/react-native-toast-message/-/react-native-toast-message-2.1.6.tgz", + "integrity": "sha512-VctXuq20vmRa9AE13acaNZhrLcS3FaBS2zEevS3+vhBsnVZYG0FIlWIis9tVnpnNxUb3ART+BWtwQjzSttXTng==" + }, "react-native-tor": { "version": "0.1.8", "integrity": "sha512-rRArwpqTQoUrQ3WQxc1WLkk1Eg/yjiwU775AxnSt6E7Nfy1V9H6+R9reMD5PJ/39qcuDYv3F7i3MR8Rjy7lOZA==", diff --git a/package.json b/package.json index 19d4dcdb72..7709467e03 100644 --- a/package.json +++ b/package.json @@ -185,6 +185,7 @@ "react-native-share": "8.2.1", "react-native-svg": "13.8.0", "react-native-tcp-socket": "5.6.2", + "react-native-toast-message": "^2.1.6", "react-native-tor": "0.1.8", "react-native-vector-icons": "9.2.0", "react-native-watch-connectivity": "1.1.0", diff --git a/screen/boltcard/details.js b/screen/boltcard/details.js index 9f17b7f80c..ac9d850c4d 100644 --- a/screen/boltcard/details.js +++ b/screen/boltcard/details.js @@ -22,6 +22,7 @@ import { BlueStorageContext } from '../../blue_modules/storage-context'; import alert from '../../components/Alert'; import navigationStyle from '../../components/navigationStyle'; import { ListItem } from 'react-native-elements'; +import Toast from 'react-native-toast-message'; @@ -150,9 +151,21 @@ const BoltCardDetails = () => { } const saveCardPinNumber = () => { + if(!((/^\d+$/.test(pinNumber) && pinNumber.length == 4))) { + Toast.show({ + type: 'error', + text1: 'PIN must be 4 digit number' + }); + return; + } wallet.savePinNumber(pinNumber).then(response => { console.log('saveCardPinNumber RESPONSE ', response); fetchCardDetails(wallet, true); + Toast.show({ + type: 'success', + text1: 'PIN changed' + }); + setPinNumber(null); }).catch(err => { console.log('ERROR', err.message); alert(err.message); @@ -172,6 +185,11 @@ const BoltCardDetails = () => { setUsePin(false); } + const onNumberFieldChange = (val, setValue) => { + var newVal = val.replace(/[^0-9]/, ''); + setValue(newVal); + } + return( @@ -197,8 +215,7 @@ const BoltCardDetails = () => { keyboardType = 'numeric' value={txMax.toString()} onChangeText={(value) => { - var newVal = value.replace(/[^0-9]/, ''); - setTxMax(newVal); + onNumberFieldChange(value, setTxMax); }} /> : @@ -215,8 +232,7 @@ const BoltCardDetails = () => { keyboardType = 'numeric' value={pinLimitSats.toString()} onChangeText={(value) => { - var newVal = value.replace(/[^0-9]/, ''); - setPinLimitSats(newVal); + onNumberFieldChange(value, setPinLimitSats); }} /> : @@ -262,7 +278,6 @@ const BoltCardDetails = () => { } {!editMode && details && details.lnurlw_enable && <> - Set card pin number { switch={{ onValueChange: togglePin, value: usePin }} /> {usePin && <> - Set card pin number - + + Set card pin number + { + onNumberFieldChange(value, setPinNumber); + }} + /> + saveCardPinNumber()} + onPress={saveCardPinNumber} /> } From debdb2195092bce5f110b765fc663644dd397ac3 Mon Sep 17 00:00:00 2001 From: Chloe Jung Date: Tue, 18 Jul 2023 13:55:28 +1200 Subject: [PATCH 05/27] Update details screen --- screen/boltcard/details.js | 51 +++++++++++++++++++++----------------- 1 file changed, 28 insertions(+), 23 deletions(-) diff --git a/screen/boltcard/details.js b/screen/boltcard/details.js index ac9d850c4d..88fb2a79c4 100644 --- a/screen/boltcard/details.js +++ b/screen/boltcard/details.js @@ -128,6 +128,10 @@ const BoltCardDetails = () => { console.log('UPDATE CARD RESPONSE ', response); fetchCardDetails(wallet, true); setEditMode(false); + Toast.show({ + type: 'success', + text1: 'Card updated' + }); }).catch(err => { console.log('ERROR', err.message); alert(err.message); @@ -278,30 +282,31 @@ const BoltCardDetails = () => { } {!editMode && details && details.lnurlw_enable && <> - - - {usePin && <> - - Set card pin number - { - onNumberFieldChange(value, setPinNumber); - }} - /> - - + PIN + - } - + {usePin && <> + + Set card pin number + { + onNumberFieldChange(value, setPinNumber); + }} + /> + + + } + } {!editMode && details && details.lnurlw_enable && From 5b6afbd0f3b9a87a1c4a8ebcf26abbd3dfb8bd5c Mon Sep 17 00:00:00 2001 From: Chloe Jung Date: Tue, 18 Jul 2023 16:35:11 +1200 Subject: [PATCH 06/27] Set a max length on the PIN number field --- screen/boltcard/details.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/screen/boltcard/details.js b/screen/boltcard/details.js index 88fb2a79c4..5f99b12476 100644 --- a/screen/boltcard/details.js +++ b/screen/boltcard/details.js @@ -189,8 +189,11 @@ const BoltCardDetails = () => { setUsePin(false); } - const onNumberFieldChange = (val, setValue) => { + const onNumberFieldChange = (val, setValue, maxLength = null) => { var newVal = val.replace(/[^0-9]/, ''); + if(maxLength) { + newVal = newVal.slice(0, maxLength); + } setValue(newVal); } @@ -297,7 +300,7 @@ const BoltCardDetails = () => { keyboardType = 'numeric' value={pinNumber} onChangeText={(value) => { - onNumberFieldChange(value, setPinNumber); + onNumberFieldChange(value, setPinNumber, 4); }} /> From 4b0192c885d75edc8324c39716befa1f88ac7284 Mon Sep 17 00:00:00 2001 From: Chloe Jung Date: Wed, 26 Jul 2023 17:11:41 +1200 Subject: [PATCH 07/27] Remove 'BoltCardDisconnectHelp' and 'BoltCardCreateHelp' screens --- Navigation.js | 4 - screen/boltcard/create.js | 13 +-- screen/boltcard/createHelp.js | 137 ------------------------------ screen/boltcard/disconnect.js | 13 +-- screen/boltcard/disconnectHelp.js | 137 ------------------------------ 5 files changed, 2 insertions(+), 302 deletions(-) delete mode 100644 screen/boltcard/createHelp.js delete mode 100644 screen/boltcard/disconnectHelp.js diff --git a/Navigation.js b/Navigation.js index c80b21c131..31b4526207 100644 --- a/Navigation.js +++ b/Navigation.js @@ -87,8 +87,6 @@ import UnlockWith from './UnlockWith'; import BoltCardCreate from './screen/boltcard/create'; import BoltCardDetails from './screen/boltcard/details'; -import BoltCardCreateHelp from './screen/boltcard/createHelp' -import BoltCardDisconnectHelp from './screen/boltcard/disconnectHelp' import BoltCardDisconnect from './screen/boltcard/disconnect'; const WalletsStack = createNativeStackNavigator(); @@ -482,8 +480,6 @@ const BoltCardCreateRoot = () => { - - ); }; diff --git a/screen/boltcard/create.js b/screen/boltcard/create.js index d4ec76bea4..9d254372dc 100644 --- a/screen/boltcard/create.js +++ b/screen/boltcard/create.js @@ -629,18 +629,7 @@ BoltCardCreate.navigationOptions = navigationStyle( (options, { theme, navigation, route }) => ( { ...options, - title: "Connect bolt card", - // headerLeft: () => Platform.OS == 'ios' ? ( - // - // navigation.navigate('BoltCardCreateHelp') - // } - // > - // - // - // ) : null + title: "Connect bolt card" }), ); diff --git a/screen/boltcard/createHelp.js b/screen/boltcard/createHelp.js deleted file mode 100644 index ccde5ef622..0000000000 --- a/screen/boltcard/createHelp.js +++ /dev/null @@ -1,137 +0,0 @@ -import React from 'react'; -import { StyleSheet, View, Text, ScrollView, Share, Alert, TouchableOpacity } from 'react-native' -import { useNavigation, useTheme } from '@react-navigation/native'; -import {Icon} from 'react-native-elements'; - -import navigationStyle from '../../components/navigationStyle'; -import { BlueButton } from '../../BlueComponents'; - -const BoltCardCreateHelp = () => { - - const { colors } = useTheme(); - const { navigate, goBacks } = useNavigation(); - - const stylesHook = StyleSheet.create({ - modalContent: { - backgroundColor: colors.modal, - borderTopColor: colors.foregroundColor, - borderWidth: colors.borderWidth, - }, - customAmount: { - borderColor: colors.formBorder, - borderBottomColor: colors.formBorder, - backgroundColor: colors.inputBackgroundColor, - }, - customAmountText: { - color: colors.foregroundColor, - }, - root: { - backgroundColor: colors.elevated, - }, - rootBackgroundColor: { - backgroundColor: colors.elevated, - }, - amount: { - color: colors.foregroundColor, - }, - label: { - color: colors.foregroundColor, - }, - modalButton: { - backgroundColor: colors.modalButton, - }, - }); - - const onShare = async () => { - try { - const result = await Share.share({ - message: 'Boltcard NFC Programmer', - url: 'https://play.google.com/store/apps/details?id=com.lightningnfcapp' - }); - if (result.action === Share.sharedAction) { - if (result.activityType) { - // shared with activity type of result.activityType - } else { - // shared - } - } else if (result.action === Share.dismissedAction) { - // dismissed - } - } catch (error) { - Alert.alert(error.message); - } - }; - - return ( - - - - You need an android phone - You will need an android phone to programme your bolt card. iOS integration is coming. Follow us on any updates. - - 1. Install Boltcard NFC Programmer on an android phone from Google Play Store - - - - 2. On the Create Bolt Card screen, click the Scan QR Code button. - 3. Scan the QR code shown on the Bolt card wallet app. - 4. Follow the steps on the app to connect your bolt card. - 5. After connecting the card successfully, click the I've connected my card button on the Bolt card wallet app. - 6. Your card should be all set to go to make your first payment! - - - - - - ); -} - -const styles = StyleSheet.create({ - title: { - fontSize: 30, - lineHeight: 35, - fontWeight: '700', - marginBottom: 20, - }, - scrollBody: { - marginTop: 32, - flexGrow: 1, - alignItems: 'center', - paddingHorizontal: 16, - }, - note: { - fontSize: 12, - lineHeight: 16, - marginBottom: 10 - }, - step: { - fontSize: 16, - lineHeight: 20, - marginBottom: 10 - }, - bold: { - fontWeight: '600' - } -}); - -BoltCardCreateHelp.navigationOptions = navigationStyle( - { - closeButton: true, - headerHideBackButton: true, - }, - (options, { theme, navigation, route }) => ( - { - ...options, - title: "How to connect bolt card", - modal: "modal", - headerLeft: () => ( - {navigation.goBack()}}> - - - ), - headerRight: () => null - } - ) -); - -export default BoltCardCreateHelp; \ No newline at end of file diff --git a/screen/boltcard/disconnect.js b/screen/boltcard/disconnect.js index b9faf5afd9..9115383af8 100644 --- a/screen/boltcard/disconnect.js +++ b/screen/boltcard/disconnect.js @@ -437,18 +437,7 @@ BoltCardDisconnect.navigationOptions = navigationStyle( (options, { theme, navigation, route }) => ( { ...options, - title: "Disconnect bolt card", - // headerLeft: () => Platform.OS == 'ios' ? ( - // - // navigation.navigate('BoltCardDisconnectHelp') - // } - // > - // - // - // ) : null + title: "Disconnect bolt card" } ), ); diff --git a/screen/boltcard/disconnectHelp.js b/screen/boltcard/disconnectHelp.js deleted file mode 100644 index 2b85a8b47e..0000000000 --- a/screen/boltcard/disconnectHelp.js +++ /dev/null @@ -1,137 +0,0 @@ -import React from 'react'; -import { StyleSheet, View, Text, ScrollView, Share, Alert, TouchableOpacity } from 'react-native' -import { useNavigation, useTheme } from '@react-navigation/native'; -import {Icon} from 'react-native-elements'; - -import navigationStyle from '../../components/navigationStyle'; -import { BlueButton } from '../../BlueComponents'; - -const BoltCardDisconnectHelp = () => { - - const { colors } = useTheme(); - const { navigate, goBacks } = useNavigation(); - - const stylesHook = StyleSheet.create({ - modalContent: { - backgroundColor: colors.modal, - borderTopColor: colors.foregroundColor, - borderWidth: colors.borderWidth, - }, - customAmount: { - borderColor: colors.formBorder, - borderBottomColor: colors.formBorder, - backgroundColor: colors.inputBackgroundColor, - }, - customAmountText: { - color: colors.foregroundColor, - }, - root: { - backgroundColor: colors.elevated, - }, - rootBackgroundColor: { - backgroundColor: colors.elevated, - }, - amount: { - color: colors.foregroundColor, - }, - label: { - color: colors.foregroundColor, - }, - modalButton: { - backgroundColor: colors.modalButton, - }, - }); - - const onShare = async () => { - try { - const result = await Share.share({ - message: 'Boltcard NFC Programmer', - url: 'https://play.google.com/store/apps/details?id=com.lightningnfcapp' - }); - if (result.action === Share.sharedAction) { - if (result.activityType) { - // shared with activity type of result.activityType - } else { - // shared - } - } else if (result.action === Share.dismissedAction) { - // dismissed - } - } catch (error) { - Alert.alert(error.message); - } - }; - - return ( - - - - You need an android phone - You will need an android phone to programme your bolt card. iOS integration is coming. Follow us on any updates. - - 1. Install Boltcard NFC Programmer on an android phone from Google Play Store - - - - 2. Go to Advanced > Reset Keys and click the Scan QR Code button under the Wipe Keys QR code. - 3. Scan the QR code shown on the Bolt card wallet app. - 4. Click the RESET CARD NOW button to disconnect your card. - 5. After disconnecting the card successfully, click the I've disconnected my card button on the Bolt card wallet app. - 6. Your card should be disconnected successfully. - - - - - - ); -} - -const styles = StyleSheet.create({ - title: { - fontSize: 30, - lineHeight: 35, - fontWeight: '700', - marginBottom: 20, - }, - scrollBody: { - marginTop: 32, - flexGrow: 1, - alignItems: 'center', - paddingHorizontal: 16, - }, - note: { - fontSize: 12, - lineHeight: 16, - marginBottom: 10 - }, - step: { - fontSize: 16, - lineHeight: 20, - marginBottom: 10 - }, - bold: { - fontWeight: '600' - } -}); - -BoltCardDisconnectHelp.navigationOptions = navigationStyle( - { - closeButton: true, - headerHideBackButton: true, - }, - (options, { theme, navigation, route }) => ( - { - ...options, - title: "How to disconnect bolt card", - modal: "modal", - headerLeft: () => ( - {navigation.goBack()}}> - - - ), - headerRight: () => null - } - ) -); - -export default BoltCardDisconnectHelp; \ No newline at end of file From d249b76f89d228c1140038626cdec640ed8e0ab4 Mon Sep 17 00:00:00 2001 From: Chloe Jung Date: Wed, 2 Aug 2023 15:44:14 +1200 Subject: [PATCH 08/27] Try using the new api call "updatecardwithpin" first then if 404, use the "updatecard" api call --- class/wallets/lightning-custodian-wallet.js | 49 +++++++++++++++++++-- 1 file changed, 45 insertions(+), 4 deletions(-) diff --git a/class/wallets/lightning-custodian-wallet.js b/class/wallets/lightning-custodian-wallet.js index 7fe4c5e568..63f60a38d4 100644 --- a/class/wallets/lightning-custodian-wallet.js +++ b/class/wallets/lightning-custodian-wallet.js @@ -844,7 +844,7 @@ export class LightningCustodianWallet extends LegacyWallet { if(!this.cardDetails) await this.getCardDetails(); console.log('enable bool', status); - const response = await this._api.post('/updatecard', { + var response = await this._api.post('/updatecardwithpin', { headers: { 'Access-Control-Allow-Origin': '*', 'Content-Type': 'application/json', @@ -859,7 +859,24 @@ export class LightningCustodianWallet extends LegacyWallet { } }); + if(response.status == "404") { + response = await this._api.post('/updatecard', { + headers: { + 'Access-Control-Allow-Origin': '*', + 'Content-Type': 'application/json', + Authorization: 'Bearer' + ' ' + this.access_token, + }, + body: { + enable: status, + card_name: this.buildCardName(), + tx_max: this.cardDetails.tx_limit_sats, + day_max: this.cardDetails.day_limit_sats + } + }); + } + const json = response.body; + if (typeof json === 'undefined') { throw new Error('API failure: ' + response.err + ' ' + JSON.stringify(response.body)); } @@ -887,7 +904,7 @@ export class LightningCustodianWallet extends LegacyWallet { enablePin = 'true'; } - const response = await this._api.post('/updatecard', { + var response = await this._api.post('/updatecardwithpin', { headers: { 'Access-Control-Allow-Origin': '*', 'Content-Type': 'application/json', @@ -904,6 +921,23 @@ export class LightningCustodianWallet extends LegacyWallet { } }); + if(response.status == "404") { + response = await this._api.post('/updatecard', { + headers: { + 'Access-Control-Allow-Origin': '*', + 'Content-Type': 'application/json', + Authorization: 'Bearer' + ' ' + this.access_token, + }, + body: { + enable: cardEnabled, + card_name: this.buildCardName(), + tx_max: tx_max, + //dont update the day_limit_says + day_max: this.cardDetails.day_limit_sats + } + }); + } + const json = response.body; if (typeof json === 'undefined') { throw new Error('API failure: ' + response.err + ' ' + JSON.stringify(response.body)); @@ -980,7 +1014,7 @@ export class LightningCustodianWallet extends LegacyWallet { } - const response = await this._api.post('/updatecard', { + const response = await this._api.post('/updatecardwithpin', { headers: { 'Access-Control-Allow-Origin': '*', 'Content-Type': 'application/json', @@ -997,6 +1031,9 @@ export class LightningCustodianWallet extends LegacyWallet { } }); + if(response.status == "404") { + throw new Error('API failure: You cannot enable PIN. Please update your hub'); + } const json = response.body; if (typeof json === 'undefined') { @@ -1027,7 +1064,7 @@ export class LightningCustodianWallet extends LegacyWallet { } - const response = await this._api.post('/updatecard', { + const response = await this._api.post('/updatecardwithpin', { headers: { 'Access-Control-Allow-Origin': '*', 'Content-Type': 'application/json', @@ -1045,6 +1082,10 @@ export class LightningCustodianWallet extends LegacyWallet { } }); + if(response.status == "404") { + throw new Error('API failure: You cannot update PIN. Please update your hub'); + } + const json = response.body; if (typeof json === 'undefined') { From b90a47d1e7446eaa182131ab93da426acaa6be0b Mon Sep 17 00:00:00 2001 From: Chloe Jung Date: Wed, 2 Aug 2023 17:17:14 +1200 Subject: [PATCH 09/27] Move the enable card button up --- screen/boltcard/details.js | 54 ++++++++++++++++++++------------------ 1 file changed, 28 insertions(+), 26 deletions(-) diff --git a/screen/boltcard/details.js b/screen/boltcard/details.js index 5f99b12476..9d7325c6da 100644 --- a/screen/boltcard/details.js +++ b/screen/boltcard/details.js @@ -283,6 +283,33 @@ const BoltCardDetails = () => { } + {!editMode && details && details.lnurlw_enable && + <> + Card Enable / Disable + { !wallet.getWipeData() + && + + {details.lnurlw_enable == 'Y' ? + { + enableCard('false') + }} + backgroundColor={colors.redBG} + /> + : + { + enableCard('true') + }} + /> + } + + } + + } + {!editMode && details && details.lnurlw_enable && <> @@ -312,32 +339,7 @@ const BoltCardDetails = () => { } - {!editMode && details && details.lnurlw_enable && - <> - Card Enable / Disable - { !wallet.getWipeData() - && - - {details.lnurlw_enable == 'Y' ? - { - enableCard('false') - }} - backgroundColor={colors.redBG} - /> - : - { - enableCard('true') - }} - /> - } - - } - - } + {!editMode && From 9efd2078381eb56d4d66b316be603f3e612ea4cb Mon Sep 17 00:00:00 2001 From: Chloe Jung Date: Thu, 3 Aug 2023 11:29:22 +1200 Subject: [PATCH 10/27] Update createboltcard api call --- class/wallets/lightning-custodian-wallet.js | 15 ++++++++++++++- screen/boltcard/create.js | 1 + 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/class/wallets/lightning-custodian-wallet.js b/class/wallets/lightning-custodian-wallet.js index 63f60a38d4..37f468be16 100644 --- a/class/wallets/lightning-custodian-wallet.js +++ b/class/wallets/lightning-custodian-wallet.js @@ -721,7 +721,7 @@ export class LightningCustodianWallet extends LegacyWallet { return this.createcardurl; } - const response = await this._api.post('/createboltcard', { + var response = await this._api.post('/createboltcardwithcard', { headers: { 'Access-Control-Allow-Origin': '*', 'Content-Type': 'application/json', @@ -732,6 +732,19 @@ export class LightningCustodianWallet extends LegacyWallet { } }); + if(response.status == "404") { + response = await this._api.post('/createboltcard', { + headers: { + 'Access-Control-Allow-Origin': '*', + 'Content-Type': 'application/json', + Authorization: 'Bearer' + ' ' + this.access_token, + }, + body: { + card_name: buildCardName() + } + }); + } + const json = response.body; if (typeof json === 'undefined') { throw new Error('API failure: ' + response.err + ' ' + JSON.stringify(response.body)); diff --git a/screen/boltcard/create.js b/screen/boltcard/create.js index 9d254372dc..712d23bc42 100644 --- a/screen/boltcard/create.js +++ b/screen/boltcard/create.js @@ -385,6 +385,7 @@ const BoltCardCreate = () => { Programming your bolt card... + Do not remove your card until writing is complete. : <> From af656b6d46b876d02243575664bffd9d941a914e Mon Sep 17 00:00:00 2001 From: chloehjung <37277782+chloehjung@users.noreply.github.com> Date: Thu, 3 Aug 2023 13:13:52 +1200 Subject: [PATCH 11/27] Add more vertical padding for ios for the text input component --- BlueComponents.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/BlueComponents.js b/BlueComponents.js index 5db1a1cd40..bef0c1bb4b 100644 --- a/BlueComponents.js +++ b/BlueComponents.js @@ -478,7 +478,7 @@ export const BlueFormTextInput = props => { underlineColorAndroid="transparent" style={{ paddingHorizontal: 8, - paddingVertical: 3, + paddingVertical: Platform.OS == 'ios' ? 8 : 3, marginTop: 5, marginHorizontal: 0, borderColor: colors.formBorder, From 6666b4358b2c8d32eb3824ced91c27da39259cad Mon Sep 17 00:00:00 2001 From: chloehjung <37277782+chloehjung@users.noreply.github.com> Date: Thu, 3 Aug 2023 13:14:25 +1200 Subject: [PATCH 12/27] Add 'KeyboardAvoidingView' to the boltcard details screen so the keyboard doesn't hide the PIN text input --- screen/boltcard/details.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/screen/boltcard/details.js b/screen/boltcard/details.js index 9d7325c6da..00165a376b 100644 --- a/screen/boltcard/details.js +++ b/screen/boltcard/details.js @@ -9,7 +9,8 @@ import { Text, TouchableOpacity, View, - TouchableWithoutFeedback + TouchableWithoutFeedback, + KeyboardAvoidingView } from 'react-native'; import { @@ -201,6 +202,9 @@ const BoltCardDetails = () => { + {loading ? Loading.... @@ -366,6 +370,8 @@ const BoltCardDetails = () => { } + + From d3b121e599a7da6bda056b4f626c23eead21f091 Mon Sep 17 00:00:00 2001 From: chloehjung <37277782+chloehjung@users.noreply.github.com> Date: Thu, 3 Aug 2023 13:14:44 +1200 Subject: [PATCH 13/27] updates for xcode --- ios/BoltCardWallet.xcodeproj/project.pbxproj | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ios/BoltCardWallet.xcodeproj/project.pbxproj b/ios/BoltCardWallet.xcodeproj/project.pbxproj index 0e17c4388b..35e69058e0 100644 --- a/ios/BoltCardWallet.xcodeproj/project.pbxproj +++ b/ios/BoltCardWallet.xcodeproj/project.pbxproj @@ -757,7 +757,7 @@ ); mainGroup = 83CBB9F61A601CBA00E9B192; packageReferences = ( - 6DFC806E24EA0B6C007B8700 /* XCRemoteSwiftPackageReference "EFQRCode" */, + 6DFC806E24EA0B6C007B8700 /* RemoteSwiftPackageReference */, ); productRefGroup = 83CBBA001A601CBA00E9B192 /* Products */; projectDirPath = ""; @@ -1536,7 +1536,7 @@ /* End XCConfigurationList section */ /* Begin XCRemoteSwiftPackageReference section */ - 6DFC806E24EA0B6C007B8700 /* XCRemoteSwiftPackageReference "EFQRCode" */ = { + 6DFC806E24EA0B6C007B8700 /* RemoteSwiftPackageReference */ = { isa = XCRemoteSwiftPackageReference; repositoryURL = "https://github.com/EFPrefix/EFQRCode.git"; requirement = { From 83fa227067022d74cf7a45cc4beae2d99a76ea65 Mon Sep 17 00:00:00 2001 From: chloehjung <37277782+chloehjung@users.noreply.github.com> Date: Thu, 3 Aug 2023 13:15:57 +1200 Subject: [PATCH 14/27] Bump the version for ios --- ios/BoltCardWallet.xcodeproj/project.pbxproj | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ios/BoltCardWallet.xcodeproj/project.pbxproj b/ios/BoltCardWallet.xcodeproj/project.pbxproj index 35e69058e0..2424b65075 100644 --- a/ios/BoltCardWallet.xcodeproj/project.pbxproj +++ b/ios/BoltCardWallet.xcodeproj/project.pbxproj @@ -757,7 +757,7 @@ ); mainGroup = 83CBB9F61A601CBA00E9B192; packageReferences = ( - 6DFC806E24EA0B6C007B8700 /* RemoteSwiftPackageReference */, + 6DFC806E24EA0B6C007B8700 /* XCRemoteSwiftPackageReference "EFQRCode" */, ); productRefGroup = 83CBBA001A601CBA00E9B192 /* Products */; projectDirPath = ""; @@ -1154,7 +1154,7 @@ "$(inherited)", "$(PROJECT_DIR)", ); - MARKETING_VERSION = 0.2.1; + MARKETING_VERSION = 0.3.1; OTHER_LDFLAGS = ( "$(inherited)", "-ObjC", @@ -1202,7 +1202,7 @@ "$(inherited)", "$(PROJECT_DIR)", ); - MARKETING_VERSION = 0.2.1; + MARKETING_VERSION = 0.3.1; OTHER_LDFLAGS = ( "$(inherited)", "-ObjC", @@ -1536,7 +1536,7 @@ /* End XCConfigurationList section */ /* Begin XCRemoteSwiftPackageReference section */ - 6DFC806E24EA0B6C007B8700 /* RemoteSwiftPackageReference */ = { + 6DFC806E24EA0B6C007B8700 /* XCRemoteSwiftPackageReference "EFQRCode" */ = { isa = XCRemoteSwiftPackageReference; repositoryURL = "https://github.com/EFPrefix/EFQRCode.git"; requirement = { From 3b870be402820c4f3fb8d97722b7710e1f0e8af3 Mon Sep 17 00:00:00 2001 From: chloehjung <37277782+chloehjung@users.noreply.github.com> Date: Thu, 3 Aug 2023 14:10:41 +1200 Subject: [PATCH 15/27] Update ios version num --- ios/BoltCardWallet.xcodeproj/project.pbxproj | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ios/BoltCardWallet.xcodeproj/project.pbxproj b/ios/BoltCardWallet.xcodeproj/project.pbxproj index 2424b65075..998fb6be52 100644 --- a/ios/BoltCardWallet.xcodeproj/project.pbxproj +++ b/ios/BoltCardWallet.xcodeproj/project.pbxproj @@ -1154,7 +1154,7 @@ "$(inherited)", "$(PROJECT_DIR)", ); - MARKETING_VERSION = 0.3.1; + MARKETING_VERSION = 0.3.0; OTHER_LDFLAGS = ( "$(inherited)", "-ObjC", @@ -1202,7 +1202,7 @@ "$(inherited)", "$(PROJECT_DIR)", ); - MARKETING_VERSION = 0.3.1; + MARKETING_VERSION = 0.3.0; OTHER_LDFLAGS = ( "$(inherited)", "-ObjC", From 5eea1fbc44bad3c53e77a41041d590b33ae43712 Mon Sep 17 00:00:00 2001 From: Rob Clarkson Date: Thu, 3 Aug 2023 15:23:16 +1200 Subject: [PATCH 16/27] Updates, UX improvements, bug fixes --- class/wallets/lightning-custodian-wallet.js | 15 +- screen/boltcard/details.js | 181 ++++++++++---------- 2 files changed, 100 insertions(+), 96 deletions(-) diff --git a/class/wallets/lightning-custodian-wallet.js b/class/wallets/lightning-custodian-wallet.js index 37f468be16..081c796921 100644 --- a/class/wallets/lightning-custodian-wallet.js +++ b/class/wallets/lightning-custodian-wallet.js @@ -852,6 +852,7 @@ export class LightningCustodianWallet extends LegacyWallet { } async enableCard(status) { + console.log('API enableCard', status); await this.checkLogin(); if(!this.cardDetails) await this.getCardDetails(); @@ -868,7 +869,8 @@ export class LightningCustodianWallet extends LegacyWallet { card_name: this.buildCardName(), tx_max: this.cardDetails.tx_limit_sats, day_max: this.cardDetails.day_limit_sats, - enable_pin: this.cardDetails.enable_pin ? 'true' : 'false' + enable_pin: this.cardDetails.enable_pin ? 'true' : 'false', + pin_limit_sats: this.cardDetails.pin_limit_sats } }); @@ -902,7 +904,8 @@ export class LightningCustodianWallet extends LegacyWallet { return this.cardEnabled = status; } - async updateCard(tx_max, pinLimitSats) { + async updateCard(tx_max) { + console.log('API updateCard', tx_max); await this.checkLogin(); if(!this.cardDetails) await this.getCardDetails(); @@ -930,7 +933,7 @@ export class LightningCustodianWallet extends LegacyWallet { //dont update the day_limit_says day_max: this.cardDetails.day_limit_sats, enable_pin: enablePin, - pin_limit_sats: pinLimitSats + pin_limit_sats: this.cardDetails.pin_limit_sats } }); @@ -1017,6 +1020,7 @@ export class LightningCustodianWallet extends LegacyWallet { } async togglePin(enable) { + console.log('API togglePin', enable); await this.checkLogin(); if(!this.cardDetails) await this.getCardDetails(); @@ -1061,7 +1065,8 @@ export class LightningCustodianWallet extends LegacyWallet { return json; } - async savePinNumber(pinNumber) { + async savePinNumber(pinNumber, pinLimitSats) { + console.log('API pinNumber', pinNumber, pinLimitSats); await this.checkLogin(); if(!this.cardDetails) await this.getCardDetails(); @@ -1090,7 +1095,7 @@ export class LightningCustodianWallet extends LegacyWallet { //dont update the day_limit_says day_max: this.cardDetails.day_limit_sats, enable_pin: enablePin, - pin_limit_sats: this.cardDetails.pin_limit_sats, + pin_limit_sats: pinLimitSats, card_pin_number: pinNumber } }); diff --git a/screen/boltcard/details.js b/screen/boltcard/details.js index 00165a376b..778414c254 100644 --- a/screen/boltcard/details.js +++ b/screen/boltcard/details.js @@ -10,7 +10,8 @@ import { TouchableOpacity, View, TouchableWithoutFeedback, - KeyboardAvoidingView + KeyboardAvoidingView, + Button } from 'react-native'; import { @@ -125,7 +126,8 @@ const BoltCardDetails = () => { }, [details]); const updateCard = () => { - wallet.updateCard(txMax, pinLimitSats).then(response => { + console.log('**** updateCard', txMax); + wallet.updateCard(txMax).then(response => { console.log('UPDATE CARD RESPONSE ', response); fetchCardDetails(wallet, true); setEditMode(false); @@ -156,19 +158,19 @@ const BoltCardDetails = () => { } const saveCardPinNumber = () => { - if(!((/^\d+$/.test(pinNumber) && pinNumber.length == 4))) { + if(pinNumber && !((/^\d+$/.test(pinNumber) && pinNumber.length == 4))) { Toast.show({ type: 'error', text1: 'PIN must be 4 digit number' }); return; } - wallet.savePinNumber(pinNumber).then(response => { + wallet.savePinNumber(pinNumber, pinLimitSats).then(response => { console.log('saveCardPinNumber RESPONSE ', response); fetchCardDetails(wallet, true); Toast.show({ type: 'success', - text1: 'PIN changed' + text1: 'PIN details saved' }); setPinNumber(null); }).catch(err => { @@ -210,49 +212,61 @@ const BoltCardDetails = () => { Loading.... : <> - - {details && details.uid && - <> - Card UID - {details.uid} - - } - {details && details.tx_limit_sats && - <> - Transaction limit - {editMode - ? - { - onNumberFieldChange(value, setTxMax); - }} - /> - : - {details.tx_limit_sats} sats - } - - } - {details && details.pin_limit_sats && - <> - PIN limit - {editMode - ? - { - onNumberFieldChange(value, setPinLimitSats); - }} - /> - : - {details.pin_limit_sats} sats - } - + + {details && details.uid && !editMode && + <> + Card UID + {details.uid} + + } + + + {details && details.tx_limit_sats && + <> + Transaction limit + {editMode + ? + { + onNumberFieldChange(value, setTxMax); + }} + /> + + : + + {details.tx_limit_sats} sats + + } @@ -298,7 +333,7 @@ const BoltCardDetails = () => { } - {!wallet.getWipeData() && !editMode && details && details.lnurlw_enable && + {!wallet.getWipeData() && !editMode && details && details.pin_enable && <> { } - + {!editMode && wallet && + + } {!editMode && - + { navigate('BoltCardCreateRoot', { screen: 'BoltCardDisconnect', From 8da027427d509be5501996d9940596b5a76b0f8a Mon Sep 17 00:00:00 2001 From: chloehjung <37277782+chloehjung@users.noreply.github.com> Date: Wed, 9 Aug 2023 17:28:07 +1200 Subject: [PATCH 26/27] Bump the version num for iOS --- ios/BoltCardWallet.xcodeproj/project.pbxproj | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ios/BoltCardWallet.xcodeproj/project.pbxproj b/ios/BoltCardWallet.xcodeproj/project.pbxproj index 998fb6be52..62ce279a72 100644 --- a/ios/BoltCardWallet.xcodeproj/project.pbxproj +++ b/ios/BoltCardWallet.xcodeproj/project.pbxproj @@ -1131,7 +1131,7 @@ CODE_SIGN_ENTITLEMENTS = BoltCardWallet/BoltCardWallet.entitlements; CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 1; + CURRENT_PROJECT_VERSION = 4; DEAD_CODE_STRIPPING = NO; DEVELOPMENT_TEAM = G2LFSW78NA; ENABLE_BITCODE = NO; @@ -1154,7 +1154,7 @@ "$(inherited)", "$(PROJECT_DIR)", ); - MARKETING_VERSION = 0.3.0; + MARKETING_VERSION = 0.3.1; OTHER_LDFLAGS = ( "$(inherited)", "-ObjC", @@ -1185,7 +1185,7 @@ CODE_SIGN_IDENTITY = "Apple Development"; "CODE_SIGN_IDENTITY[sdk=macosx*]" = "Apple Development"; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 1; + CURRENT_PROJECT_VERSION = 4; DEVELOPMENT_TEAM = G2LFSW78NA; ENABLE_BITCODE = NO; "ENABLE_HARDENED_RUNTIME[sdk=macosx*]" = YES; @@ -1202,7 +1202,7 @@ "$(inherited)", "$(PROJECT_DIR)", ); - MARKETING_VERSION = 0.3.0; + MARKETING_VERSION = 0.3.1; OTHER_LDFLAGS = ( "$(inherited)", "-ObjC", From 8e153ffc8f4237a102b148a6c039add97e152443 Mon Sep 17 00:00:00 2001 From: Chloe Jung Date: Wed, 9 Aug 2023 17:28:32 +1200 Subject: [PATCH 27/27] bump version num --- android/app/build.gradle | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/android/app/build.gradle b/android/app/build.gradle index 0ddbaafb00..c1d11abdf1 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -102,8 +102,8 @@ android { /* * https://www.epochconverter.com/ */ - versionCode 1691366430 - versionName "0.3.0" + versionCode 1691557776 + versionName "0.3.1" multiDexEnabled true testBuildType System.getProperty('testBuildType', 'debug') // This will later be used to control the test apk build type testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner' diff --git a/package.json b/package.json index 084cdf5ea9..4debd8df8d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "BoltCardWallet", - "version": "0.3.0", + "version": "0.3.1", "license": "MIT", "repository": { "type": "git",