Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
isUnsubscribed: () => boolean,
derivationMode: DerivationMode,
showNewAccount: boolean,
}): Promise {
const isSegwit = isSegwitDerivationMode(derivationMode)
const unsplitFork = isUnsplitDerivationMode(derivationMode) ? currency.forkedFrom : null
const { coinType } = unsplitFork ? getCryptoCurrencyById(unsplitFork) : currency
const path = `${isSegwit ? '49' : '44'}'/${coinType}'`
const { publicKey: seedIdentifier } = await withDevice(devicePath)(transport =>
from(getAddress(transport, currency, path)),
).toPromise()
if (isUnsubscribed()) return []
const walletName = getWalletName({
seedIdentifier,
currency,
derivationMode,
})
// retrieve or create the wallet
const wallet = await getOrCreateWallet(core, walletName, { currency, derivationMode })
// recursively scan all accounts on device on the given app
// new accounts will be created in sqlite, existing ones will be updated
const accounts = await scanNextAccount({
core,
wallet,
walletName,
devicePath,
currency,
: null;
const { coinType } = unsplitFork
? getCryptoCurrencyById(unsplitFork)
: currency;
const path = `${isSegwit ? "49" : "44"}'/${coinType}'`;
const hwApp = new Btc(transport);
const { publicKey: seedIdentifier } = await hwApp.getWalletPublicKey(
path,
false,
isSegwit,
);
if (isUnsubscribed()) return;
const walletName = getWalletName({
seedIdentifier,
currency,
derivationMode,
});
const wallet = await getOrCreateWallet({
core,
walletName,
currency,
derivationMode,
});
const onAccountScanned = account => o.next(account);
// recursively scan all accounts on device on the given app
// new accounts will be created in sqlite, existing ones will be updated
export async function getFeesForTransaction({
account,
transaction,
}: {
account: Account,
transaction: *,
}): Promise {
try {
const { derivationMode, currency, xpub, index } = account;
const core = await load();
const walletName = getWalletName(account);
const coreWallet = await getOrCreateWallet({
core,
walletName,
currency,
derivationMode,
});
const coreAccount = await getOrCreateAccount({
core,
coreWallet,
index,
xpub,
});
const bitcoinLikeAccount = await core.coreAccount.asBitcoinLikeAccount(
async function getCoreObjects(core, account: Account) {
const walletName = getWalletName(account);
const { currency, derivationMode, index, xpub } = account;
const coreWallet = await getOrCreateWallet({
core,
walletName,
currency,
derivationMode,
});
const coreAccount = await getOrCreateAccount({
core,
coreWallet,
index,
xpub,
});
core => async ({
account,
transaction,
}: {
account: Account,
transaction: *,
}): Promise => {
try {
const { derivationMode, currency, xpub, index } = account;
const walletName = getWalletName(account);
const coreWallet = await getOrCreateWallet({
core,
walletName,
currency,
derivationMode,
});
const coreAccount = await getOrCreateAccount({
core,
coreWallet,
index,
xpub,
});
const bitcoinLikeAccount = await coreAccount.asBitcoinLikeAccount();
blockHeight: number,
currency: CryptoCurrency,
xpub: string,
index: number,
transaction: Transaction,
deviceId: string,
isCancelled: () => boolean,
onSigning: () => void,
onSigned: () => void,
onOperationBroadcasted: (optimisticOp: Operation) => void,
}): Promise => {
const { feePerByte } = transaction;
if (!feePerByte) throw FeeNotLoaded();
if (isCancelled()) return;
const walletName = getWalletName({
currency,
seedIdentifier,
derivationMode,
});
const coreWallet = await getOrCreateWallet({
core,
walletName,
currency,
derivationMode,
});
if (isCancelled()) return;
const coreAccount = await coreWallet.getAccount(index);
if (isCancelled()) return;
const bitcoinLikeAccount = await coreAccount.asBitcoinLikeAccount();
if (isCancelled()) return;
export async function scanAccountsFromXPUB({
core,
currencyId,
xpub,
derivationMode,
seedIdentifier,
}: {
core: *,
currencyId: string,
xpub: string,
derivationMode: DerivationMode,
seedIdentifier: string,
}) {
const currency = getCryptoCurrencyById(currencyId)
const walletName = getWalletName({
currency,
seedIdentifier,
derivationMode,
})
const wallet = await getOrCreateWallet(core, walletName, { currency, derivationMode })
const index = 0
const isSegwit = isSegwitDerivationMode(derivationMode)
const extendedInfos = {
index,
owners: ['main'],
derivations: [
`${isSegwit ? '49' : '44'}'/${currency.coinType}'`,
export async function syncAccount({ account }: { account: Account }) {
const { derivationMode, currency, xpub, index, seedIdentifier } = account;
const core = await load();
const walletName = getWalletName(account);
const coreWallet = await getOrCreateWallet({
core,
walletName,
currency,
derivationMode,
});
const coreAccount = await getOrCreateAccount({
core,
coreWallet,
index,
xpub,
});
const updatedAccount = await syncCoreAccount({