Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
T
tangled
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
eriksson monteiro
tangled
Commits
2f99be07
Commit
2f99be07
authored
Jan 17, 2022
by
Eriksson Monteiro
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update millix node: fix wallet auto-creation. increase ad payment frequence
parent
98c0209a
Changes
6
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
80 additions
and
34 deletions
+80
-34
millix_node/api/PMW9LXqUv7vXLpbA/index.js
millix_node/api/PMW9LXqUv7vXLpbA/index.js
+6
-3
millix_node/core/config/config.js
millix_node/core/config/config.js
+1
-1
millix_node/core/services/services.js
millix_node/core/services/services.js
+13
-5
millix_node/core/wallet/wallet.js
millix_node/core/wallet/wallet.js
+48
-20
millix_node/index.js
millix_node/index.js
+2
-2
millix_node/tangled-advertisement.js
millix_node/tangled-advertisement.js
+10
-3
No files found.
millix_node/api/PMW9LXqUv7vXLpbA/index.js
View file @
2f99be07
...
...
@@ -53,8 +53,8 @@ class _PMW9LXqUv7vXLpbA extends Endpoint {
res
.
send
({
api_status
:
'
success
'
,
wallet
:
{
id
:
walletID
,
address
:
`
${
keyIdentifier
}${
addressVersion
}${
keyIdentifier
}
`
,
id
:
walletID
,
address
:
`
${
keyIdentifier
}${
addressVersion
}${
keyIdentifier
}
`
,
address_key_identifier
:
keyIdentifier
}
});
...
...
@@ -63,7 +63,10 @@ class _PMW9LXqUv7vXLpbA extends Endpoint {
};
eventBus
.
once
(
'
wallet_unlock
'
,
authenticationSuccessHandler
);
services
.
stop
();
services
.
initialize
({
initialize_wallet_event
:
false
}).
catch
(
e
=>
{
services
.
initialize
({
initialize_wallet_event
:
false
,
auto_create_wallet
:
false
}).
catch
(
e
=>
{
eventBus
.
removeListener
(
'
wallet_authentication_error
'
,
authenticationErrorHandler
);
eventBus
.
removeListener
(
'
wallet_unlock
'
,
authenticationSuccessHandler
);
res
.
send
({
...
...
millix_node/core/config/config.js
View file @
2f99be07
...
...
@@ -772,7 +772,7 @@ export const DATABASE_ENGINE = 'sqlite';
export
const
DATABASE_CONNECTION
=
{};
export
const
MILLIX_CIRCULATION
=
9
e15
;
export
const
NODE_MILLIX_BUILD_DATE
=
1640009160
;
export
const
NODE_MILLIX_VERSION
=
'
1.13.
0
-tangled
'
;
export
const
NODE_MILLIX_VERSION
=
'
1.13.
1
-tangled
'
;
export
const
DATA_BASE_DIR_MAIN_NETWORK
=
'
./millix-tangled
'
;
export
const
DATA_BASE_DIR_TEST_NETWORK
=
'
./millix-tangled
'
;
let
DATA_BASE_DIR
=
MODE_TEST_NETWORK
?
DATA_BASE_DIR_TEST_NETWORK
:
DATA_BASE_DIR_MAIN_NETWORK
;
...
...
millix_node/core/services/services.js
View file @
2f99be07
...
...
@@ -17,10 +17,11 @@ class Service {
}
initialize
(
options
=
{})
{
const
{
mode
,
initialize_wallet_event
:
initializeWalletEvent
}
=
options
;
let
{
mode
,
initialize_wallet_event
:
initializeWalletEvent
,
auto_create_wallet
:
createWalletIfNotExists
}
=
options
;
if
(
this
.
initialized
)
{
return
Promise
.
resolve
();
}
...
...
@@ -28,9 +29,13 @@ class Service {
if
(
mode
)
{
this
.
mode
=
mode
;
}
if
(
createWalletIfNotExists
===
undefined
)
{
createWalletIfNotExists
=
true
;
}
return
logManager
.
initialize
()
.
then
(()
=>
server
.
initialize
())
.
then
(()
=>
wallet
.
setMode
(
this
.
mode
).
initialize
(
initializeWalletEvent
))
.
then
(()
=>
wallet
.
setMode
(
this
.
mode
).
initialize
(
initializeWalletEvent
,
createWalletIfNotExists
))
.
then
(()
=>
cache
.
initialize
())
.
then
(()
=>
network
.
initialize
())
.
then
(()
=>
peer
.
initialize
())
...
...
@@ -41,6 +46,9 @@ class Service {
.
catch
(
e
=>
{
console
.
log
(
`[services]
${
e
.
message
}
`
);
this
.
initialized
=
false
;
if
(
e
.
cause
===
'
wallet_not_found
'
)
{
return
;
}
return
this
.
initialize
(
options
);
});
}
...
...
millix_node/core/wallet/wallet.js
View file @
2f99be07
...
...
@@ -122,7 +122,7 @@ class Wallet {
return
mnemonic
.
phrase
;
}
getMnemonic
()
{
getMnemonic
(
createIfNotExits
)
{
return
new
Promise
((
resolve
)
=>
{
walletUtils
.
loadMnemonic
()
.
then
(([
passphrase
,
isNewMnemonic
])
=>
resolve
([
...
...
@@ -130,11 +130,19 @@ class Wallet {
isNewMnemonic
]))
.
catch
(()
=>
{
console
.
log
(
'
Creating new mnemonic
'
);
let
passphrase
=
this
.
createMnemonic
();
resolve
([
console
.
log
(
'
[wallet]
'
+
(
createIfNotExits
?
'
Creating new mnemonic
'
:
'
No wallet found in the system
'
));
let
passphrase
=
undefined
;
if
(
createIfNotExits
)
{
passphrase
=
this
.
createMnemonic
();
console
.
log
(
'
[wallet] creating a new mnemonic. please backup these 24 words to be able to recover you wallet.
'
);
console
.
log
(
'
[wallet] mnemonic phrase =>
'
,
passphrase
);
}
resolve
(
createIfNotExits
?
[
passphrase
,
true
]
:
[
undefined
,
false
]);
});
});
...
...
@@ -864,7 +872,7 @@ class Wallet {
delete
this
.
_transactionReceivedFromNetwork
[
transaction
.
transaction_id
];
delete
this
.
_transactionRequested
[
transaction
.
transaction_id
];
const
cachedValidation
=
cache
.
getCacheItem
(
'
validation
'
,
transaction
.
transaction_id
);
if
(
cachedValidation
&&
cachedValidation
.
cause
===
'
transaction_not_found
'
)
{
if
(
cachedValidation
&&
cachedValidation
.
cause
===
'
transaction_not_found
'
)
{
cache
.
removeCacheItem
(
'
validation
'
,
transaction
.
transaction_id
);
}
});
...
...
@@ -1716,26 +1724,43 @@ class Wallet {
});
}
initialize
(
initializeEventsOnly
)
{
initialize
(
initializeEventsOnly
,
createWalletIfNotExists
)
{
if
(
!
initializeEventsOnly
)
{
return
this
.
getMnemonic
()
.
then
(([
mnemonicPhrase
,
isNewMnemonic
])
=>
this
.
getWalletPrivateKey
(
mnemonicPhrase
,
isNewMnemonic
).
then
(
xPrivkey
=>
[
return
this
.
getMnemonic
(
createWalletIfNotExists
)
.
then
(([
mnemonicPhrase
,
isNewMnemonic
])
=>
{
if
(
mnemonicPhrase
===
undefined
)
{
// not wallet found
return
Promise
.
resolve
(
null
);
}
return
this
.
getWalletPrivateKey
(
mnemonicPhrase
,
isNewMnemonic
).
then
(
xPrivkey
=>
[
xPrivkey
,
isNewMnemonic
])
.
then
(([
xPrivkey
,
isNewMnemonic
])
=>
this
.
isCreateWallet
(
xPrivkey
,
isNewMnemonic
))
.
then
(([
xPrivkey
,
isCreated
])
=>
this
.
activateWalletByMasterKey
(
xPrivkey
,
isCreated
))
.
then
((
walletID
)
=>
{
if
(
isNewMnemonic
)
{
return
walletUtils
.
storeMnemonic
(
mnemonicPhrase
).
then
(()
=>
walletID
);
}
else
{
return
Promise
.
resolve
(
walletID
);
}
})
)
.
then
(([
xPrivkey
,
isNewMnemonic
])
=>
this
.
isCreateWallet
(
xPrivkey
,
isNewMnemonic
))
.
then
(([
xPrivkey
,
isCreated
])
=>
this
.
activateWalletByMasterKey
(
xPrivkey
,
isCreated
))
.
then
((
walletID
)
=>
{
if
(
isNewMnemonic
)
{
return
walletUtils
.
storeMnemonic
(
mnemonicPhrase
).
then
(()
=>
walletID
);
}
else
{
return
Promise
.
resolve
(
walletID
);
}
});
}
)
.
then
(
walletID
=>
{
if
(
!
walletID
)
{
// not wallet found
return
new
Promise
((
_
,
reject
)
=>
{
console
.
log
(
'
[wallet] waiting for a new wallet to be created...
'
);
const
error
=
{
cause
:
'
wallet_not_found
'
,
message
:
'
there is no wallet configured
'
};
eventBus
.
emit
(
'
wallet_authentication_error
'
,
error
);
reject
(
error
);
});
}
this
.
_initializeEvents
();
return
database
.
getRepository
(
'
keychain
'
).
getWalletDefaultKeyIdentifier
(
walletID
)
.
then
(
defaultKeyIdentifier
=>
{
...
...
@@ -1754,6 +1779,9 @@ class Wallet {
});
})
.
catch
((
err
)
=>
{
if
(
err
&&
err
.
cause
===
'
wallet_not_found
'
)
{
return
Promise
.
reject
(
err
);
}
throw
Error
(
`Could not initialize wallet
${
err
}
`
);
});
}
...
...
millix_node/index.js
View file @
2f99be07
...
...
@@ -106,7 +106,7 @@ eventBus.on('wallet_unlock', () => {
db
.
initialize
()
.
then
(()
=>
configLoader
.
cleanConfigsFromDatabase
())
.
then
(()
=>
configLoader
.
load
(
false
))
.
then
(()
=>
services
.
initialize
())
.
then
(()
=>
services
.
initialize
(
{
auto_create_wallet
:
false
}
))
.
then
(()
=>
{
logManager
.
logSize
=
1000
;
if
(
config
.
MODE_TEST
)
{
...
...
@@ -126,6 +126,6 @@ db.initialize()
});
}
});
//millix v1.13.
0
-tangled
//millix v1.13.
1
-tangled
\ No newline at end of file
millix_node/tangled-advertisement.js
View file @
2f99be07
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment