mirror of
https://github.com/BlueWallet/BlueWallet.git
synced 2025-03-03 03:59:10 +01:00
ADD: change address
This commit is contained in:
parent
77343ce6e2
commit
3b61a5b72a
5 changed files with 39 additions and 4 deletions
|
@ -1034,4 +1034,12 @@ export class AbstractHDElectrumWallet extends AbstractHDWallet {
|
|||
|
||||
return ret;
|
||||
}
|
||||
|
||||
// check if address is a Change address. Needed for Coin control
|
||||
addressIsChange(address) {
|
||||
for (let c = 0; c < this.next_free_change_address_index + 1; c++) {
|
||||
if (address === this._getInternalAddressByIndex(c)) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -404,4 +404,10 @@ export class LegacyWallet extends AbstractWallet {
|
|||
allowSendMax() {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Check if address is a Change address. Needed for Coin control.
|
||||
// Useless for Legacy wallets, so it is always false
|
||||
addressIsChange(address) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -252,4 +252,9 @@ export class WatchOnlyWallet extends LegacyWallet {
|
|||
|
||||
return false;
|
||||
}
|
||||
|
||||
addressIsChange(...args) {
|
||||
if (this._hdWalletInstance) return this._hdWalletInstance.addressIsChange(...args);
|
||||
return super.getAllExternalAddresses(...args);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -403,6 +403,7 @@
|
|||
"co_sign_transaction": "Co-sign QR-airgapped transaction"
|
||||
},
|
||||
"cc": {
|
||||
"change": "change",
|
||||
"empty": "Wallet UTXO set is empty",
|
||||
"freeze": "freeze",
|
||||
"header": "Coin control",
|
||||
|
|
|
@ -13,6 +13,7 @@ import {
|
|||
TextInput,
|
||||
TouchableWithoutFeedback,
|
||||
View,
|
||||
useColorScheme,
|
||||
} from 'react-native';
|
||||
import { useRoute, useTheme, useNavigation } from '@react-navigation/native';
|
||||
|
||||
|
@ -27,14 +28,21 @@ const oStyles = StyleSheet.create({
|
|||
avatar: { borderColor: 'white', borderWidth: 1 },
|
||||
amount: { fontWeight: 'bold' },
|
||||
memo: { fontSize: 13, marginTop: 3 },
|
||||
changeLight: { backgroundColor: '#EEF0F4' },
|
||||
changeDark: { backgroundColor: '#3b3b3c', borderWidth: 0 },
|
||||
changeText: { color: '#9BA0A9' },
|
||||
freezeLight: { backgroundColor: '#F2D3D3' },
|
||||
freezeDark: { backgroundColor: '#5a4e4e', borderWidth: 0 },
|
||||
freezeText: { color: '#FC6D6D' },
|
||||
});
|
||||
|
||||
const Output = ({ item: { address, txid, value, vout }, oMemo, frozen, full = false, onPress }) => {
|
||||
const Output = ({ item: { address, txid, value, vout }, oMemo, frozen, change = false, full = false, onPress }) => {
|
||||
const { colors } = useTheme();
|
||||
const { txMetadata } = useContext(BlueStorageContext);
|
||||
const cs = useColorScheme();
|
||||
const memo = oMemo || txMetadata[txid]?.memo || '';
|
||||
const fullId = `${txid}:${vout}`;
|
||||
const shortId = `${address.substring(0, 10)}...${address.substr(address.length - 10)}`;
|
||||
const shortId = `${address.substring(0, 9)}...${address.substr(address.length - 9)}`;
|
||||
const color = `#${txid.substring(0, 6)}`;
|
||||
const amount = formatBalanceWithoutSuffix(value, BitcoinUnit.BTC, true);
|
||||
|
||||
|
@ -61,7 +69,12 @@ const Output = ({ item: { address, txid, value, vout }, oMemo, frozen, full = fa
|
|||
</ListItem.Subtitle>
|
||||
)}
|
||||
</ListItem.Content>
|
||||
{frozen && <Badge value={loc.cc.freeze} status="error" />}
|
||||
{change && (
|
||||
<Badge value={loc.cc.change} badgeStyle={oStyles[cs === 'dark' ? 'changeDark' : 'changeLight']} textStyle={oStyles.changeText} />
|
||||
)}
|
||||
{frozen && (
|
||||
<Badge value={loc.cc.freeze} badgeStyle={oStyles[cs === 'dark' ? 'freezeDark' : 'freezeLight']} textStyle={oStyles.freezeText} />
|
||||
)}
|
||||
</ListItem>
|
||||
);
|
||||
};
|
||||
|
@ -75,6 +88,7 @@ Output.propTypes = {
|
|||
}),
|
||||
oMemo: PropTypes.string,
|
||||
frozen: PropTypes.bool,
|
||||
change: PropTypes.bool,
|
||||
full: PropTypes.bool,
|
||||
onPress: PropTypes.func,
|
||||
};
|
||||
|
@ -167,7 +181,8 @@ const CoinControl = () => {
|
|||
|
||||
const renderItem = p => {
|
||||
const { memo, frozen } = wallet.getUTXOMetadata(p.item.txid, p.item.vout);
|
||||
return <Output item={p.item} oMemo={memo} frozen={frozen} onPress={() => handleChoose(p.item)} />;
|
||||
const change = wallet.addressIsChange(p.item.address);
|
||||
return <Output item={p.item} oMemo={memo} frozen={frozen} change={change} onPress={() => handleChoose(p.item)} />;
|
||||
};
|
||||
|
||||
return (
|
||||
|
|
Loading…
Add table
Reference in a new issue