forked from woodser/monero-ts
-
Notifications
You must be signed in to change notification settings - Fork 10
/
Scratchpad.js
50 lines (43 loc) · 1.92 KB
/
Scratchpad.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
const TestUtils = require("./utils/TestUtils");
const WalletSyncPrinter = require("./utils/WalletSyncPrinter");
const monerojs = require("../../index");
describe("Scratchpad", function() {
it("Can be scripted easily", async function() {
// let daemon = await TestUtils.getDaemonRpc();
// let walletRpc = await TestUtils.getWalletRpc();
// let walletFull = await TestUtils.getWalletFull();
// initialize daemon rpc client
let daemon = monerojs.connectToDaemonRpc({
uri: "http://localhost:37750",
username: "super",
password: "super",
proxyToWorker: TestUtils.PROXY_TO_WORKER,
rejectUnauthorized: false
});
console.log("Daemon height: " + await daemon.getHeight());
// initialize wallet rpc client
let walletRpc = await monerojs.connectToWalletRpc({
uri: "http://localhost:28084",
username: "rpc_user",
password: "abc123",
rejectUnauthorized: false
});
await walletRpc.openWallet("test_wallet_1", "supersecretpassword123");
console.log("RPC wallet mnemonic: " + await walletRpc.getMnemonic());
// create in-memory wallet with mnemonic
let walletFull = await monerojs.createWalletFull({
//path: "./test_wallets/" + GenUtils.getUUID(), // in-memory wallet if not given
password: "abctesting123",
networkType: "testnet",
serverUri: "http://localhost:28081",
mnemonic: "silk mocked cucumber lettuce hope adrenalin aching lush roles fuel revamp baptism wrist long tender teardrop midst pastry pigment equip frying inbound pinched ravine frying",
restoreHeight: 0,
proxyToWorker: TestUtils.PROXY_TO_WORKER,
rejectUnauthorized: false
});
await walletFull.sync(new WalletSyncPrinter());
console.log("Full wallet daemon height: " + await walletFull.getDaemonHeight());
console.log("Full wallet mnemonic: " + await walletFull.getMnemonic());
await walletFull.close();
});
});