Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(wallet): Beignet Migration - DO NOT MERGE #1437

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 2 additions & 6 deletions __tests__/transactions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { getSelectedWallet } from '../src/utils/wallet';
import { TAvailableNetworks } from '../src/utils/networks';
import { mnemonic, walletState } from './utils/dummy-wallet';
import { createTransaction } from '../src/utils/wallet/transactions';
import { isValidBech32mEncodedString } from '../src/utils/scanner';
import { isValidBech32mEncodedString } from 'beignet';

const selectedNetwork: TAvailableNetworks = 'bitcoinTestnet';

Expand All @@ -28,7 +28,7 @@ describe('On chain transactions', () => {

updateWallet({ wallets: { wallet0: walletState } });

await setupOnChainTransaction({ selectedNetwork });
setupOnChainTransaction({});
});

it('Creates a transaction sending to a taproot address', async () => {
Expand All @@ -41,8 +41,6 @@ describe('On chain transactions', () => {
expect(network).toEqual('bitcoinTestnet');

updateSendTransaction({
selectedNetwork,
selectedWallet,
transaction: {
rbf: true,
outputs: [
Expand Down Expand Up @@ -77,8 +75,6 @@ describe('On chain transactions', () => {
const selectedWallet = getSelectedWallet();

updateSendTransaction({
selectedNetwork,
selectedWallet,
transaction: {
rbf: true,
outputs: [
Expand Down
3 changes: 2 additions & 1 deletion __tests__/utils/wait-for-electrum.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import net from 'net';
import BitcoinJsonRpc from 'bitcoin-json-rpc';
import ElectrumClient from 'electrum-client';
import { EProtocol } from 'beignet';

export const sleep = (ms): Promise<void> => {
return new Promise((resolve) => {
Expand All @@ -22,7 +23,7 @@ const initWaitForElectrumToSync = async (
false,
elAddr.port,
elAddr.host,
'tcp',
EProtocol.tcp,
);

electrum.subscribe.on('blockchain.headers.subscribe', (params) => {
Expand Down
8 changes: 7 additions & 1 deletion __tests__/wallet-restore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
import { connectToElectrum } from '../src/utils/wallet/electrum';
import { addElectrumPeer } from '../src/store/actions/settings';
import initWaitForElectrumToSync from './utils/wait-for-electrum';
import { EProtocol } from 'beignet';

jest.setTimeout(60_000);

Expand Down Expand Up @@ -71,7 +72,12 @@ describe('Wallet - wallet restore and receive', () => {
expect(store.getState().wallet.selectedNetwork).toEqual('bitcoinRegtest');

res = await addElectrumPeer({
peer: { host: '127.0.0.1', ssl: 60002, tcp: 60001, protocol: 'tcp' },
peer: {
host: '127.0.0.1',
ssl: 60002,
tcp: 60001,
protocol: EProtocol.tcp,
},
});
if (res.isErr()) {
throw res.error;
Expand Down
19 changes: 12 additions & 7 deletions __tests__/wallet-send.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,24 @@ import '../src/utils/i18n';
import store from '../src/store';
import { createNewWallet, startWalletServices } from '../src/utils/startup';
import {
updateAddressIndexes,
updateWallet,
resetSendTransaction,
updateSendTransaction,
setupOnChainTransaction,
updateAddressIndexes,
updateSendTransaction,
updateWallet,
} from '../src/store/actions/wallet';
import { connectToElectrum } from '../src/utils/wallet/electrum';
import {
broadcastTransaction,
createTransaction,
sendMax,
updateFee,
validateTransaction,
} from '../src/utils/wallet/transactions';
import { addElectrumPeer } from '../src/store/actions/settings';
import { getScriptHash } from '../src/utils/wallet';
import initWaitForElectrumToSync from './utils/wait-for-electrum';
import { runStorageCheck } from '../src/utils/wallet/checks';
import { EProtocol, validateTransaction } from 'beignet';

jest.setTimeout(60_000);

Expand Down Expand Up @@ -76,7 +76,12 @@ describe('Wallet - new wallet, send and receive', () => {
expect(store.getState().wallet.selectedNetwork).toEqual('bitcoinRegtest');

res = await addElectrumPeer({
peer: { host: '127.0.0.1', ssl: 60002, tcp: 60001, protocol: 'tcp' },
peer: {
host: '127.0.0.1',
ssl: 60002,
tcp: 60001,
protocol: EProtocol.tcp,
},
});
if (res.isErr()) {
throw res.error;
Expand Down Expand Up @@ -243,7 +248,7 @@ describe('Wallet - new wallet, send and receive', () => {
const receivingAddress2 = await rpc.getNewAddress();

// setup new transaction
res = resetSendTransaction();
res = await resetSendTransaction();
if (res.isErr()) {
throw res.error;
}
Expand All @@ -260,7 +265,7 @@ describe('Wallet - new wallet, send and receive', () => {
},
});

res = sendMax();
res = await sendMax();
if (res.isErr()) {
throw res.error;
}
Expand Down
13 changes: 7 additions & 6 deletions e2e/settings.e2e.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
electrumHost,
electrumPort,
} from './helpers';
import { EProtocol } from 'beignet';

const __DEV__ = process.env.DEV === 'true';

Expand Down Expand Up @@ -397,41 +398,41 @@ d('Settings', () => {
url: `${electrumHost}:${electrumPort}:t`,
expectedHost: electrumHost,
expectedPort: electrumPort.toString(),
expectedProtocol: 'tcp',
expectedProtocol: EProtocol.tcp,
};
const umbrel2 = {
url: `${electrumHost}:${electrumPort}:s`,
expectedHost: electrumHost,
expectedPort: electrumPort.toString(),
expectedProtocol: 'ssl',
expectedProtocol: EProtocol.ssl,
};

// should detect protocol for common ports
const noProto1 = {
url: `${electrumHost}:50001`,
expectedHost: electrumHost,
expectedPort: '50001',
expectedProtocol: 'tcp',
expectedProtocol: EProtocol.tcp,
};
const noProto2 = {
url: `${electrumHost}:50002`,
expectedHost: electrumHost,
expectedPort: '50002',
expectedProtocol: 'ssl',
expectedProtocol: EProtocol.ssl,
};

// HTTP URL
const http1 = {
url: `http://${electrumHost}:${electrumPort}`,
expectedHost: electrumHost,
expectedPort: electrumPort.toString(),
expectedProtocol: 'tcp',
expectedProtocol: EProtocol.tcp,
};
const http2 = {
url: `https://${electrumHost}:${electrumPort}`,
expectedHost: electrumHost,
expectedPort: electrumPort.toString(),
expectedProtocol: 'ssl',
expectedProtocol: EProtocol.ssl,
};

const conns = [umbrel1, umbrel2, noProto1, noProto2, http1, http2];
Expand Down
20 changes: 10 additions & 10 deletions ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,10 @@ PODS:
- lottie-react-native (5.1.6):
- lottie-ios (~> 3.4.0)
- React-Core
- MMKV (1.3.1):
- MMKVCore (~> 1.3.1)
- MMKVCore (1.3.1)
- nodejs-mobile-react-native (0.8.1):
- MMKV (1.3.2):
- MMKVCore (~> 1.3.2)
- MMKVCore (1.3.2)
- nodejs-mobile-react-native (18.17.4):
- React-Core
- OpenSSL-Universal (1.1.1100)
- RCT-Folly (2021.07.22.00):
Expand Down Expand Up @@ -392,7 +392,7 @@ PODS:
- React-Core
- react-native-keep-awake (1.2.2):
- React-Core
- react-native-ldk (0.0.120):
- react-native-ldk (0.0.121):
- React
- react-native-mmkv (2.10.2):
- MMKV (>= 1.2.13)
Expand Down Expand Up @@ -891,9 +891,9 @@ SPEC CHECKSUMS:
libevent: 4049cae6c81cdb3654a443be001fb9bdceff7913
lottie-ios: 8f97d3271e155c2d688875c29cd3c74908aef5f8
lottie-react-native: 8f9d4be452e23f6e5ca0fdc11669dc99ab52be81
MMKV: 5a07930c70c70b86cd87761a42c8f3836fb681d7
MMKVCore: e50135dbd33235b6ab390635991bab437ab873c0
nodejs-mobile-react-native: e35e7ed7ecfca168f168983e9557f1c5278d864b
MMKV: f21593c0af4b3f2a0ceb8f820f28bb639ea22bb7
MMKVCore: 31b4cb83f8266467eef20a35b6d78e409a11060d
nodejs-mobile-react-native: e69bf6e02f0b467b96c6ca960603ea01639e4cba
OpenSSL-Universal: ebc357f1e6bc71fa463ccb2fe676756aff50e88c
RCT-Folly: 424b8c9a7a0b9ab2886ffe9c3b041ef628fd4fb1
RCTRequired: c0569ecc035894e4a68baecb30fe6a7ea6e399f9
Expand All @@ -915,7 +915,7 @@ SPEC CHECKSUMS:
react-native-flipper: 9c1957af24b76493ba74f46d000a5c1d485e7731
react-native-image-picker: 2e2e82aba9b6a91a7c78f7d9afde341a2659c7b8
react-native-keep-awake: ad1d67f617756b139536977a0bf06b27cec0714a
react-native-ldk: fc83520c891e58888c8f975a02ed394a4c4e1c36
react-native-ldk: b94705aa18ce353138044e7602c51e866584ad67
react-native-mmkv: 9ae7ca3977e8ef48dbf7f066974eb844c20b5fd7
react-native-netinfo: 5ddbf20865bcffab6b43d0e4e1fd8b3896beb898
react-native-randombytes: 421f1c7d48c0af8dbcd471b0324393ebf8fe7846
Expand Down Expand Up @@ -966,4 +966,4 @@ SPEC CHECKSUMS:

PODFILE CHECKSUM: b01d3271ab99feb247ef10569ea8ace3cf7254ec

COCOAPODS: 1.12.1
COCOAPODS: 1.14.2
Loading