/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.
When using legacy ECDSA authentication
The wallet to update is the one used to create the usersignature
header.
When using Authentication Tokens
The wallet to update is the one specified by the wallet_id
in the request body.
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
When using legacy ECDSA authentication
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.
When using Authentication Tokens
Neither the authsignature
or usersignature
headers are required for this request.
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
sandbox.silamoney.com
Content-Type: application/json
// if using OAuth2
Authorization: Bearer [GENERATED JWT TOKEN HERE]
// if using ECDSA
authsignature: [GENERATED AUTHSIGNATURE HEX STRING HERE]
usersignature: [GENERATED USERSIGNATURE HEX STRING HERE]
// ECDSA
{
"header": {
"created": 1234567890,
"app_handle": "handle.silamoney.eth",
"user_handle":"user.silamoney.eth",
"version": "0.2",
"reference": "<your unique id>"
},
"nickname": "new_wallet_nickname",
"default": true
}
// Authentication Tokens
{
"header": {
"created": 1234567890,
"app_handle": "handle.silamoney.eth",
"user_handle":"user.silamoney.eth",
"version": "0.2",
"reference": "<your unique id>"
},
"wallet_id": "<wallet_id>",
"nickname": "new_wallet_nickname",
"default": true
}
***
HTTP/1.1 200 OK
// ECDSA
{
"message": "Wallet updated.",
"success": true,
"status": "SUCCESS",
"response_time_ms": "171",
"reference": "<your unique id>",
"wallet": {
"nickname": "new_wallet_nickname",
"default": true
},
"changes": [
{
"attribute": "nickname",
"old_value": "<original nickname>",
"new_value": "new_wallet_nickname"
},
{
"attribute": "default",
"old_value": false,
"new_value": true
}
]
}
// Authentication Tokens
{
"success": true,
"message": "Wallet updated.",
"reference": "<your unique id>",
"wallet": {
"nickname": "default",
"default": true,
"wallet_id": "fef85906-e289-4b6b-9ab4-68db2d8f46cb"
},
"changes": [
{
"attribute": "nickname",
"old_value": "<original nickname>",
"new_value": "new_wallet_nickname"
},
{
"attribute": "default",
"old_value": false,
"new_value": true
}
],
"status": "SUCCESS",
"response_time_ms": "92"
}
const walletProperties = { nickname: 'new_nickname', default: true };
const res = await Sila.updateWallet(
userHandle,
walletPrivateKey,
walletProperties,
statementsEnabled
); // 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,
"statements_enabled": 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,
"statements_enabled": 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,statementsEnabled) //statementsEnabled is optional // // ;
// 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()).getWallet().isStatementsEnabled());
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;
$statements_enabled = true
// Call the api
$response = $client->updateWallet($userHandle, $nickname, $status, $userPrivateKey, $statements_enabled);
// 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
echo $response->getData()->wallet->statements_enabled; // The wallet statement enabled will be true
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. |
wallet_id | String (uuid) | Required for AuthToken requests. |
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. |
Updated 3 months ago