A Bitcoin Address Generator for React Native Projects.
npm install react-native-address-generatorimport { getAddress, getScriptHash, getPrivateKey } from 'react-native-address-generator';
const mnemonic =
'lazy rally chat way pet outside flame cup oval absurd innocent balcony';
const passphrase = 'passphrase';
const path = "m/84'/1'/0'/0/0";
const network = 'testnet';
const getAddressRes = await getAddress({
mnemonic,
path,
network,
passphrase,
});
if (getAddressRes.isErr()) {
console.log(getAddressRes.error.message);
return;
}
console.log(getAddressRes.value);
const address = getAddressRes.value.address;
const getScriptHashRes = await getScriptHash({
address,
network,
});
if (getScriptHashRes.isErr()) {
console.log(getScriptHashRes.error.message);
return;
}
console.log(getScriptHashRes.value);
const getPrivateKeyRes = await getPrivateKey({
mnemonic,
path,
network,
passphrase,
});
if (getPrivateKeyRes.isErr()) {
console.log(getPrivateKeyRes.error.message);
return;
}
console.log(getPrivateKeyRes.value);After making changes to any of the Rust files, the bindings will need to be updated. To do this, run the following command:
npm run update-bindingsFinally, ensure that AddressGeneratorModule.kt, AddressGenerator.swift, AddressGenerator.mm & src/index.tsx are updated accordingly based on the changes made to the Rust files.
MIT