UNPKG

@ledgerhq/coin-hedera

Version:
39 lines 1.63 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.receive = void 0; const errors_1 = require("@ledgerhq/errors"); const rxjs_1 = require("rxjs"); const derivation_1 = require("@ledgerhq/coin-framework/derivation"); /* this is due to libs/coin-modules/coin-hedera/src/hw-getAddress.ts r.address is actually the public key, to check if we're on another device we resort to this check instead we rely on seedIdentifier being the public key for Hedera accounts TODO: document where the seedIdentifier for hedera is set looks like it's set to the publickey in makeScanAccount here: libs/coin-framework/src/bridge/jsHelpers.ts */ const receive = (getAddress) => (account, { deviceId }) => new rxjs_1.Observable(o => { void (async function () { try { const r = await getAddress(deviceId, { derivationMode: account.derivationMode, currency: account.currency, path: account.freshAddressPath, segwit: (0, derivation_1.isSegwitDerivationMode)(account.derivationMode), }); if (r.publicKey !== account.seedIdentifier) { throw new errors_1.WrongDeviceForAccount(); } o.next({ address: account.freshAddress, path: account.freshAddressPath, publicKey: r.publicKey, }); o.complete(); } catch (err) { o.error(err); } })(); }); exports.receive = receive; exports.default = exports.receive; //# sourceMappingURL=receive.js.map