s/nano_/dn_/

This commit is contained in:
Minecon724 2025-10-16 18:38:14 +02:00
commit 0806dc7fda
Signed by untrusted user who does not match committer: m724
GPG key ID: A02E6E67AB961189
9 changed files with 1178 additions and 490 deletions

8
.idea/.gitignore generated vendored Normal file
View file

@ -0,0 +1,8 @@
# Default ignored files
/shelf/
/workspace.xml
# Editor-based HTTP Client requests
/httpRequests/
# Datasource local storage ignored files
/dataSources/
/dataSources.local.xml

8
.idea/modules.xml generated Normal file
View file

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/nanocurrency-web-js.iml" filepath="$PROJECT_DIR$/.idea/nanocurrency-web-js.iml" />
</modules>
</component>
</project>

12
.idea/nanocurrency-web-js.iml generated Normal file
View file

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="WEB_MODULE" version="4">
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$">
<excludeFolder url="file://$MODULE_DIR$/.tmp" />
<excludeFolder url="file://$MODULE_DIR$/temp" />
<excludeFolder url="file://$MODULE_DIR$/tmp" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>

6
.idea/vcs.xml generated Normal file
View file

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="" vcs="Git" />
</component>
</project>

View file

@ -92,7 +92,7 @@ const accounts = wallet.legacyAccounts(seed, from, to)
accountIndex: 0,
privateKey: '3be4fc2ef3f3b7374e6fc4fb6e7bb153f8a2998b3b3dab50853eabe128024143',
publicKey: '5b65b0e8173ee0802c2c3e6c9080d1a16b06de1176c938a924f58670904e82c4',
address: 'nano_1pu7p5n3ghq1i1p4rhmek41f5add1uh34xpb94nkbxe8g4a6x1p69emk8y1d'
address: 'dn_1pu7p5n3ghq1i1p4rhmek41f5add1uh34xpb94nkbxe8g4a6x1p69emk8y1d'
}
]
}
@ -120,13 +120,13 @@ const data = {
walletBalanceRaw: '5618869000000000000000000000000',
// Your wallet address
fromAddress: 'nano_1e5aqegc1jb7qe964u4adzmcezyo6o146zb8hm6dft8tkp79za3sxwjym5rx',
fromAddress: 'dn_1e5aqegc1jb7qe964u4adzmcezyo6o146zb8hm6dft8tkp79za3sxwjym5rx',
// The address to send to
toAddress: 'nano_1q3hqecaw15cjt7thbtxu3pbzr1eihtzzpzxguoc37bj1wc5ffoh7w74gi6p',
toAddress: 'dn_1q3hqecaw15cjt7thbtxu3pbzr1eihtzzpzxguoc37bj1wc5ffoh7w74gi6p',
// From account info
representativeAddress: 'nano_1stofnrxuz3cai7ze75o174bpm7scwj9jn3nxsn8ntzg784jf1gzn1jjdkou',
representativeAddress: 'dn_1stofnrxuz3cai7ze75o174bpm7scwj9jn3nxsn8ntzg784jf1gzn1jjdkou',
// Previous block, from account info
frontier: '92BA74A7D6DC7557F3EDA95ADC6341D51AC777A0A6FF0688A5C492AB2B2CB40D',
@ -153,10 +153,10 @@ const data = {
walletBalanceRaw: '18618869000000000000000000000000',
// Your address
toAddress: 'nano_3kyb49tqpt39ekc49kbej51ecsjqnimnzw1swxz4boix4ctm93w517umuiw8',
toAddress: 'dn_3kyb49tqpt39ekc49kbej51ecsjqnimnzw1swxz4boix4ctm93w517umuiw8',
// From account info
representativeAddress: 'nano_1stofnrxuz3cai7ze75o174bpm7scwj9jn3nxsn8ntzg784jf1gzn1jjdkou',
representativeAddress: 'dn_1stofnrxuz3cai7ze75o174bpm7scwj9jn3nxsn8ntzg784jf1gzn1jjdkou',
// From account info
frontier: '92BA74A7D6DC7557F3EDA95ADC6341D51AC777A0A6FF0688A5C492AB2B2CB40D',
@ -186,10 +186,10 @@ const data = {
walletBalanceRaw: '3000000000000000000000000000000',
// Your wallet address
address: 'nano_3igf8hd4sjshoibbbkeitmgkp1o6ug4xads43j6e4gqkj5xk5o83j8ja9php',
address: 'dn_3igf8hd4sjshoibbbkeitmgkp1o6ug4xads43j6e4gqkj5xk5o83j8ja9php',
// The new representative
representativeAddress: 'nano_1anrzcuwe64rwxzcco8dkhpyxpi8kd7zsjc1oeimpc3ppca4mrjtwnqposrs',
representativeAddress: 'dn_1anrzcuwe64rwxzcco8dkhpyxpi8kd7zsjc1oeimpc3ppca4mrjtwnqposrs',
// Previous block, from account info
frontier: '128106287002E595F479ACD615C818117FCB3860EC112670557A2467386249D4',
@ -243,7 +243,7 @@ You are able to challenge an user to prove ownership of a Nano address simply by
```javascript
import { tools } from 'nanocurrency-web'
const nanoAddress = 'nano_1pu7p5n3ghq1i1p4rhmek41f5add1uh34xpb94nkbxe8g4a6x1p69emk8y1d'
const nanoAddress = 'dn_1pu7p5n3ghq1i1p4rhmek41f5add1uh34xpb94nkbxe8g4a6x1p69emk8y1d'
const privateKey = '3be4fc2ef3f3b7374e6fc4fb6e7bb153f8a2998b3b3dab50853eabe128024143'
const data = 'sign this'
@ -264,7 +264,7 @@ You are able to validate Nano addresses and mnemonic words.
import { tools } from 'nanocurrency-web'
// Validate Nano address
const valid = tools.validateAddress('nano_1pu7p5n3ghq1i1p4rhmek41f5add1uh34xpb94nkbxe8g4a6x1p69emk8y1d')
const valid = tools.validateAddress('dn_1pu7p5n3ghq1i1p4rhmek41f5add1uh34xpb94nkbxe8g4a6x1p69emk8y1d')
// Validate mnemonic phrases
const valid = tools.validateMnemonic('edge defense waste choose enrich upon flee junk siren film clown finish luggage leader kid quick brick print evidence swap drill paddle truly occur')
@ -297,6 +297,6 @@ Fork the project, make your changes and request them to be merged with a pull re
If this helped you in your endeavours and you feel like supporting the developer, please donate some Nano:
`nano_1iic4ggaxy3eyg89xmswhj1r5j9uj66beka8qjcte11bs6uc3wdwr7i9hepm`
`dn_1iic4ggaxy3eyg89xmswhj1r5j9uj66beka8qjcte11bs6uc3wdwr7i9hepm`
If you prefer the old fashioned way, I also have a [GitHub Sponsors account](https://github.com/sponsors/numsu).

View file

@ -20,7 +20,7 @@ const wallet = {
* with input parameters 44'/165' and index 0.
*
* The Nano address is derived from the public key using standard Nano encoding.
* The address is prefixed with 'nano_'.
* The address is prefixed with 'dn_'.
*
* Generation uses CryptoJS to generate random entropy by default. You can give your own entropy
* as a parameter and it will be used instead.
@ -44,7 +44,7 @@ const wallet = {
* a mnemonic phrase and a seed, the account is derived from the seed at index 0.
*
* The Nano address is derived from the public key using standard Nano encoding.
* The address is prefixed with 'nano_'.
* The address is prefixed with 'dn_'.
*
* Generation uses CryptoJS to generate random seed by default. You can give your own seed
* as a parameter and it will be used instead.
@ -64,7 +64,7 @@ const wallet = {
* algorithm with input parameters 44'/165' and index 0.
*
* The Nano address is derived from the public key using standard Nano encoding.
* The address is prefixed with 'nano_'.
* The address is prefixed with 'dn_'.
*
* @param {string} mnemonic - The mnemonic phrase. Words are separated with a space
* @param {string} [seedPassword] - (Optional) seed password
@ -82,7 +82,7 @@ const wallet = {
* phrase, a seed which represents the mnemonic and an account derived from the seed at index 0.
*
* The Nano address is derived from the public key using standard Nano encoding.
* The address is prefixed with 'nano_'.
* The address is prefixed with 'dn_'.
*
* @param {string} mnemonic - The mnemonic phrase. Words are separated with a space
* @throws Throws an error if the mnemonic phrase doesn't pass validations
@ -100,7 +100,7 @@ const wallet = {
* parameters 44'/165' and index 0.
*
* The Nano address is derived from the public key using standard Nano encoding.
* The address is prefixed with 'nano_'.
* The address is prefixed with 'dn_'.
*
* @param {string} seed - The seed
* @returns {Wallet} The wallet, without the mnemonic phrase because it's not possible to infer backwards
@ -117,7 +117,7 @@ const wallet = {
* algorithm.
*
* The Nano address is derived from the public key using standard Nano encoding.
* The address is prefixed with 'nano_'.
* The address is prefixed with 'dn_'.
*
* @param {string} seed - The seed
* @returns {Wallet} The wallet
@ -228,7 +228,7 @@ const block = {
...data,
fromAddress: data.address,
amountRaw: '0',
toAddress: 'nano_1111111111111111111111111111111111111111111111111111hifc8npp', // Burn address
toAddress: 'dn_1111111111111111111111111111111111111111111111111111hifc8npp', // Burn address
}
return BlockSigner.send(block, privateKey)

View file

@ -6,7 +6,7 @@ import Convert from './util/convert'
export default class NanoAddress {
static readonly alphabet = '13456789abcdefghijkmnopqrstuwxyz'
static readonly prefix = 'nano_'
static readonly prefix = 'dn_'
static deriveAddress = (publicKey: string): string => {
const publicKeyBytes = Convert.hex2ab(publicKey)
@ -45,8 +45,9 @@ export default class NanoAddress {
static addressToPublicKey = (input: string): string => {
const cleaned = input
.replace('nano_', '')
.replace('nano_', '')
.replace('xrb_', '')
.replace('dn_', '')
const publicKeyBytes = NanoAddress.decodeNanoBase32(cleaned)
return Convert.ab2hex(publicKeyBytes).slice(0, 64)
}
@ -83,7 +84,7 @@ export default class NanoAddress {
}
/**
* Validates a Nano address with 'nano' and 'xrb' prefixes
* Validates a Nano address with 'nano', 'xrb' and 'dn' prefixes
*
* Derived from https://github.com/alecrios/nano-address-validator
*
@ -98,7 +99,7 @@ export default class NanoAddress {
throw TypeError('Address must be a string.')
}
const allowedPrefixes: string[] = ['nano', 'xrb']
const allowedPrefixes: string[] = ['nano', 'xrb', 'dn']
const pattern = new RegExp(
`^(${allowedPrefixes.join('|')})_[13]{1}[13456789abcdefghijkmnopqrstuwxyz]{59}$`,
)

1533
package-lock.json generated

File diff suppressed because it is too large Load diff

View file

@ -22,7 +22,7 @@ describe('generate wallet test', () => {
expect(result.seed).to.equal('1accdd4c25e06e47310d0c62c290ec166071d024352e003e5366e8ba6ba523f2a0cb34116ac55a238a886778880a9b2a547112fd7cffade81d8d8d084ccb7d36')
expect(result.accounts[0].privateKey).to.equal('eb18b748bcc48f824cf8a1fe92f7fc93bfc6f2a1eb9c1d40fa26d335d8a0c30f')
expect(result.accounts[0].publicKey).to.equal('a9ef7bbc004813cf75c5fc5c582066182d5c9cffd42eb7eb81cefea8e78c47c5')
expect(result.accounts[0].address).to.equal('nano_3chhhgy11k1msxtwdz4wd1i8e83fdkghzo3gpzor5mqyo5mrrjy79zpw1g34')
expect(result.accounts[0].address).to.equal('dn_3chhhgy11k1msxtwdz4wd1i8e83fdkghzo3gpzor5mqyo5mrrjy79zpw1g34')
})
it('should generate the correct wallet with the given test vector and a seed password', () => {
@ -37,12 +37,12 @@ describe('generate wallet test', () => {
expect(result.seed).to.not.equal('1accdd4c25e06e47310d0c62c290ec166071d024352e003e5366e8ba6ba523f2a0cb34116ac55a238a886778880a9b2a547112fd7cffade81d8d8d084ccb7d36')
expect(result.accounts[0].privateKey).to.not.equal('eb18b748bcc48f824cf8a1fe92f7fc93bfc6f2a1eb9c1d40fa26d335d8a0c30f')
expect(result.accounts[0].publicKey).to.not.equal('a9ef7bbc004813cf75c5fc5c582066182d5c9cffd42eb7eb81cefea8e78c47c5')
expect(result.accounts[0].address).to.not.equal('nano_3chhhgy11k1msxtwdz4wd1i8e83fdkghzo3gpzor5mqyo5mrrjy79zpw1g34')
expect(result.accounts[0].address).to.not.equal('dn_3chhhgy11k1msxtwdz4wd1i8e83fdkghzo3gpzor5mqyo5mrrjy79zpw1g34')
expect(result.seed).to.equal('146e3e2a0530848c9174d45ecec8c3f74a7be3f1ee832f92eb6227284121eb2e48a6b8fc469403984cd5e8f0d1ed05777c78f458d0e98c911841590e5d645dc3')
expect(result.accounts[0].privateKey).to.equal('2d5851bd5a89b8c943078be6ad5bbee8aeab77d6a4744c20d1b87d78e3286b93')
expect(result.accounts[0].publicKey).to.equal('923b6c7e281c1c5529fd2dc848117781216a1753cfd487fc34009f3591e636d7')
expect(result.accounts[0].address).to.equal('nano_36jufjz4i91wcnnztdgab1aqh1b3fado9mynizy5a16z8payefpqo81zsshc')
expect(result.accounts[0].address).to.equal('dn_36jufjz4i91wcnnztdgab1aqh1b3fado9mynizy5a16z8payefpqo81zsshc')
})
it('should throw when given an entropy with an invalid length', () => {
@ -70,7 +70,7 @@ describe('import wallet with test vectors test', () => {
expect(result.seed).to.equal('0dc285fde768f7ff29b66ce7252d56ed92fe003b605907f7a4f683c3dc8586d34a914d3c71fc099bb38ee4a59e5b081a3497b7a323e90cc68f67b5837690310c')
expect(result.accounts[0].privateKey).to.equal('3be4fc2ef3f3b7374e6fc4fb6e7bb153f8a2998b3b3dab50853eabe128024143')
expect(result.accounts[0].publicKey).to.equal('5b65b0e8173ee0802c2c3e6c9080d1a16b06de1176c938a924f58670904e82c4')
expect(result.accounts[0].address).to.equal('nano_1pu7p5n3ghq1i1p4rhmek41f5add1uh34xpb94nkbxe8g4a6x1p69emk8y1d')
expect(result.accounts[0].address).to.equal('dn_1pu7p5n3ghq1i1p4rhmek41f5add1uh34xpb94nkbxe8g4a6x1p69emk8y1d')
})
it('should successfully import a wallet with the checksum starting with a zero', () => {
@ -86,7 +86,7 @@ describe('import wallet with test vectors test', () => {
expect(result.seed).to.equal('0dc285fde768f7ff29b66ce7252d56ed92fe003b605907f7a4f683c3dc8586d34a914d3c71fc099bb38ee4a59e5b081a3497b7a323e90cc68f67b5837690310c')
expect(result.accounts[0].privateKey).to.equal('3be4fc2ef3f3b7374e6fc4fb6e7bb153f8a2998b3b3dab50853eabe128024143')
expect(result.accounts[0].publicKey).to.equal('5b65b0e8173ee0802c2c3e6c9080d1a16b06de1176c938a924f58670904e82c4')
expect(result.accounts[0].address).to.equal('nano_1pu7p5n3ghq1i1p4rhmek41f5add1uh34xpb94nkbxe8g4a6x1p69emk8y1d')
expect(result.accounts[0].address).to.equal('dn_1pu7p5n3ghq1i1p4rhmek41f5add1uh34xpb94nkbxe8g4a6x1p69emk8y1d')
})
it('should successfully import a legacy hex wallet with the a seed', () => {
@ -98,7 +98,7 @@ describe('import wallet with test vectors test', () => {
expect(result.seed).to.equal('0000000000000000000000000000000000000000000000000000000000000000')
expect(result.accounts[0].privateKey).to.equal('9f0e444c69f77a49bd0be89db92c38fe713e0963165cca12faf5712d7657120f')
expect(result.accounts[0].publicKey).to.equal('c008b814a7d269a1fa3c6528b19201a24d797912db9996ff02a1ff356e45552b')
expect(result.accounts[0].address).to.equal('nano_3i1aq1cchnmbn9x5rsbap8b15akfh7wj7pwskuzi7ahz8oq6cobd99d4r3b7')
expect(result.accounts[0].address).to.equal('dn_3i1aq1cchnmbn9x5rsbap8b15akfh7wj7pwskuzi7ahz8oq6cobd99d4r3b7')
})
it('should successfully import legacy hex accounts with the a seed', () => {
@ -111,7 +111,7 @@ describe('import wallet with test vectors test', () => {
expect(accounts[2].accountIndex).to.equal(2)
expect(accounts[2].privateKey).to.equal('6a1804198020b080996ba45b5891f8227d7a4f41c8479824423780d234939d58')
expect(accounts[2].publicKey).to.equal('2fea520fe54f5d0dca79d553d9c7f5af7db6ac17586dbca6905794caadc639df')
expect(accounts[2].address).to.equal('nano_1dzcca9ycmtx3q79mocmu95zdduxptp3gp5fqkmb1ownscpweggzah8cb4rb')
expect(accounts[2].address).to.equal('dn_1dzcca9ycmtx3q79mocmu95zdduxptp3gp5fqkmb1ownscpweggzah8cb4rb')
})
it('should throw when given a seed with an invalid length', () => {
@ -147,10 +147,10 @@ describe('derive more accounts from the same seed test', () => {
expect(result.length).to.equal(15)
expect(result[0].privateKey).to.equal('3be4fc2ef3f3b7374e6fc4fb6e7bb153f8a2998b3b3dab50853eabe128024143')
expect(result[0].publicKey).to.equal('5b65b0e8173ee0802c2c3e6c9080d1a16b06de1176c938a924f58670904e82c4')
expect(result[0].address).to.equal('nano_1pu7p5n3ghq1i1p4rhmek41f5add1uh34xpb94nkbxe8g4a6x1p69emk8y1d')
expect(result[0].address).to.equal('dn_1pu7p5n3ghq1i1p4rhmek41f5add1uh34xpb94nkbxe8g4a6x1p69emk8y1d')
expect(result[14].privateKey).to.equal('5f12e37c64daf2501c6a6a20614fd8d977fed65b5b5f0b045ec997f2ed2f53ca')
expect(result[14].publicKey).to.equal('f93a61018e07825a095e8cf7bdce9242e9c12c5c41a55de597a2be93fa41306b')
expect(result[14].address).to.equal('nano_3ybte61rw3w4da6ox59qqq9b6iqbr6p7rif7dqkshaoykhx64e5dbp4o1ua1')
expect(result[14].address).to.equal('dn_3ybte61rw3w4da6ox59qqq9b6iqbr6p7rif7dqkshaoykhx64e5dbp4o1ua1')
const result2 = wallet.accounts(
'0dc285fde768f7ff29b66ce7252d56ed92fe003b605907f7a4f683c3dc8586d34a914d3c71fc099bb38ee4a59e5b081a3497b7a323e90cc68f67b5837690310c',
@ -168,8 +168,8 @@ describe('block signing tests using official test vectors', () => {
const result = block.receive({
walletBalanceRaw: '18618869000000000000000000000000',
transactionHash: 'CBC911F57B6827649423C92C88C0C56637A4274FF019E77E24D61D12B5338783',
toAddress: 'nano_1e5aqegc1jb7qe964u4adzmcezyo6o146zb8hm6dft8tkp79za3sxwjym5rx',
representativeAddress: 'nano_1stofnrxuz3cai7ze75o174bpm7scwj9jn3nxsn8ntzg784jf1gzn1jjdkou',
toAddress: 'dn_1e5aqegc1jb7qe964u4adzmcezyo6o146zb8hm6dft8tkp79za3sxwjym5rx',
representativeAddress: 'dn_1stofnrxuz3cai7ze75o174bpm7scwj9jn3nxsn8ntzg784jf1gzn1jjdkou',
frontier: '92BA74A7D6DC7557F3EDA95ADC6341D51AC777A0A6FF0688A5C492AB2B2CB40D',
amountRaw: '7000000000000000000000000000000',
work,
@ -182,8 +182,8 @@ describe('block signing tests using official test vectors', () => {
const result = block.receive({
walletBalanceRaw: '18618869000000000000000000000000',
transactionHash: 'CBC911F57B6827649423C92C88C0C56637A4274FF019E77E24D61D12B5338783',
toAddress: 'nano_1e5aqegc1jb7qe964u4adzmcezyo6o146zb8hm6dft8tkp79za3sxwjym5rx',
representativeAddress: 'nano_1stofnrxuz3cai7ze75o174bpm7scwj9jn3nxsn8ntzg784jf1gzn1jjdkou',
toAddress: 'dn_1e5aqegc1jb7qe964u4adzmcezyo6o146zb8hm6dft8tkp79za3sxwjym5rx',
representativeAddress: 'dn_1stofnrxuz3cai7ze75o174bpm7scwj9jn3nxsn8ntzg784jf1gzn1jjdkou',
frontier: '92BA74A7D6DC7557F3EDA95ADC6341D51AC777A0A6FF0688A5C492AB2B2CB40D',
amountRaw: '7000000000000000000000000000000',
}, '781186FB9EF17DB6E3D1056550D9FAE5D5BBADA6A6BC370E4CBB938B1DC71DA3')
@ -195,9 +195,9 @@ describe('block signing tests using official test vectors', () => {
const work = 'fbffed7c73b61367'
const result = block.send({
walletBalanceRaw: '5618869000000000000000000000000',
fromAddress: 'nano_1e5aqegc1jb7qe964u4adzmcezyo6o146zb8hm6dft8tkp79za3sxwjym5rx',
toAddress: 'nano_1q3hqecaw15cjt7thbtxu3pbzr1eihtzzpzxguoc37bj1wc5ffoh7w74gi6p',
representativeAddress: 'nano_1stofnrxuz3cai7ze75o174bpm7scwj9jn3nxsn8ntzg784jf1gzn1jjdkou',
fromAddress: 'dn_1e5aqegc1jb7qe964u4adzmcezyo6o146zb8hm6dft8tkp79za3sxwjym5rx',
toAddress: 'dn_1q3hqecaw15cjt7thbtxu3pbzr1eihtzzpzxguoc37bj1wc5ffoh7w74gi6p',
representativeAddress: 'dn_1stofnrxuz3cai7ze75o174bpm7scwj9jn3nxsn8ntzg784jf1gzn1jjdkou',
frontier: '92BA74A7D6DC7557F3EDA95ADC6341D51AC777A0A6FF0688A5C492AB2B2CB40D',
amountRaw: '2000000000000000000000000000000',
work,
@ -209,9 +209,9 @@ describe('block signing tests using official test vectors', () => {
it('should create a valid signature for a send block without work', () => {
const result = block.send({
walletBalanceRaw: '5618869000000000000000000000000',
fromAddress: 'nano_1e5aqegc1jb7qe964u4adzmcezyo6o146zb8hm6dft8tkp79za3sxwjym5rx',
toAddress: 'nano_1q3hqecaw15cjt7thbtxu3pbzr1eihtzzpzxguoc37bj1wc5ffoh7w74gi6p',
representativeAddress: 'nano_1stofnrxuz3cai7ze75o174bpm7scwj9jn3nxsn8ntzg784jf1gzn1jjdkou',
fromAddress: 'dn_1e5aqegc1jb7qe964u4adzmcezyo6o146zb8hm6dft8tkp79za3sxwjym5rx',
toAddress: 'dn_1q3hqecaw15cjt7thbtxu3pbzr1eihtzzpzxguoc37bj1wc5ffoh7w74gi6p',
representativeAddress: 'dn_1stofnrxuz3cai7ze75o174bpm7scwj9jn3nxsn8ntzg784jf1gzn1jjdkou',
frontier: '92BA74A7D6DC7557F3EDA95ADC6341D51AC777A0A6FF0688A5C492AB2B2CB40D',
amountRaw: '2000000000000000000000000000000',
}, '781186FB9EF17DB6E3D1056550D9FAE5D5BBADA6A6BC370E4CBB938B1DC71DA3')
@ -223,8 +223,8 @@ describe('block signing tests using official test vectors', () => {
const work = '0000000000000000'
const result = block.representative({
walletBalanceRaw: '3000000000000000000000000000000',
address: 'nano_3igf8hd4sjshoibbbkeitmgkp1o6ug4xads43j6e4gqkj5xk5o83j8ja9php',
representativeAddress: 'nano_1anrzcuwe64rwxzcco8dkhpyxpi8kd7zsjc1oeimpc3ppca4mrjtwnqposrs',
address: 'dn_3igf8hd4sjshoibbbkeitmgkp1o6ug4xads43j6e4gqkj5xk5o83j8ja9php',
representativeAddress: 'dn_1anrzcuwe64rwxzcco8dkhpyxpi8kd7zsjc1oeimpc3ppca4mrjtwnqposrs',
frontier: '128106287002E595F479ACD615C818117FCB3860EC112670557A2467386249D4',
work,
}, '781186FB9EF17DB6E3D1056550D9FAE5D5BBADA6A6BC370E4CBB938B1DC71DA3') // Did not find a private key at nano docs for this address
@ -235,8 +235,8 @@ describe('block signing tests using official test vectors', () => {
it('should create a valid signature for a change rep block without work', () => {
const result = block.representative({
walletBalanceRaw: '3000000000000000000000000000000',
address: 'nano_3igf8hd4sjshoibbbkeitmgkp1o6ug4xads43j6e4gqkj5xk5o83j8ja9php',
representativeAddress: 'nano_1anrzcuwe64rwxzcco8dkhpyxpi8kd7zsjc1oeimpc3ppca4mrjtwnqposrs',
address: 'dn_3igf8hd4sjshoibbbkeitmgkp1o6ug4xads43j6e4gqkj5xk5o83j8ja9php',
representativeAddress: 'dn_1anrzcuwe64rwxzcco8dkhpyxpi8kd7zsjc1oeimpc3ppca4mrjtwnqposrs',
frontier: '128106287002E595F479ACD615C818117FCB3860EC112670557A2467386249D4',
}, '781186FB9EF17DB6E3D1056550D9FAE5D5BBADA6A6BC370E4CBB938B1DC71DA3') // Did not find a private key at nano docs for this address
expect(result.signature.toUpperCase()).to.equal('A3C3C66D6519CBC0A198E56855942DEACC6EF741021A1B11279269ADC587DE1DA53CD478B8A47553231104CF24D742E1BB852B0546B87038C19BAE20F9082B0D')
@ -293,8 +293,8 @@ describe('Signer tests', () => {
const sendBlock = block.send({
walletBalanceRaw: '5618869000000000000000000000000',
fromAddress: this.testWallet.accounts[0].address,
toAddress: 'nano_1q3hqecaw15cjt7thbtxu3pbzr1eihtzzpzxguoc37bj1wc5ffoh7w74gi6p',
representativeAddress: 'nano_1stofnrxuz3cai7ze75o174bpm7scwj9jn3nxsn8ntzg784jf1gzn1jjdkou',
toAddress: 'dn_1q3hqecaw15cjt7thbtxu3pbzr1eihtzzpzxguoc37bj1wc5ffoh7w74gi6p',
representativeAddress: 'dn_1stofnrxuz3cai7ze75o174bpm7scwj9jn3nxsn8ntzg784jf1gzn1jjdkou',
frontier: '92BA74A7D6DC7557F3EDA95ADC6341D51AC777A0A6FF0688A5C492AB2B2CB40D',
amountRaw: '2000000000000000000000000000000',
}, this.testWallet.accounts[0].privateKey)
@ -304,19 +304,19 @@ describe('Signer tests', () => {
const valid = tools.verifyBlock(publicKey, sendBlock)
expect(valid).to.be.true
sendBlock.account = 'nano_1q3hqecaw15cjt7thbtxu3pbzr1eihtzzpzxguoc37bj1wc5ffoh7w74gi6p'
sendBlock.account = 'dn_1q3hqecaw15cjt7thbtxu3pbzr1eihtzzpzxguoc37bj1wc5ffoh7w74gi6p'
const valid2 = tools.verifyBlock(this.testWallet.accounts[0].publicKey, sendBlock)
expect(valid2).to.be.false
})
it('should convert a Nano address to public key', () => {
const publicKey = tools.addressToPublicKey('nano_1pu7p5n3ghq1i1p4rhmek41f5add1uh34xpb94nkbxe8g4a6x1p69emk8y1d')
const publicKey = tools.addressToPublicKey('dn_1pu7p5n3ghq1i1p4rhmek41f5add1uh34xpb94nkbxe8g4a6x1p69emk8y1d')
expect(publicKey).to.equal('5b65b0e8173ee0802c2c3e6c9080d1a16b06de1176c938a924f58670904e82c4')
})
it('should convert a public key to a Nano address', () => {
const address = tools.publicKeyToAddress('5b65b0e8173ee0802c2c3e6c9080d1a16b06de1176c938a924f58670904e82c4')
expect(address).to.equal('nano_1pu7p5n3ghq1i1p4rhmek41f5add1uh34xpb94nkbxe8g4a6x1p69emk8y1d')
expect(address).to.equal('dn_1pu7p5n3ghq1i1p4rhmek41f5add1uh34xpb94nkbxe8g4a6x1p69emk8y1d')
})
it('should create a blake2b hash', () => {