gitlab.com/SiaPrime/SiaPrime@v1.4.1/doc/Exchanges.md (about) 1 Wallet Information for Exchanges 2 ======= 3 4 SiaPrime's wallet differs a bit from Bitcoin's. This guide is to point any exchanges to relevant functions and features of the wallet that may be of unique interest to them. 5 6 ### Address Management 7 8 The SiaPrime wallet follows the concept of an address gap limit [as specified in BIP 44](https://github.com/bitcoin/bips/blob/master/bip-0044.mediawiki#Address_gap_limit). The default gap limit is 50. This means the wallet will not allow creation of more than 50 consecutive addresses if none of those 50 addresses have been used on the blockchain. 9 10 New addresses can be created via a GET request to the `/wallet/address` endpoint. 11 12 ### Useful API Endpoints 13 14 Below is a list of several endpoints an exchange may find useful. For an overview of all API routes, see [API.md](/doc/API.md). 15 16 #### /wallet/watch [POST] 17 18 ###### Parameters 19 The parameters should be encoded as JSON. 20 21 ``` 22 // Array of addresses to be watched 23 addresses 24 25 // Boolean indicating whether we want to remove these 26 // address from our watch-list instead of add them 27 remove 28 29 // Boolean indicating whether or not these addresses 30 // have been used on the blockchain before. If unused 31 // is false, the wallet will rescan the blockchain after 32 // this request. 33 unused 34 35 ``` 36 37 ###### Response 38 39 standard success or error response. 40 41 #### /wallet/transactions [GET] 42 43 returns a list of transactions related to the wallet. 44 45 ###### Query String Parameters 46 ``` 47 // Number of most recent transactions to return. 48 // Must provide a valid value, defaults to 10 if unspecified. 49 count // block height 50 51 // An optional parameter specifying if we want to filter 52 // only transactions being sent or being received by the wallet. 53 // Can be either "send" or "receive". 54 category // block height 55 56 // A boolean parameter specifying if we want to filter 57 // only transactions pertaining to addresses being watched via 58 // the /wallet/watch [POST] command. 59 watchonly 60 ``` 61 62 ###### JSON Response 63 ```javascript 64 { 65 // The most recent 'count' transactions satisfying the filter criteria. 66 "confirmedtransactions": [ 67 { 68 // See the documentation for '/wallet/transaction/:id' for more information. 69 } 70 ], 71 72 // All of the unconfirmed transactions. 73 "unconfirmedtransactions": [ 74 { 75 // See the documentation for '/wallet/transaction/:id' for more information. 76 } 77 ] 78 } 79 ``` 80 81 #### /wallet/address [GET] 82 83 creates a new address from the wallet generated by the primary seed. An error will 84 be returned if the wallet is locked. 85 86 ###### JSON Response 87 ```javascript 88 { 89 // Wallet address that can receive SCP. Addresses are 76 character long hex strings. 90 "address": "1234567890abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789ab" 91 } 92 ``` 93 94 #### /wallet/siacoins [POST] 95 96 Function: Send SCP to an address or set of addresses. The outputs are 97 arbitrarily selected from addresses in the wallet. If 'outputs' is supplied, 98 'amount' and 'destination' must be empty. The number of outputs should not 99 exceed 400; this may result in a transaction too large to fit in the 100 transaction pool. 101 102 ###### Query String Parameters 103 ``` 104 // Number of hastings being sent. A hasting is the smallest unit in SiaPrime. There 105 // are 10^24 hastings in a single unit of SCP. 106 amount // hastings 107 108 // Address that is receiving the coins. 109 destination // address 110 111 // JSON array of outputs. The structure of each output is: 112 // {"unlockhash": "<destination>", "value": "<amount>"} 113 outputs 114 ``` 115 116 ###### JSON Response 117 ```javascript 118 { 119 // Array of IDs of the transactions that were created when sending the coins. 120 // The last transaction contains the output headed to the 'destination'. 121 // Transaction IDs are 64 character long hex strings. 122 transactionids [ 123 "1234567890abcdef0123456789abcdef0123456789abcdef0123456789abcdef", 124 "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", 125 "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb" 126 ] 127 } 128 ``` 129 130 ### Examples 131 132 #### Send to single address 133 134 ###### Example POST Request 135 Use _amount_ and _destination_ parameters. 136 ``` 137 /wallet/siacoins?amount=1000000000000000000000000&destination=1234567890abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789ab 138 ``` 139 140 ###### Expected Response Code 141 ``` 142 200 OK 143 ``` 144 145 ###### Example Response Body 146 ```json 147 { 148 "transactionids": [ 149 "3918e4a4b4cee46b3e5b28b8a1cc41c064a6f6002d162d396f296c201e6edc13", 150 "18b85b7d20f8a87bdadacf11e135ad44db1d93efd0613d23116e8cf255502762" 151 ] 152 } 153 ``` 154 155 156 #### Send to set of addresses 157 Use _outputs_ parameter in the form of a JSON array. _amount_ and _destination_ parameters must be empty. 158 159 160 ###### Example POST Request 161 ``` 162 /wallet/siacoins?outputs=[{"unlockhash":"1234567890abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789ab","value":"1000000000000000000000000"},{"unlockhash":"abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789ab1234567890","value":"8000000000000000000000000"},{"unlockhash":"cdef0123456789abcdef0123456789abcdef0123456789ab1234567890abcdef0123456789ab","value":"5000000000000000000000000"}] 163 ``` 164 165 ###### (sample JSON request body for reference) 166 ```json 167 { 168 "outputs": [ 169 { 170 "unlockhash": 171 "1234567890abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789ab", 172 "value": "1000000000000000000000000" 173 }, 174 { 175 "unlockhash": 176 "abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789ab1234567890", 177 "value": "8000000000000000000000000" 178 }, 179 { 180 "unlockhash": 181 "cdef0123456789abcdef0123456789abcdef0123456789ab1234567890abcdef0123456789ab", 182 "value": "20000000000000000000000000" 183 } 184 ] 185 } 186 187 ``` 188 189 ###### Expected Response Code 190 ``` 191 200 OK 192 ``` 193 194 ###### Example Response Body 195 ```json 196 { 197 "transactionids": [ 198 "21962e0118f3ca5d6fab0262c65bca0220fbcc828c499974d86e7cc4047a0ce5", 199 "f2471d550823f2c0616565d8476a7fea5f2b9a841612bf109923c3a54e760721" 200 ] 201 } 202 ``` 203