Amend Primitives/Tooling
This commit is contained in:
@@ -4,7 +4,8 @@ import {
|
||||
Bytes,
|
||||
encodeExtendedJson,
|
||||
decodeExtendedJson,
|
||||
Hasher,
|
||||
// Encrypter,
|
||||
// Hasher,
|
||||
HDPrivateNode,
|
||||
HDPublicNode,
|
||||
Mnemonic,
|
||||
@@ -116,10 +117,10 @@ export const address = {
|
||||
export const blockHeader = {
|
||||
from: [
|
||||
{
|
||||
label: 'From Hex',
|
||||
inputs: ['UTF-8'],
|
||||
label: 'From',
|
||||
inputs: ['Hex'],
|
||||
models: [''],
|
||||
callback: (args: [string]) => BlockHeader.fromHex(...args),
|
||||
callback: (args: [string]) => BlockHeader.from(...args),
|
||||
},
|
||||
],
|
||||
to: [
|
||||
@@ -193,67 +194,30 @@ export const bytes = {
|
||||
],
|
||||
};
|
||||
|
||||
export const hasher = {
|
||||
from: [
|
||||
{
|
||||
label: 'From Hex',
|
||||
inputs: ['Hex'],
|
||||
models: [''],
|
||||
callback: (args: [string]) => Hasher.fromHex(...args),
|
||||
},
|
||||
{
|
||||
label: 'From Base64',
|
||||
inputs: ['Base64'],
|
||||
models: [''],
|
||||
callback: (args: [string]) => Hasher.fromBase64(...args),
|
||||
},
|
||||
{
|
||||
label: 'From UTF-8',
|
||||
inputs: ['UTF-8'],
|
||||
models: [''],
|
||||
callback: (args: [string]) => Hasher.fromUTF8(...args),
|
||||
},
|
||||
],
|
||||
to: [
|
||||
{
|
||||
label: 'To Sha256 Hex',
|
||||
callback: (hasher: Hasher) => hasher.toSHA256Hex(),
|
||||
},
|
||||
{
|
||||
label: 'To RipeMD160 Hex',
|
||||
callback: (hasher: Hasher) => hasher.toRIPEMD160Hex(),
|
||||
},
|
||||
{
|
||||
label: 'To Hash160 Hex',
|
||||
callback: (hasher: Hasher) => hasher.toHash160Hex(),
|
||||
},
|
||||
{
|
||||
label: 'To Hash256 Hex',
|
||||
callback: (hasher: Hasher) => hasher.toHash256Hex(),
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
export const hdPrivateNode = {
|
||||
from: [
|
||||
{
|
||||
label: 'Generate Random',
|
||||
inputs: ['Derivation Path'],
|
||||
models: ["m/44'/145'/0'/0/1"],
|
||||
callback: () => HDPrivateNode.generateRandom(),
|
||||
},
|
||||
{
|
||||
label: 'From Mnemonic',
|
||||
inputs: ['Mnemonic', 'Derivation Path'],
|
||||
models: ['', "m/44'/145'/0'/0/1"],
|
||||
label: 'From Mnemonic Phrase',
|
||||
inputs: ['Mnemonic'],
|
||||
models: [''],
|
||||
callback: (args: [string]) => HDPrivateNode.fromMnemonic(...args),
|
||||
},
|
||||
{
|
||||
label: 'From XPriv Key',
|
||||
inputs: ['XPriv Key', 'Derivation Path'],
|
||||
models: ['', "m/44'/145'/0'/0/1"],
|
||||
inputs: ['XPriv Key'],
|
||||
models: [''],
|
||||
callback: (args: [string]) => HDPrivateNode.fromXPriv(...args),
|
||||
},
|
||||
{
|
||||
label: 'From Seed',
|
||||
inputs: ['Seed (Hex)'],
|
||||
models: [''],
|
||||
callback: (args: [string]) => HDPrivateNode.fromSeed(...args),
|
||||
},
|
||||
{
|
||||
label: 'From Raw',
|
||||
inputs: ['Raw (LibAuth Format/ExtJSON Encoded)'],
|
||||
@@ -283,6 +247,18 @@ export const hdPrivateNode = {
|
||||
hdPrivateNode.deriveHDPublicNode().toXPub(),
|
||||
},
|
||||
],
|
||||
methods: [
|
||||
{
|
||||
label: 'Derive Path',
|
||||
inputs: ['BIP32 Path'],
|
||||
models: ["m/44'/145'/0'/0/0"],
|
||||
callback: (hdPrivateNode: HDPrivateNode, args: [string]) =>
|
||||
hdPrivateNode
|
||||
.derivePath(...args)
|
||||
.toPrivateKey()
|
||||
.toWif(),
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
export const hdPublicNode = {
|
||||
@@ -317,30 +293,50 @@ export const hdPublicNode = {
|
||||
encodeExtendedJson(hdPublicNode.toRaw(), 2),
|
||||
},
|
||||
],
|
||||
methods: [
|
||||
{
|
||||
label: 'Derive Path',
|
||||
inputs: ['BIP32 Public Key Path'],
|
||||
models: ['M/0/0'],
|
||||
callback: (hdPublicNode: HDPublicNode, args: [string]) =>
|
||||
hdPublicNode
|
||||
.derivePath(...args)
|
||||
.toPublicKey()
|
||||
.deriveAddress()
|
||||
.toCashAddr(),
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
export const mnemonic = {
|
||||
from: [
|
||||
{
|
||||
label: 'Generate Random',
|
||||
callback: () => Mnemonic.generateRandom(),
|
||||
inputs: ['Passphrase (Optional)'],
|
||||
models: [undefined],
|
||||
callback: (args: [string?]) => Mnemonic.generateRandom(...args),
|
||||
},
|
||||
{
|
||||
label: 'From String',
|
||||
inputs: ['String'],
|
||||
label: 'From Phrase',
|
||||
inputs: ['Mnemonic Phrase'],
|
||||
models: [''],
|
||||
callback: (args: [string]) => Mnemonic.fromString(...args),
|
||||
callback: (args: [string]) => Mnemonic.fromPhrase(...args),
|
||||
extendedInput: true,
|
||||
},
|
||||
],
|
||||
to: [
|
||||
{
|
||||
label: 'To String (without passphrase)',
|
||||
callback: (mnemonic: Mnemonic) => mnemonic.toString(false),
|
||||
label: 'To Seed',
|
||||
callback: (mnemonic: Mnemonic) =>
|
||||
Bytes.fromBytes(mnemonic.toSeed()).toHex(),
|
||||
},
|
||||
{
|
||||
label: 'To String (with passphrase)',
|
||||
callback: (mnemonic: Mnemonic) => mnemonic.toString(true),
|
||||
label: 'To Phrase (without passphrase)',
|
||||
callback: (mnemonic: Mnemonic) => mnemonic.toPhrase(false),
|
||||
},
|
||||
{
|
||||
label: 'To Phrase (with passphrase)',
|
||||
callback: (mnemonic: Mnemonic) => mnemonic.toPhrase(true),
|
||||
},
|
||||
{
|
||||
label: 'Words',
|
||||
@@ -361,16 +357,10 @@ export const privateKey = {
|
||||
callback: () => PrivateKey.generateRandom(),
|
||||
},
|
||||
{
|
||||
label: 'From Hex',
|
||||
inputs: ['Hex'],
|
||||
label: 'From Hex or WIF',
|
||||
inputs: ['Hex or WIF'],
|
||||
models: [''],
|
||||
callback: (args: [string]) => PrivateKey.fromHex(...args),
|
||||
},
|
||||
{
|
||||
label: 'From WIF',
|
||||
inputs: ['WIF'],
|
||||
models: [''],
|
||||
callback: (args: [string]) => PrivateKey.fromWIF(...args),
|
||||
callback: (args: [string]) => PrivateKey.from(...args),
|
||||
},
|
||||
],
|
||||
to: [
|
||||
|
||||
Reference in New Issue
Block a user