-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1234 from openkfw/blockchain-wallet-import
Add blockchain wallet import endpoint
- Loading branch information
Showing
15 changed files
with
219 additions
and
1,683 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
const util = require("util"); | ||
const exec = util.promisify(require("child_process").exec); | ||
const log = require("./../log/logger"); | ||
const shell = require("shelljs"); | ||
|
||
const importWallet = async (walletPath, chainName) => { | ||
console.log("importing params ..."); | ||
shell.mv( | ||
`${walletPath}/params.dat`, | ||
`/root/.multichain/${chainName}/params.dat`, | ||
); | ||
shell.mv( | ||
`${walletPath}/params.dat.bak`, | ||
`/root/.multichain/${chainName}/params.dat.bak`, | ||
); | ||
|
||
console.log("importing wallet..."); | ||
shell.mv(`${walletPath}/wallet`, `/root/.multichain/${chainName}/wallet`); | ||
shell.mv( | ||
`${walletPath}/wallet.dat`, | ||
`/root/.multichain/${chainName}/wallet.dat`, | ||
); | ||
}; | ||
|
||
const listAvailableWallets = async (chainName) => { | ||
const { stdout } = await exec(`multichain-cli ${chainName} getaddresses`); | ||
log.debug({ message: "Available wallets:", stdout }); | ||
|
||
return stdout; | ||
}; | ||
|
||
module.exports = { | ||
importWallet, | ||
listAvailableWallets, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.