Merge branch 'master' into passcodeexp

This commit is contained in:
Marcos Rodriguez Velez 2024-02-26 18:17:55 -04:00
commit 11ac96d672
No known key found for this signature in database
GPG key ID: 6030B2F48CCE86D7
10 changed files with 23 additions and 45 deletions

View file

@ -7,7 +7,6 @@ import WidgetCommunication from './WidgetCommunication';
import presentAlert from '../components/Alert';
const bitcoin = require('bitcoinjs-lib');
const ElectrumClient = require('electrum-client');
const reverse = require('buffer-reverse');
const BigNumber = require('bignumber.js');
const net = require('net');
@ -333,7 +332,7 @@ module.exports.getBalanceByAddress = async function (address) {
if (!mainClient) throw new Error('Electrum client is not connected');
const script = bitcoin.address.toOutputScript(address);
const hash = bitcoin.crypto.sha256(script);
const reversedHash = Buffer.from(reverse(hash));
const reversedHash = Buffer.from(hash).reverse();
const balance = await mainClient.blockchainScripthash_getBalance(reversedHash.toString('hex'));
balance.addr = address;
return balance;
@ -362,7 +361,7 @@ module.exports.getTransactionsByAddress = async function (address) {
if (!mainClient) throw new Error('Electrum client is not connected');
const script = bitcoin.address.toOutputScript(address);
const hash = bitcoin.crypto.sha256(script);
const reversedHash = Buffer.from(reverse(hash));
const reversedHash = Buffer.from(hash).reverse();
const history = await mainClient.blockchainScripthash_getHistory(reversedHash.toString('hex'));
for (const h of history || []) {
if (h.tx_hash) txhashHeightCache[h.tx_hash] = h.height; // cache tx height
@ -380,7 +379,7 @@ module.exports.getMempoolTransactionsByAddress = async function (address) {
if (!mainClient) throw new Error('Electrum client is not connected');
const script = bitcoin.address.toOutputScript(address);
const hash = bitcoin.crypto.sha256(script);
const reversedHash = Buffer.from(reverse(hash));
const reversedHash = Buffer.from(hash).reverse();
return mainClient.blockchainScripthash_getMempool(reversedHash.toString('hex'));
};
@ -477,7 +476,7 @@ module.exports.multiGetBalanceByAddress = async function (addresses, batchsize)
for (const addr of chunk) {
const script = bitcoin.address.toOutputScript(addr);
const hash = bitcoin.crypto.sha256(script);
let reversedHash = Buffer.from(reverse(hash));
let reversedHash = Buffer.from(hash).reverse();
reversedHash = reversedHash.toString('hex');
scripthashes.push(reversedHash);
scripthash2addr[reversedHash] = addr;
@ -523,7 +522,7 @@ module.exports.multiGetUtxoByAddress = async function (addresses, batchsize) {
for (const addr of chunk) {
const script = bitcoin.address.toOutputScript(addr);
const hash = bitcoin.crypto.sha256(script);
let reversedHash = Buffer.from(reverse(hash));
let reversedHash = Buffer.from(hash).reverse();
reversedHash = reversedHash.toString('hex');
scripthashes.push(reversedHash);
scripthash2addr[reversedHash] = addr;
@ -566,7 +565,7 @@ module.exports.multiGetHistoryByAddress = async function (addresses, batchsize)
for (const addr of chunk) {
const script = bitcoin.address.toOutputScript(addr);
const hash = bitcoin.crypto.sha256(script);
let reversedHash = Buffer.from(reverse(hash));
let reversedHash = Buffer.from(hash).reverse();
reversedHash = reversedHash.toString('hex');
scripthashes.push(reversedHash);
scripthash2addr[reversedHash] = addr;
@ -1039,7 +1038,7 @@ function txhexToElectrumTransaction(txhex) {
if (inn.witness[1]) txinwitness.push(inn.witness[1].toString('hex'));
ret.vin.push({
txid: reverse(inn.hash).toString('hex'),
txid: Buffer.from(inn.hash).reverse().toString('hex'),
vout: inn.index,
scriptSig: { hex: inn.script.toString('hex'), asm: '' },
txinwitness,

View file

@ -2,7 +2,6 @@ import { HDSegwitBech32Wallet } from './wallets/hd-segwit-bech32-wallet';
import { SegwitBech32Wallet } from './wallets/segwit-bech32-wallet';
const bitcoin = require('bitcoinjs-lib');
const BlueElectrum = require('../blue_modules/BlueElectrum');
const reverse = require('buffer-reverse');
const BigNumber = require('bignumber.js');
/**
@ -150,7 +149,7 @@ export class HDSegwitBech32Transaction {
const prevInputs = [];
for (const inp of this._txDecoded.ins) {
let reversedHash = Buffer.from(reverse(inp.hash));
let reversedHash = Buffer.from(inp.hash).reverse();
reversedHash = reversedHash.toString('hex');
prevInputs.push(reversedHash);
}
@ -161,7 +160,7 @@ export class HDSegwitBech32Transaction {
let wentIn = 0;
const utxos = [];
for (const inp of this._txDecoded.ins) {
let reversedHash = Buffer.from(reverse(inp.hash));
let reversedHash = Buffer.from(inp.hash).reverse();
reversedHash = reversedHash.toString('hex');
if (prevTransactions[reversedHash] && prevTransactions[reversedHash].vout && prevTransactions[reversedHash].vout[inp.index]) {
let value = prevTransactions[reversedHash].vout[inp.index].value;
@ -228,7 +227,7 @@ export class HDSegwitBech32Transaction {
const spentUtxos = this._wallet.getDerivedUtxoFromOurTransaction(true);
for (const inp of this._txDecoded.ins) {
const txidInUtxo = reverse(inp.hash).toString('hex');
const txidInUtxo = Buffer.from(inp.hash).reverse().toString('hex');
let found = false;
for (const spentU of spentUtxos) {

View file

@ -19,7 +19,6 @@ import { CreateTransactionResult, CreateTransactionUtxo, Transaction, Utxo } fro
const ECPair = ECPairFactory(ecc);
const BlueElectrum: typeof BlueElectrumNs = require('../../blue_modules/BlueElectrum');
const reverse = require('buffer-reverse');
const bip32 = BIP32Factory(ecc);
const bip47 = BIP47Factory(ecc);
@ -1165,7 +1164,7 @@ export class AbstractHDElectrumWallet extends AbstractHDWallet {
let masterFingerprintHex = Number(masterFingerprint).toString(16);
if (masterFingerprintHex.length < 8) masterFingerprintHex = '0' + masterFingerprintHex; // conversion without explicit zero might result in lost byte
const hexBuffer = Buffer.from(masterFingerprintHex, 'hex');
masterFingerprintBuffer = Buffer.from(reverse(hexBuffer));
masterFingerprintBuffer = Buffer.from(hexBuffer).reverse();
} else {
masterFingerprintBuffer = Buffer.from([0x00, 0x00, 0x00, 0x00]);
}
@ -1191,7 +1190,7 @@ export class AbstractHDElectrumWallet extends AbstractHDWallet {
let masterFingerprintHex = Number(masterFingerprint).toString(16);
if (masterFingerprintHex.length < 8) masterFingerprintHex = '0' + masterFingerprintHex; // conversion without explicit zero might result in lost byte
const hexBuffer = Buffer.from(masterFingerprintHex, 'hex');
masterFingerprintBuffer = Buffer.from(reverse(hexBuffer));
masterFingerprintBuffer = Buffer.from(hexBuffer).reverse();
} else {
masterFingerprintBuffer = Buffer.from([0x00, 0x00, 0x00, 0x00]);
}

View file

@ -3,7 +3,6 @@ import * as bip39 from 'bip39';
import * as bitcoin from 'bitcoinjs-lib';
import { Psbt, Transaction } from 'bitcoinjs-lib';
import b58 from 'bs58check';
import reverse from 'buffer-reverse';
import createHash from 'create-hash';
import { ECPairFactory } from 'ecpair';
import * as mn from 'electrum-mnemonic';
@ -1111,7 +1110,7 @@ export class MultisigHDWallet extends AbstractHDElectrumWallet {
// means we failed to get amounts that go in previously, so lets use utxo amounts cache we've build
// from non-segwit inputs
for (const inp of psbt.txInputs) {
const cacheKey = reverse(inp.hash).toString('hex') + ':' + inp.index;
const cacheKey = Buffer.from(inp.hash).reverse().toString('hex') + ':' + inp.index;
if (cacheUtxoAmounts[cacheKey]) goesIn += cacheUtxoAmounts[cacheKey];
}
}

View file

@ -281,6 +281,7 @@
"language": "Język",
"last_updated": "Ostatnia aktualizacja",
"language_isRTL": "Aby ustawienia dotyczące kierunku pisma wybranego języka zaczęły obowiązywać, BlueWallet musi być zrestartowany.",
"license": "Licencja",
"lightning_error_lndhub_uri": "Nieprawidłowy adres LNDHub",
"lightning_saved": "Wprowadzone przez ciebie zmiany zostały pomyślnie zachowane.",
"lightning_settings": "Ustawienia Lightning",
@ -452,7 +453,6 @@
"no_ln_wallet_error": "Musisz najpierw dodać portfel Lightning, zanim zapłacisz fakturę.",
"looks_like_bip38": "To wygląda na klucz prywatny chroniony hasłem (BIP38).",
"reorder_title": "Zmień kolejność portfeli",
"reorder_instructions": "Stuknij i przytrzmaj portfel aby go przeciągnąć na liście.",
"please_continue_scanning": "Proszę skanuj dalej.",
"select_no_bitcoin": "Nie ma dostępnych portfeli Bitcoin.",
"select_no_bitcoin_exp": "Portfel Bitcoin jest wymagany by uzupełnić portfel Lightning. Proszę utwórz lub zaimportuj.",
@ -462,7 +462,8 @@
"warning_do_not_disclose": "Uwaga! Nie ujawniać.",
"add_ln_wallet_first": "Najpierw musisz dodać portfel Lightning.",
"identity_pubkey": "Klucz publiczny tożsamości",
"xpub_title": "XPUB portfela"
"xpub_title": "XPUB portfela",
"search_wallets": "Szukaj portfeli"
},
"multisig": {
"multisig_vault": "Skarbiec",
@ -571,6 +572,8 @@
"sats": "satoshi"
},
"addresses": {
"copy_private_key": "Skopiuj klucz prywatny",
"sensitive_private_key": "Uwaga: klucz prywatne są skrajnie poufne. Kontynuować?",
"sign_title": "Podpisz/Weryfikuj wiadomość",
"sign_help": "Tutaj możesz stworzyć lub zweryfikować podpis kryptograficzny oparty o adres Bitcoin.",
"sign_sign": "Podpisz",

11
package-lock.json generated
View file

@ -38,7 +38,6 @@
"bitcoinjs-message": "2.2.0",
"bolt11": "1.4.1",
"buffer": "6.0.3",
"buffer-reverse": "1.0.1",
"coinselect": "3.1.13",
"crypto-js": "4.2.0",
"dayjs": "1.11.10",
@ -8402,11 +8401,6 @@
"resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.2.tgz",
"integrity": "sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ=="
},
"node_modules/buffer-reverse": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/buffer-reverse/-/buffer-reverse-1.0.1.tgz",
"integrity": "sha512-M87YIUBsZ6N924W57vDwT/aOu8hw7ZgdByz6ijksLjmHJELBASmYTTlNHRgjE+pTsT9oJXGaDSgqqwfdHotDUg=="
},
"node_modules/buffer-xor": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/buffer-xor/-/buffer-xor-1.0.3.tgz",
@ -28971,11 +28965,6 @@
"resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.2.tgz",
"integrity": "sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ=="
},
"buffer-reverse": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/buffer-reverse/-/buffer-reverse-1.0.1.tgz",
"integrity": "sha512-M87YIUBsZ6N924W57vDwT/aOu8hw7ZgdByz6ijksLjmHJELBASmYTTlNHRgjE+pTsT9oJXGaDSgqqwfdHotDUg=="
},
"buffer-xor": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/buffer-xor/-/buffer-xor-1.0.3.tgz",

View file

@ -124,7 +124,6 @@
"bitcoinjs-message": "2.2.0",
"bolt11": "1.4.1",
"buffer": "6.0.3",
"buffer-reverse": "1.0.1",
"coinselect": "3.1.13",
"crypto-js": "4.2.0",
"dayjs": "1.11.10",

View file

@ -271,6 +271,10 @@ export default class Selftest extends Component {
}
//
assertStrictEqual(Buffer.from('00ff0f', 'hex').reverse().toString('hex'), '0fff00');
//
} catch (Err) {
errorMessage += Err;
isOk = false;

View file

@ -18,8 +18,6 @@ import loc from '../../loc';
import { FiatUnit, FiatUnitSource, FiatUnitType, getFiatRate } from '../../models/fiatUnit';
dayjs.extend(require('dayjs/plugin/calendar'));
const ITEM_HEIGHT = 50;
const Currency = () => {
const { setPreferredFiatCurrency } = useContext(BlueStorageContext);
const [isSavingNewPreferredCurrency, setIsSavingNewPreferredCurrency] = useState(false);
@ -62,17 +60,11 @@ const Currency = () => {
fetchCurrency();
}, [setOptions]);
const getItemLayout = (_data: any, index: number) => ({
length: ITEM_HEIGHT,
offset: ITEM_HEIGHT * index,
index,
});
const renderItem = ({ item }: { item: FiatUnitType }) => (
<ListItem
disabled={isSavingNewPreferredCurrency || selectedCurrency.endPointKey === item.endPointKey}
title={`${item.endPointKey} (${item.symbol})`}
containerStyle={StyleSheet.flatten([styles.flex, { height: ITEM_HEIGHT }])}
containerStyle={StyleSheet.flatten([styles.flex, { minHeight: 60 }])}
checkmark={selectedCurrency.endPointKey === item.endPointKey}
onPress={async () => {
setIsSavingNewPreferredCurrency(true);
@ -104,7 +96,6 @@ const Currency = () => {
data={data}
initialNumToRender={30}
extraData={data}
getItemLayout={getItemLayout}
renderItem={renderItem}
/>
<BlueCard>

View file

@ -1,4 +0,0 @@
declare module 'buffer-reverse' {
declare function reverse(buffer: Buffer): Buffer;
export default reverse;
}