Wallet API Reference

Wallet REST API Reference

This is the API reference documentation for the REST service built into the Vega Wallet software. For detailed explanation of the Vega Wallet see the Wallets and signing section of the documentation and for further code examples see the Vega Wallet API how to guide.

Create a wallet

Creating a wallet is done using a name and passphrase. If a wallet already exists, the action is aborted. New wallets are marshalled, encrypted (using the passphrase) and saved to a file on the file system. A session and accompanying token (JWT) is created, and the JWT is returned to the user.

  • Request:

    {
      "wallet": "walletname",
      "passphrase": "supersecret"
    }
    
  • Command:

    curl -s -XPOST -d 'requestjson' https://wallet.testnet.vega.xyz/api/v1/wallets
    
  • Response:

    {
      "token": "verylongJWT"
    }
    

Logging in to a wallet

Logging in to a wallet is done using the wallet name and passphrase. The operation fails should the wallet not exist, or if the passphrase used is incorrect (i.e. the passphrase cannot be used to decrypt the wallet). On success, the wallet is loaded, a session is created and a JWT is returned to the user.

  • Request:

    {
      "wallet": "walletname",
      "passphrase": "supersecret"
    }
    
  • Command:

    curl -s -XPOST -d 'requestjson' https://wallet.testnet.vega.xyz/api/v1/auth/token
    
  • Response:

    {
      "token": "verylongJWT"
    }
    

Sign a transaction

Sign a transaction using the specified key pair. tx is a base64 encoded Vega command message e.g. OrderSubmission, OrderAmendment, etc.

  • Request:

    {
      "tx": "dGVzdGRhdGEK",
      "pubKey": "1122aabb...",
      "propagate": false
    }
    
  • Command:

    curl -s -XPOST -H "Authorization: Bearer verylongJWT" -d 'requestjson' https://wallet.testnet.vega.xyz/api/v1/messages
    
    
  • Response:

    {
      "signedTx": {
        "data": "dGVzdGRhdGEK",
        "sig": "...",
        "pubKey": "1122aabb..."
      }
    }
    

Propagate transaction

As seen (above), the request payload includes a propagate field. If set to true the Vega Wallet service, if configured with a correct Vega node address, will try to send the transaction on your behalf to the node after signing it successfully.

In the future, a Vega node address can be configured via configuration file, by default it will point to a local address.

Logging out of a wallet

Using the JWT returned when logging in, the session is recovered and removed from the service. The wallet can no longer be accessed using the token from this point on.

  • Request: n/a

  • Command:

    curl -s -XDELETE -H 'Authorization: Bearer verylongJWT' https://wallet.testnet.vega.xyz/api/v1/auth/token
    
  • Response:

    {
      "success": true
    }
    

List keys

Users can list all their public keys (with taint status, and metadata), if they provide the correct JWT. The service extracts the session from this token, and uses it to fetch the relevant wallet information to send back to the user.

  • Request: n/a

  • Command:

    curl -s -XGET -H "Authorization: Bearer verylongJWT" https://wallet.testnet.vega.xyz/api/v1/keys
    
  • Response:

    {
      "keys": [
        {
          "pub": "1122aabb...",
          "algo": "ed25519",
          "tainted": false,
          "meta": [
            {
              "key": "somekey",
              "value": "somevalue"
            }
          ]
        }
      ]
    }
    

Generate a new key pair

The user submits a valid JWT, and a passphrase. We recover the session of the user, and attempt to open the wallet using the passphrase. If the JWT is invalid, the session could not be recovered, or the wallet could not be opened, an error is returned. If all went well, a new key pair is generated, saved in the wallet, and the public key is returned.

  • Request:

    {
      "passphrase": "supersecret",
      "meta": [
        {
          "key": "somekey",
          "value": "somevalue"
        }
      ]
    }
    
  • Command:

    curl -s -XPOST -H 'Authorization: Bearer verylongJWT' -d 'requestjson' https://wallet.testnet.vega.xyz/api/v1/keys
    
  • Response:

    {
      "key": {
        "pub": "1122aabb...",
        "algo": "ed25519",
        "tainted": false,
        "meta": [
          {
            "key": "somekey",
            "value": "somevalue"
          }
        ]
      }
    }
    

Taint a key

When a user decides they no longer want to use a specific key in their wallet, that user can taint the key. The key is not deleted, nor does it lose any collateral associated with it. The wallet will mark this key as tainted and will not allow the user to sign anything with it.

  • Request:

    {
      "passphrase": "supersecret"
    }
    
  • Command:

    curl -s -XPUT -H "Authorization: Bearer verylongJWT" -d 'requestjson' https://wallet.testnet.vega.xyz/api/v1/keys/1122aabb/taint
    
    
  • Response:

    {
      "success": true
    }
    

Update key metadata

Overwrite all existing metadata with the new metadata.

  • Request:

    {
      "passphrase": "supersecret",
      "meta": [
        {
          "key": "newkey",
          "value": "newvalue"
        }
      ]
    }
    
  • Command:

    curl -s -XPUT -H "Authorization: Bearer verylongJWT" -d 'requestjson' https://wallet.testnet.vega.xyz/api/v1/keys/1122aabb/metadata
    
    
  • Response:

    {
      "success": true
    }