跳到主要内容

钱包会话与账户

Endpoint
http://127.0.0.1:3420/v3/owner
Credential
Token from open_wallet, inside the encrypted envelope. Loopback only
Methods here
10
Documented against
node 4.0.3, wallet 4.0.0

Exchange public keys and establish the shared secret for the encrypted envelope.

Surface
/v3/owner on port 3420
Parameters
1 named
Declared in
api/src/owner_rpc_s.rs:1495
  • The only call on this surface that is not encrypted, because it is what sets encryption up.
  • The shared secret is the raw x coordinate of the resulting point, 32 bytes, not hashed. It is used directly as the AES-256 key.
Parameters

Your ephemeral public key, 33 bytes hex.

8 lines
{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "init_secure_api",
  "params": {
    "ecdh_pubkey": "<your compressed secp256k1 public key, hex>"
  }
}
Response
N/A

open_wallet

Read only

Unlock the wallet with its password and receive the session token.

Takes the wallet password. Everything that can spend is gated behind the token this returns, so treat the token as a credential with the same weight.

Surface
/v3/owner on port 3420
Parameters
2 named
Declared in
api/src/owner_rpc_s.rs:1720
Parameters

Wallet name, or null for the default.

The password set at init.

9 lines
{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "open_wallet",
  "params": {
    "name": null,
    "password": "<wallet password>"
  }
}
Response
N/A

close_wallet

Read only

Close the wallet and invalidate its token.

Surface
/v3/owner on port 3420
Parameters
1 named
Declared in
api/src/owner_rpc_s.rs:1753
Parameters

Wallet name, or null.

8 lines
{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "close_wallet",
  "params": {
    "name": null
  }
}
Response
N/A

accounts

Read only

Every account label in this wallet, with its derivation path.

Surface
/v3/owner on port 3420
Parameters
1 named
Declared in
api/src/owner_rpc_s.rs:78
  • Each account is one BIP32 derivation path inside the wallet seed. The path identifier is one depth byte followed by four big-endian child indices.
  • A label this method does not return resolves to the active account when passed as src_acct_name or dest_acct_name.
Parameters

Session token. Every method on this surface needs it.

8 lines
{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "accounts",
  "params": {
    "token": "<token from open_wallet>"
  }
}
Response6 lines
[
  {
    "label": "default",
    "path": "0200000000000000000000000000000000"
  }
]

Create a new account label.

Surface
/v3/owner on port 3420
Parameters
2 named
Declared in
api/src/owner_rpc_s.rs:111
Parameters

Session token. Every method on this surface needs it.

New account label.

9 lines
{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "create_account_path",
  "params": {
    "token": "<token from open_wallet>",
    "label": "savings"
  }
}
Response
N/A

Choose which account later calls draw from and credit.

Surface
/v3/owner on port 3420
Parameters
2 named
Declared in
api/src/owner_rpc_s.rs:144
  • The active account is state on the wallet instance, shared by every token the listener serves, and it is not written to disk. A restarted listener starts on default unless epic-wallet was given -a.
  • To choose an account for one call without changing the active one, pass src_acct_name in InitTxArgs or dest_acct_name to the Foreign API.
Parameters

Session token. Every method on this surface needs it.

Account label to activate.

9 lines
{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "set_active_account",
  "params": {
    "token": "<token from open_wallet>",
    "label": "default"
  }
}
Response
N/A

create_config

Read only

Write a wallet configuration file for a chain type.

Surface
/v3/owner on port 3420
Parameters
5 named
Declared in
api/src/owner_rpc_s.rs:1637
Parameters

Mainnet, Floonet, UserTesting or AutomatedTesting.

Overrides for the generated config.

Logging overrides.

Tor settings for the generated config.

Relay overrides.

12 lines
{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "create_config",
  "params": {
    "chain_type": "Mainnet",
    "wallet_config": null,
    "logging_config": null,
    "tor_config": null,
    "epicbox_config": null
  }
}
Response
N/A

create_wallet

Changes state

Create a new wallet, or restore one from a recovery phrase.

Refuses to run if a seed file already exists, so it cannot silently overwrite a wallet. Move the existing wallet aside first if you mean to replace it.

Surface
/v3/owner on port 3420
Parameters
4 named
Declared in
api/src/owner_rpc_s.rs:1680
Parameters

Wallet name.

Recovery phrase to restore from, or null for a new seed.

Word count when generating a new seed.

Password to encrypt the seed with.

11 lines
{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "create_wallet",
  "params": {
    "name": null,
    "mnemonic": null,
    "mnemonic_length": 24,
    "password": "<new password>"
  }
}
Response
N/A

Where the wallet keeps its data.

Surface
/v3/owner on port 3420
Parameters
none
Declared in
api/src/owner_rpc_s.rs:1527

This method takes no parameters.

6 lines
{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "get_top_level_directory",
  "params": {}
}
Response
N/A

Point the wallet at a different data directory.

Changes which wallet later calls act on. Combined with a relocated directory it also changes which node secret resolves, which is the usual cause of an unexpected 401.

Surface
/v3/owner on port 3420
Parameters
1 named
Declared in
api/src/owner_rpc_s.rs:1560
Parameters

Absolute path.

8 lines
{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "set_top_level_directory",
  "params": {
    "dir": "/home/you/wallets/bob"
  }
}
Response
N/A

下一页