How to use the @arkecosystem/crypto.Identities.Address function in @arkecosystem/crypto

To help you get started, we’ve selected a few @arkecosystem/crypto examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github nos / client / src / renderer / shared / util / ARK / sendARK.js View on Github external
export default async function sendARK({ amount, receiver, wif, fee = 0 }) {
  if (!Identities.Address.validate(receiver)) {
    throw new Error(`Invalid script hash: "${receiver}"`);
  }
  if (amount <= 0) {
    throw new Error(`Invalid amount: "${amount}"`);
  }

  console.log('Amount ', amount);
  console.log('receiver ', receiver);
  console.log('wif ', wif);

  const send = async () => {
    try {
      // https://github.com/ArkEcosystem/core/blob/1cbc2a05a596340d4f261d162b8f426815908db6/packages/crypto/src/transactions/builders/transactions/transaction.ts
      const transaction = Transactions.BuilderFactory.transfer() // specify 'transfer' as our AIP11 transaction type
        .network(23)
        .version(2)
github ArkEcosystem / core / packages / core-tester-cli / src / commands / command.ts View on Github external
protected async sendTransaction(transactions: any[]): Promise> {
        if (!Array.isArray(transactions)) {
            transactions = [transactions];
        }

        for (const transaction of transactions) {
            let recipientId = transaction.recipientId;

            if (!recipientId) {
                recipientId = Identities.Address.fromPublicKey(transaction.senderPublicKey, this.network);
            }

            logger.info(
                `[T] ${transaction.id} (${recipientId} / ${this.fromSatoshi(transaction.amount)} / ${this.fromSatoshi(
                    transaction.fee,
                )})`,
            );
        }

        return this.api.post("transactions", { transactions });
    }
github ArkEcosystem / desktop-wallet / __tests__ / unit / services / transaction.spec.js View on Github external
beforeEach(() => {
      transactionObject = Transactions.BuilderFactory
        .transfer()
        .amount(1)
        .fee(1)
        .recipientId(recipientAddress)

      spyDispatch = jest.spyOn(vmMock.$store, 'dispatch')
      spyTranslate = jest.spyOn(vmMock, '$t')
      wallet = {
        address: Identities.Address.fromPassphrase(senderPassphrase),
        publicKey: senderPublicKey,
        ledgerIndex: 0
      }
    })
github ArkEcosystem / core / packages / core-state / src / wallets / wallet-manager.ts View on Github external
public applyBlock(block: Interfaces.IBlock): void {
        const generatorPublicKey: string = block.data.generatorPublicKey;

        let delegate: State.IWallet;
        if (!this.has(generatorPublicKey)) {
            const generator: string = Identities.Address.fromPublicKey(generatorPublicKey);

            if (block.data.height === 1) {
                delegate = new Wallet(generator);
                delegate.publicKey = generatorPublicKey;

                this.reindex(delegate);
            } else {
                app.forceExit(`Failed to lookup generator '${generatorPublicKey}' of block '${block.data.id}'.`);
            }
        } else {
            delegate = this.findByPublicKey(block.data.generatorPublicKey);
        }

        const appliedTransactions: Interfaces.ITransaction[] = [];

        try {
github ArkEcosystem / core / packages / core / src / commands / network / generate.ts View on Github external
private createWallet(pubKeyHash: number) {
        const passphrase = generateMnemonic();
        const keys = Identities.Keys.fromPassphrase(passphrase);

        return {
            address: Identities.Address.fromPublicKey(keys.publicKey, pubKeyHash),
            passphrase,
            keys,
            username: undefined,
        };
    }
github ArkEcosystem / desktop-wallet / src / renderer / components / Input / InputPublicKey.vue View on Github external
isValid (value) {
        if (!this.isRequired && value.replace(/\s+/, '') === '') {
          return true
        }

        try {
          Identities.Address.fromPublicKey(value)

          return true
        } catch (error) {
          //
        }

        return false
      }
    }
github ArkEcosystem / core / deprecated / core-json-rpc / src / server / modules.ts View on Github external
async method(params: { passphrase: string }) {
            const { publicKey }: Interfaces.IKeyPair = Identities.Keys.fromPassphrase(params.passphrase);

            return {
                publicKey,
                address: Identities.Address.fromPublicKey(publicKey),
            };
        },
        schema: {
github ArkEcosystem / core / packages / core-transaction-pool / src / pool-wallet-manager.ts View on Github external
public deleteWallet(publicKey) {
        this.forgetByPublicKey(publicKey);
        this.forgetByAddress(Identities.Address.fromPublicKey(publicKey));
    }
github wownmedia / cryptology_tbw / src / utils / crypto.ts View on Github external
public static getAddressFromPublicKey(
        publicKey: string,
        networkVersion: number
    ): string {
        return Identities.Address.fromPublicKey(publicKey, networkVersion);
    }
github ArkEcosystem / core / deprecated / core-json-rpc / src / server / modules.ts View on Github external
async method(params: { userId: string; bip38: string }) {
            const encryptedWIF: string = await database.get(
                Crypto.HashAlgorithms.sha256(Buffer.from(params.userId)).toString("hex"),
            );

            if (!encryptedWIF) {
                return Boom.notFound(`User ${params.userId} could not be found.`);
            }

            const { keys, wif }: IWallet = decryptWIF(encryptedWIF, params.userId, params.bip38);

            return {
                publicKey: keys.publicKey,
                address: Identities.Address.fromPublicKey(keys.publicKey),
                wif,
            };
        },
        schema: {