/update_wallet

Updates nickname and/or default status of a wallet.

This endpoint allows updating of a wallet's nickname and treatment as a default destination address for a handle. The wallet to update is the one used to create the usersignature header.

Wallet nicknames must be (case-insensitive) unique among a user's wallets. For example, two different users can have wallets nicknamed "default_wallet", but one user cannot have two wallets named "default" and "DEFAULT".

A "default" wallet is the address to which tokens are transferred to a "destination_handle" if no "destination_wallet" (nickname) or "destination_address" (blockchain address) is specified in a /transfer_sila request.

  

Requests

Both authsignature and usersignature headers are required for this request. The usersignature header should be generated with the user's wallet that needs to be updated.

The nickname key is not required; if provided, its string value must be unique (case-insensitive) among a user's wallets.

The default key is not required; the value is a boolean.

Note - We recently renamed the field auth_handle to app_handle. For backward compatibility, auth_handle is still valid but has been removed from our documentation.

  
POST /0.2/update_wallet HTTP/1.1
Host: sandbox.silamoney.com
authsignature: [GENERATED AUTHSIGNATURE HEX STRING HERE]
usersignature: [GENERATED USERSIGNATURE HEX STRING HERE]
Content-Type: application/json

{
  "header": {
    "created": 1234567890, 
    "app_handle": "handle.silamoney.eth", 
    "user_handle":"user.silamoney.eth", 
    "version": "0.2", 
    "crypto": "ETH", 
    "reference": "<your unique id>"
  }, 
  "nickname": "new_wallet_nickname",
  "default": true
}

***

HTTP/1.1 200 OK

{
  "message": "Wallet updated.",
  "success": true,
  "status": "SUCCESS",
  "response_time_ms": "171",
  "reference": "<your unique id>",
  "wallet": {
    "blockchain_address": "(address)",
    "blockchain_network": "ETH",
    "nickname": "new_wallet_nickname",
    "default": true
  },
  "changes": [
    {
      "attribute": "nickname",
      "old_value": "",
      "new_value": "new_wallet_nickname"
    },
    {
      "attribute": "default",
      "old_value": false,
      "new_value": true
    }
  ]
}
const walletProperties = { nickname: 'new_nickname', default: true };
const res = await Sila.updateWallet(
  userHandle,
  walletPrivateKey,
  walletProperties,
); // Nickname and Default are not required but you must include at least one of them.

// Success Response Object
console.log(res.statusCode); // 200
console.log(res.data.success); // TRUE
console.log(res.data.status);
console.log(res.data.message); // Wallet updated
console.log(res.data.wallet); // Wallet's detail (nickname, default...)
console.log(res.data.changes); // An array of the changes made to the wallet
payload = {
    "user_handle": "user.silamoney.eth",
    "nickname": "wallet_python_updated",
    "default": True
}

response = Wallet.updateWallet(app, payload, user_private_key)

### Success Response Object
{
  "status": 'SUCCESS',
  "status_code": 200,
  "message": "Wallet updated.",
  "success": True,
  "wallet": {
    "blockchain_address": "(address)",
    "blockchain_network": "ETH",
    "nickname": "new_wallet_nickname",
    "default": True
  },
  "changes": [
    {
      "attribute": "nickname",
      "old_value": "",
      "new_value": "new_wallet_nickname"
    },
    {
      "attribute": "default",
      "old_value": False,
      "new_value": True
    }
  ]
}

### Failure Response Object
{
    "message": "Wallet updated.",
    "success": True
}
ApiResponse response = api.updateWallet(userHandle, nickname, status, userPrivateKey);

// Success Response Object
System.out.println(response.getStatusCode()); // 200
System.out.println(((UpdateWalletResponse)response.getData()).getSuccess());
System.out.println(((UpdateWalletResponse)response.getData()).getMessage());
System.out.println(((UpdateWalletResponse)response.getData()).getStatus());
System.out.println(((UpdateWalletResponse)response.getData()).getWallet().getBlockChainAddress());
System.out.println(((UpdateWalletResponse)response.getData()).getWallet().getBlockChainNetwork());
System.out.println(((UpdateWalletResponse)response.getData()).getWallet().getNickname());
System.out.println(((UpdateWalletResponse)response.getData()).getWallet().isDefaultWallet());
System.out.println(((UpdateWalletResponse)response.getData()).getChanges().get(0).getAttribute());
System.out.println(((UpdateWalletResponse)response.getData()).getChanges().get(0).getOldValue());
System.out.println(((UpdateWalletResponse)response.getData()).getChanges().get(0).getNewValue());
$userHandle = 'user.silamoney.eth';
$userPrivateKey = 'some private key'; // Hex format
$nickname = 'new_wallet_nickname'
$status = true

// Call the api
$response = $client->updateWallet($userHandle, $nickname, $status, $userPrivateKey);

// Success 200
echo $response->getStatusCode(); // 200
echo $response->getData()->status;
echo $response->getData()->success; // TRUE
echo $response->getData()->message; // Message
echo $response->getData()->wallet; // The wallet updated
echo $response->getData()->changes; // An array with the changes made to the properties
ApiResponse<object> response = api.UpdateWallet(userHandle, walletPrivateKey, nickname, isDefault); // Nickname and Is Default are not required but you must include at least one of them.

// Success Object Response

Console.WriteLine(response.StatusCode); // 200
var parsedData = (UpdateWalletResponse)response.Data;
Console.WriteLine(parsedData.Success); // TRUE
Console.WriteLine(parsedData.Message); // Message
Console.WriteLine(parsedData.Wallet); // Wallet details (nickname, default...)
Console.WriteLine(parsedData.Changes); // A list of changes made to the wallet

Key

Type

Description

header

JSON object

Required. Requires these keys in JSON format: created, app_handle, user_handle. See the /check_handle endpoint for the complete list of fields in this object.

nickname

String

Optional. Must be unique for user_handle wallet nicknames. Min Length 1, Max Length 40
Example: new_wallet_nickname

default

Boolean

Optional. Default false. If set to true and tokens are transferred to this user with the /transfer_sila endpoint and no specific wallet is named, the wallet set as default will be the transfer destination.

  

Responses

The success attribute is a JSON key sent in the response body.

Status Code

success Attribute

Description

200

true

Successfully updated wallet.

400

false

Bad request format.

401

false

Auth signature is absent or derived address does not belong to app_handle.

403

false

Wallet nickname already in use.


Did this page help you?