1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* User: delboy1978uk |
4
|
|
|
* Date: 18/08/15 |
5
|
|
|
* Time: 20:00 |
6
|
|
|
*/ |
7
|
|
|
|
8
|
|
|
namespace Del\Bitcoin\Api; |
9
|
|
|
|
10
|
|
|
|
11
|
|
|
class Wallet extends AbstractApi |
12
|
|
|
{ |
13
|
|
|
/** |
14
|
|
|
* The addmultisigaddress RPC adds a P2SH multisig address to the wallet. |
15
|
|
|
* |
16
|
|
|
* @param int $number The minimum (m) number of signatures required to spend |
17
|
|
|
* this m-of-n multisig script |
18
|
|
|
* @param string|array $addresses either |
19
|
|
|
* Keys Or Addresses array Required(exactly 1) |
20
|
|
|
* An array of strings with each string being a public key or address |
21
|
|
|
* Key Or Address string Required(1 or more) |
22
|
|
|
* A public key against which signatures will be checked. Alternatively, |
23
|
|
|
* this may be a P2PKH address belonging to the wallet—the corresponding |
24
|
|
|
* public key will be substituted. There must be at least as many keys as |
25
|
|
|
* specified by the Required parameter, and there may be more keys |
26
|
|
|
* @return mixed |
27
|
|
|
*/ |
28
|
|
|
public function addMultiSigAddress($number,$addresses) |
29
|
|
|
{ |
30
|
|
|
return $this->send('addmultisigaddress',[$number,$addresses]); |
31
|
|
|
} |
32
|
|
|
|
33
|
|
|
/** |
34
|
|
|
* The backupwallet RPC safely copies wallet.dat to the specified file, which |
35
|
|
|
* can be a directory or a path with filename. |
36
|
|
|
* |
37
|
|
|
* @param string $destination A filename or directory name. If a filename, it will |
38
|
|
|
* be created or overwritten. If a directory name, the file wallet.dat will be |
39
|
|
|
* created or overwritten within that directory |
40
|
|
|
* @return mixed |
41
|
|
|
*/ |
42
|
|
|
public function backupWallet($destination) |
43
|
|
|
{ |
44
|
|
|
return $this->send('backupwallet',[$destination]); |
45
|
|
|
} |
46
|
|
|
|
47
|
|
|
/** |
48
|
|
|
* The dumpprivkey RPC returns the wallet-import-format (WIP) private key |
49
|
|
|
* corresponding to an address. (But does not remove it from the wallet.) |
50
|
|
|
* |
51
|
|
|
* @param string $p2pkh_address The P2PKH address corresponding to the private key |
52
|
|
|
* you want returned. Must be the address corresponding to a private key in this wallet |
53
|
|
|
* @return mixed |
54
|
|
|
*/ |
55
|
|
|
public function dumpPrivKey($p2pkh_address) |
56
|
|
|
{ |
57
|
|
|
return $this->send('dumpprivkey',[$p2pkh_address]); |
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
/** |
61
|
|
|
* The dumpwallet RPC creates or overwrites a file with all wallet keys in a |
62
|
|
|
* human-readable format. |
63
|
|
|
* |
64
|
|
|
* @param string $filename The file in which the wallet dump will be placed. May be |
65
|
|
|
* prefaced by an absolute file path. An existing file with that name will be |
66
|
|
|
* overwritten |
67
|
|
|
* @return mixed |
68
|
|
|
*/ |
69
|
|
|
public function dumpWallet($filename) |
70
|
|
|
{ |
71
|
|
|
return $this->send('dumpwallet',[$filename]); |
72
|
|
|
} |
73
|
|
|
|
74
|
|
|
/** |
75
|
|
|
* The encryptwallet RPC encrypts the wallet with a passphrase. This is only to enable |
76
|
|
|
* encryption for the first time. After encryption is enabled, you will need to enter |
77
|
|
|
* the passphrase to use private keys. |
78
|
|
|
* |
79
|
|
|
* Warning: if using this RPC on the command line, remember that your shell probably |
80
|
|
|
* saves your command lines (including the value of the passphrase parameter). In |
81
|
|
|
* addition, there is no RPC to completely disable encryption. If you want to return |
82
|
|
|
* to an unencrypted wallet, you must create a new wallet and restore your data from |
83
|
|
|
* a backup made with the dumpwallet RPC. |
84
|
|
|
* |
85
|
|
|
* @param string $passphrase |
86
|
|
|
* @return mixed |
87
|
|
|
*/ |
88
|
|
|
public function encryptWallet($passphrase) |
89
|
|
|
{ |
90
|
|
|
return $this->send('encryptwallet',[$passphrase]); |
91
|
|
|
} |
92
|
|
|
|
93
|
|
|
/** |
94
|
|
|
* The getaccountaddress RPC returns the current Bitcoin address for receiving payments |
95
|
|
|
* to this account. If the account doesn’t exist, it creates both the account and a new |
96
|
|
|
* address for receiving payment. Once a payment has been received to an address, |
97
|
|
|
* future calls to this RPC for the same account will return a different address. |
98
|
|
|
* |
99
|
|
|
* @param string $account The name of an account. Use an empty string (“”) for the |
100
|
|
|
* default account. If the account doesn’t exist, it will be created |
101
|
|
|
* @return mixed |
102
|
|
|
*/ |
103
|
|
|
public function getAccountAddress($account = '') |
104
|
|
|
{ |
105
|
|
|
return $this->send('getaccountaddress',[$account]); |
106
|
|
|
} |
107
|
|
|
|
108
|
|
|
/** |
109
|
|
|
* The getaccount RPC returns the name of the account associated with the given address. |
110
|
|
|
* |
111
|
|
|
* @param string $address A P2PKH or P2SH Bitcoin address belonging either to a specific |
112
|
|
|
* account or the default account (“”) |
113
|
|
|
* @return mixed |
114
|
|
|
*/ |
115
|
|
|
public function getAccount($address) |
116
|
|
|
{ |
117
|
|
|
return $this->send('getaccount',[$address]); |
118
|
|
|
} |
119
|
|
|
|
120
|
|
|
/** |
121
|
|
|
* The getaddressesbyaccount RPC returns a list of every address assigned to a |
122
|
|
|
* particular account. |
123
|
|
|
* |
124
|
|
|
* @param string $account The name of the account containing the addresses to |
125
|
|
|
* get. To get addresses from the default account, pass an empty string (“”) |
126
|
|
|
* @return mixed |
127
|
|
|
*/ |
128
|
|
|
public function getAddressesByAccount($account = '') |
129
|
|
|
{ |
130
|
|
|
return $this->send('getaddressesbyaccount',[$account]); |
131
|
|
|
} |
132
|
|
|
|
133
|
|
|
/** |
134
|
|
|
* The getbalance RPC gets the balance in decimal bitcoins across all accounts |
135
|
|
|
* or for a particular account. |
136
|
|
|
* |
137
|
|
|
* @param string $account The name of an account to get the balance for. An |
138
|
|
|
* empty string (“”) is the default account. The string * will get the balance |
139
|
|
|
* for all accounts (this is the default behavior) |
140
|
|
|
* @param int $confirmations The minimum number of confirmations an |
141
|
|
|
* externally-generated transaction must have before it is counted towards the |
142
|
|
|
* balance. Transactions generated by this node are counted immediately. Typically, |
143
|
|
|
* externally-generated transactions are payments to this wallet and transactions |
144
|
|
|
* generated by this node are payments to other wallets. Use 0 to count unconfirmed |
145
|
|
|
* transactions. Default is 1 |
146
|
|
|
* @param bool $inc_watch_only |
147
|
|
|
* @return mixed |
148
|
|
|
*/ |
149
|
|
|
public function getBalance($account = '*',$confirmations = 1,$inc_watch_only = false) |
150
|
|
|
{ |
151
|
|
|
return $this->send('getbalance',[$account,$confirmations,$inc_watch_only]); |
152
|
|
|
} |
153
|
|
|
|
154
|
|
|
/** |
155
|
|
|
* The getnewaddress RPC returns a new Bitcoin address for receiving payments. If an |
156
|
|
|
* account is specified, payments received with the address will be credited to that |
157
|
|
|
* account. |
158
|
|
|
* |
159
|
|
|
* @param string $account The name of the account to put the address in. The default |
160
|
|
|
* is the default account, an empty string (“”) |
161
|
|
|
* @return mixed |
162
|
|
|
*/ |
163
|
|
|
public function getNewAddress($account = '') |
164
|
|
|
{ |
165
|
|
|
return $this->send('getnewaddress',[$account]); |
166
|
|
|
} |
167
|
|
|
|
168
|
|
|
/** |
169
|
|
|
* The getrawchangeaddress RPC returns a new Bitcoin address for receiving change. |
170
|
|
|
* This is for use with raw transactions, not normal use. |
171
|
|
|
* |
172
|
|
|
* @return mixed |
173
|
|
|
*/ |
174
|
|
|
public function getRawChangeAddress() |
175
|
|
|
{ |
176
|
|
|
return $this->send('getrawchangeaddress'); |
177
|
|
|
} |
178
|
|
|
|
179
|
|
|
/** |
180
|
|
|
* The getreceivedbyaccount RPC returns the total amount received by addresses in a |
181
|
|
|
* particular account from transactions with the specified number of confirmations. |
182
|
|
|
* It does not count coinbase transactions. |
183
|
|
|
* |
184
|
|
|
* @param string $account The name of the account containing the addresses to get. |
185
|
|
|
* For the default account, use an empty string (“”) |
186
|
|
|
* @return mixed |
187
|
|
|
*/ |
188
|
|
|
public function getReceivedByAccount($account) |
189
|
|
|
{ |
190
|
|
|
return $this->send('getreceivedbyaccount',[$account]); |
191
|
|
|
} |
192
|
|
|
|
193
|
|
|
/** |
194
|
|
|
* The getreceivedbyaddress RPC returns the total amount received by the specified |
195
|
|
|
* address in transactions with the specified number of confirmations. It does not |
196
|
|
|
* count coinbase transactions. |
197
|
|
|
* |
198
|
|
|
* @param string $address The address whose transactions should be tallied |
199
|
|
|
* @return mixed |
200
|
|
|
*/ |
201
|
|
|
public function getReceivedByAddress($address) |
202
|
|
|
{ |
203
|
|
|
return $this->send('getreceivedbyaddress',[$address]); |
204
|
|
|
} |
205
|
|
|
|
206
|
|
|
/** |
207
|
|
|
* The gettransaction RPC gets detailed information about an in-wallet transaction. |
208
|
|
|
* |
209
|
|
|
* @param string $txid The TXID of the transaction to get details about. The TXID must be |
210
|
|
|
* encoded as hex in RPC byte order |
211
|
|
|
* @param bool $inc_watch_only If set to true, include watch-only addresses in details |
212
|
|
|
* and calculations as if they were regular addresses belonging to the wallet. If set |
213
|
|
|
* to false (the default), treat watch-only addresses as if they didn’t belong to this |
214
|
|
|
* wallet |
215
|
|
|
* @return mixed |
216
|
|
|
*/ |
217
|
|
|
public function getTransaction($txid,$inc_watch_only = false) |
218
|
|
|
{ |
219
|
|
|
return $this->send('gettransaction',[$txid,$inc_watch_only]); |
220
|
|
|
} |
221
|
|
|
|
222
|
|
|
/** |
223
|
|
|
* The getunconfirmedbalance RPC returns the wallet’s total unconfirmed balance. |
224
|
|
|
* |
225
|
|
|
* @return mixed |
226
|
|
|
*/ |
227
|
|
|
public function getUnconfirmedBalance() |
228
|
|
|
{ |
229
|
|
|
return $this->send('getunconfirmedbalance'); |
230
|
|
|
} |
231
|
|
|
|
232
|
|
|
/** |
233
|
|
|
* The getwalletinfo RPC provides information about the wallet. |
234
|
|
|
* |
235
|
|
|
* @return mixed |
236
|
|
|
*/ |
237
|
|
|
public function getWalletInfo() |
238
|
|
|
{ |
239
|
|
|
return $this->send('getwalletinfo'); |
240
|
|
|
} |
241
|
|
|
|
242
|
|
|
/** |
243
|
|
|
* The importaddress RPC adds an address or pubkey script to the wallet without the |
244
|
|
|
* associated private key, allowing you to watch for transactions affecting that address |
245
|
|
|
* or pubkey script without being able to spend any of its outputs. |
246
|
|
|
* |
247
|
|
|
* @param string $address Either a P2PKH or P2SH address encoded in base58check, or a |
248
|
|
|
* pubkey script encoded as hex |
249
|
|
|
* @param string $account An account name into which the address should be placed. Default |
250
|
|
|
* is the default account, an empty string(“”) |
251
|
|
|
* @param bool $rescan Set to true (the default) to rescan the entire local block database |
252
|
|
|
* for transactions affecting any address or pubkey script in the wallet (including |
253
|
|
|
* transaction affecting the newly-added address or pubkey script). Set to false to not |
254
|
|
|
* rescan the block database (rescanning can be performed at any time by restarting Bitcoin |
255
|
|
|
* Core with the -rescan command-line argument). Rescanning may take several minutes. Notes: |
256
|
|
|
* if the address or pubkey script is already in the wallet, the block database will not be |
257
|
|
|
* rescanned even if this parameter is set |
258
|
|
|
* @return mixed |
259
|
|
|
*/ |
260
|
|
|
public function importAddress($address,$account = '',$rescan = true) |
261
|
|
|
{ |
262
|
|
|
return $this->send('importaddress',[$address,$account,$rescan]); |
263
|
|
|
} |
264
|
|
|
|
265
|
|
|
/** |
266
|
|
|
* The importprivkey RPC adds a private key to your wallet. The key should be formatted in |
267
|
|
|
* the wallet import format created by the dumpprivkey RPC. |
268
|
|
|
* |
269
|
|
|
* @param $key |
270
|
|
|
* @param string $account |
271
|
|
|
* @param bool $rescan |
272
|
|
|
* @return mixed |
273
|
|
|
*/ |
274
|
|
|
public function importPrivKey($key,$account = '',$rescan = true) |
275
|
|
|
{ |
276
|
|
|
return $this->send('importprivkey',[$key,$account,$rescan]); |
277
|
|
|
} |
278
|
|
|
|
279
|
|
|
/** |
280
|
|
|
* The importwallet RPC imports private keys from a file in wallet dump file format |
281
|
|
|
* (see the dumpwallet RPC). These keys will be added to the keys currently in the |
282
|
|
|
* wallet. This call may need to rescan all or parts of the block chain for transactions |
283
|
|
|
* affecting the newly-added keys, which may take several minutes. |
284
|
|
|
* |
285
|
|
|
* @param string $filename The file to import. The path is relative to Bitcoin Core’s |
286
|
|
|
* working directory |
287
|
|
|
* @return mixed |
288
|
|
|
*/ |
289
|
|
|
public function importWallet($filename) |
290
|
|
|
{ |
291
|
|
|
return $this->send('importwallet',[$filename]); |
292
|
|
|
} |
293
|
|
|
|
294
|
|
|
/** |
295
|
|
|
* The keypoolrefill RPC fills the cache of unused pre-generated keys (the keypool). |
296
|
|
|
* |
297
|
|
|
* @param $size |
298
|
|
|
* @return mixed |
299
|
|
|
*/ |
300
|
|
|
public function keyPoolRefill($size) |
301
|
|
|
{ |
302
|
|
|
return $this->send('keypoolrefill',[$size]); |
303
|
|
|
} |
304
|
|
|
|
305
|
|
|
/** |
306
|
|
|
* The listaccounts RPC lists accounts and their balances. |
307
|
|
|
* |
308
|
|
|
* @param int $confirmations The minimum number of confirmations an externally-generated |
309
|
|
|
* transaction must have before it is counted towards the balance. Transactions generated |
310
|
|
|
* by this node are counted immediately. Typically, externally-generated transactions are |
311
|
|
|
* payments to this wallet and transactions generated by this node are payments to other |
312
|
|
|
* wallets. Use 0 to count unconfirmed transactions. Default is 1 |
313
|
|
|
* @param bool $inc_watch_only If set to true, include watch-only addresses in details and |
314
|
|
|
* calculations as if they were regular addresses belonging to the wallet. If set to false |
315
|
|
|
* (the default), treat watch-only addresses as if they didn’t belong to this wallet |
316
|
|
|
* @return mixed |
317
|
|
|
*/ |
318
|
|
|
public function listAccounts($confirmations = 1, $inc_watch_only = false) |
319
|
|
|
{ |
320
|
|
|
return $this->send('listaccounts',[$confirmations,$inc_watch_only]); |
321
|
|
|
} |
322
|
|
|
|
323
|
|
|
/** |
324
|
|
|
* The listaddressgroupings RPC lists groups of addresses that may have had their common |
325
|
|
|
* ownership made public by common use as inputs in the same transaction or from being |
326
|
|
|
* used as change from a previous transaction. |
327
|
|
|
* |
328
|
|
|
* @return mixed |
329
|
|
|
*/ |
330
|
|
|
public function listAddressGroupings() |
331
|
|
|
{ |
332
|
|
|
return $this->send('listaddressgroupings'); |
333
|
|
|
} |
334
|
|
|
|
335
|
|
|
/** |
336
|
|
|
* The listlockunspent RPC returns a list of temporarily unspendable (locked) outputs. |
337
|
|
|
* @return mixed |
338
|
|
|
*/ |
339
|
|
|
public function listLockUnspent() |
340
|
|
|
{ |
341
|
|
|
return $this->send('listlockunspent'); |
342
|
|
|
} |
343
|
|
|
|
344
|
|
|
/** |
345
|
|
|
* The listreceivedbyaccount RPC lists the total number of bitcoins received by each account. |
346
|
|
|
* |
347
|
|
|
* @param int $confirmations The minimum number of confirmations an externally-generated |
348
|
|
|
* transaction must have before it is counted towards the balance. Transactions generated |
349
|
|
|
* by this node are counted immediately. Typically, externally-generated transactions are |
350
|
|
|
* payments to this wallet and transactions generated by this node are payments to other |
351
|
|
|
* wallets. Use 0 to count unconfirmed transactions. Default is 1 |
352
|
|
|
* @param bool $inc_empty Set to true to display accounts which have never received a payment. |
353
|
|
|
* Set to false (the default) to only include accounts which have received a payment. Any account |
354
|
|
|
* which has received a payment will be displayed even if its current balance is 0 |
355
|
|
|
* @param bool $inc_watch_only If set to true, include watch-only addresses in details and |
356
|
|
|
* calculations as if they were regular addresses belonging to the wallet. If set to false |
357
|
|
|
* (the default), treat watch-only addresses as if they didn’t belong to this wallet |
358
|
|
|
* @return mixed |
359
|
|
|
*/ |
360
|
|
|
public function listReceivedByAccount($confirmations = 1,$inc_empty = false,$inc_watch_only = false) |
361
|
|
|
{ |
362
|
|
|
return $this->send('listreceivedbyaccount',[$confirmations,$inc_empty,$inc_watch_only]); |
363
|
|
|
} |
364
|
|
|
|
365
|
|
|
/** |
366
|
|
|
* The listreceivedbyaddress RPC lists the total number of bitcoins received by each address. |
367
|
|
|
* |
368
|
|
|
* @param int $confirmations The minimum number of confirmations an externally-generated |
369
|
|
|
* transaction must have before it is counted towards the balance. Transactions generated |
370
|
|
|
* by this node are counted immediately. Typically, externally-generated transactions are |
371
|
|
|
* payments to this wallet and transactions generated by this node are payments to other |
372
|
|
|
* wallets. Use 0 to count unconfirmed transactions. Default is 1 |
373
|
|
|
* @param bool $inc_empty Set to true to display accounts which have never received a payment. |
374
|
|
|
* Set to false (the default) to only include accounts which have received a payment. Any account |
375
|
|
|
* which has received a payment will be displayed even if its current balance is 0 |
376
|
|
|
* @param bool $inc_watch_only If set to true, include watch-only addresses in details and |
377
|
|
|
* calculations as if they were regular addresses belonging to the wallet. If set to false |
378
|
|
|
* (the default), treat watch-only addresses as if they didn’t belong to this wallet |
379
|
|
|
* @return mixed |
380
|
|
|
*/ |
381
|
|
|
public function listReceivedByAddress($confirmations = 1,$inc_empty = false,$inc_watch_only = false) |
382
|
|
|
{ |
383
|
|
|
return $this->send('listreceivedbyaddress',[$confirmations,$inc_empty,$inc_watch_only]); |
384
|
|
|
} |
385
|
|
|
|
386
|
|
|
/** |
387
|
|
|
* The listsinceblock RPC gets all transactions affecting the wallet which have occurred since a |
388
|
|
|
* particular block, plus the header hash of a block at a particular depth. |
389
|
|
|
* |
390
|
|
|
* @param string $header_hash The hash of a block header encoded as hex in RPC byte order |
391
|
|
|
* . All transactions affecting the wallet which are not in that block or any earlier |
392
|
|
|
* block will be returned, including unconfirmed transactions. Default is the hash of the |
393
|
|
|
* genesis block, so all transactions affecting the wallet are returned by default |
394
|
|
|
* @param int $target_confirmations Sets the lastblock field of the results to the header hash |
395
|
|
|
* of a block with this many confirmations. This does not affect which transactions are |
396
|
|
|
* returned. Default is 1, so the hash of the most recent block on the local best block chain is returned |
397
|
|
|
* @param bool $inc_watch_only If set to true, include watch-only addresses in details and |
398
|
|
|
* calculations as if they were regular addresses belonging to the wallet. If set to false |
399
|
|
|
* (the default), treat watch-only addresses as if they didn’t belong to this wallet |
400
|
|
|
* @return mixed |
401
|
|
|
*/ |
402
|
|
|
public function listSinceBlock($header_hash = '0x000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f',$target_confirmations = 1,$inc_watch_only = false) |
403
|
|
|
{ |
404
|
|
|
return $this->send('listsinceblock',[$header_hash,$target_confirmations,$inc_watch_only]); |
405
|
|
|
} |
406
|
|
|
|
407
|
|
|
/** |
408
|
|
|
* The listtransactions RPC returns the most recent transactions that affect the wallet. |
409
|
|
|
* |
410
|
|
|
* @param string $account The name of an account to get transactinos from. Use an empty string (“”) |
411
|
|
|
* to get transactions for the default account. Default is * to get transactions for all accounts |
412
|
|
|
* @param int $count The number of the most recent transactions to list. Default is 10 |
413
|
|
|
* @param int $skip The number of the most recent transactions which should not be returned. Allows |
414
|
|
|
* for pagination of results. Default is 0 |
415
|
|
|
* @param bool $inc_watch_only If set to true, include watch-only addresses in details and |
416
|
|
|
* calculations as if they were regular addresses belonging to the wallet. If set to false (the |
417
|
|
|
* default), treat watch-only addresses as if they didn’t belong to this wallet |
418
|
|
|
* @return mixed |
419
|
|
|
*/ |
420
|
|
|
public function listTransactions($account = '*',$count = 10,$skip = 0,$inc_watch_only = false) |
421
|
|
|
{ |
422
|
|
|
return $this->send('listtransactions',[$account,$count,$skip,$inc_watch_only]); |
423
|
|
|
} |
424
|
|
|
|
425
|
|
|
/** |
426
|
|
|
* The listunspent RPC returns an array of unspent transaction outputs belonging to this wallet. |
427
|
|
|
* Note: as of Bitcoin Core 0.10.0, outputs affecting watch-only addresses will be returned; see |
428
|
|
|
* the spendable field in the results described below. |
429
|
|
|
* |
430
|
|
|
* @param int $min The minimum number of confirmations the transaction containing an output must |
431
|
|
|
* have in order to be returned. Use 0 to return outputs from unconfirmed transactions. |
432
|
|
|
* Default is 1 |
433
|
|
|
* @param int $max The maximum number of confirmations the transaction containing an output may |
434
|
|
|
* have in order to be returned. Default is 9999999 (~10 million) |
435
|
|
|
* @param mixed $addresses either: |
436
|
|
|
* Addresses array Optional(0 or 1) If present, only outputs which pay an address |
437
|
|
|
* in this array will be returned |
438
|
|
|
* Address string Required(1 or more) A P2PKH or P2SH address |
439
|
|
|
* @return mixed |
440
|
|
|
*/ |
441
|
|
|
public function listUnspent($min = 1,$max = 9999999,$addresses) |
442
|
|
|
{ |
443
|
|
|
return $this->send('listunspent',[$min,$max,$addresses]); |
444
|
|
|
} |
445
|
|
|
|
446
|
|
|
/** |
447
|
|
|
* The lockunspent RPC temporarily locks or unlocks specified transaction outputs. A locked |
448
|
|
|
* transaction output will not be chosen by automatic coin selection when spending bitcoins. |
449
|
|
|
* Locks are stored in memory only, so nodes start with zero locked outputs and the locked |
450
|
|
|
* output list is always cleared when a node stops or fails. |
451
|
|
|
* |
452
|
|
|
* @param bool $unlock Set to false to lock the outputs specified in the following parameter. |
453
|
|
|
* Set to true to unlock the outputs specified. If this is the only argument specified and |
454
|
|
|
* it is set to true, all outputs will be unlocked; if it is the only argument and is set |
455
|
|
|
* to false, there will be no change |
456
|
|
|
* @param mixed $outputs either : |
457
|
|
|
* Outputs array Optional(0 or 1) An array of outputs to lock or unlock |
458
|
|
|
* Output object Required(1 or more) An object describing a particular output |
459
|
|
|
* txid string Required(exactly 1) The TXID of the transaction containing the output |
460
|
|
|
* to lock or unlock, encoded as hex in internal |
461
|
|
|
* byte order |
462
|
|
|
* vout int Required(exactly 1) The output index number (vout) of the output to |
463
|
|
|
* lock or unlock. The first output in a transaction |
464
|
|
|
* has an index of 0 |
465
|
|
|
* @return mixed |
466
|
|
|
*/ |
467
|
|
|
public function lockUnspent($unlock,$outputs) |
468
|
|
|
{ |
469
|
|
|
return $this->send('lockunspent',[$unlock,$outputs]); |
470
|
|
|
} |
471
|
|
|
|
472
|
|
|
/** |
473
|
|
|
* The move RPC moves a specified amount from one account in your wallet to another using |
474
|
|
|
* an off-block-chain transaction. |
475
|
|
|
* |
476
|
|
|
* @param string $from The name of the account to move the funds from |
477
|
|
|
* @param string $to The name of the account to move the funds to |
478
|
|
|
* @param float $amount The amount of bitcoins to move |
479
|
|
|
* @param string $comment A comment to assign to this move payment |
480
|
|
|
* @return mixed |
481
|
|
|
*/ |
482
|
|
|
public function move($from,$to,$amount,$comment = '') |
483
|
|
|
{ |
484
|
|
|
return $this->send('move',[$from,$to,$amount,null,$comment]); |
485
|
|
|
} |
486
|
|
|
|
487
|
|
|
/** |
488
|
|
|
* The sendfrom RPC spends an amount from a local account to a bitcoin address. |
489
|
|
|
* |
490
|
|
|
* @param string $from The name of the account from which the bitcoins should be spent. Use |
491
|
|
|
* an empty string (“”) for the default account |
492
|
|
|
* @param string $to A P2PKH or P2SH address to which the bitcoins should be sent |
493
|
|
|
* @param float $amount The amount to spend in bitcoins. Bitcoin Core will ensure the |
494
|
|
|
* account has sufficient bitcoins to pay this amount (but the transaction fee paid is |
495
|
|
|
* not included in the calculation, so an account can spend a total of its balance plus |
496
|
|
|
* the transaction fee) |
497
|
|
|
* @param int $confirmations The minimum number of confirmations an incoming transaction |
498
|
|
|
* must have for its outputs to be credited to this account’s balance. Outgoing transactions |
499
|
|
|
* are always counted, as are move transactions made with the move RPC. If an account doesn’t |
500
|
|
|
* have a balance high enough to pay for this transaction, the payment will be rejected. |
501
|
|
|
* Use 0 to spend unconfirmed incoming payments. Default is 1 |
502
|
|
|
* |
503
|
|
|
* Warning: if account1 receives an unconfirmed payment and transfers it to account2 with |
504
|
|
|
* the move RPC, account2 will be able to spend those bitcoins even if this parameter is |
505
|
|
|
* set to 1 or higher. |
506
|
|
|
* |
507
|
|
|
* @param string $comment A locally-stored (not broadcast) comment assigned to this |
508
|
|
|
* transaction. Default is no comment |
509
|
|
|
* @param string $comment_to A locally-stored (not broadcast) comment assigned to this |
510
|
|
|
* transaction. Meant to be used for describing who the payment was sent to. Default |
511
|
|
|
* is no comment |
512
|
|
|
* @return mixed |
513
|
|
|
*/ |
514
|
|
|
public function sendFrom($from,$to,$amount,$confirmations = 1,$comment = '',$comment_to = '') |
515
|
|
|
{ |
516
|
|
|
return $this->send('sendfrom',[$from,$to,$amount,$confirmations,$comment,$comment_to]); |
517
|
|
|
} |
518
|
|
|
|
519
|
|
|
/** |
520
|
|
|
* The sendmany RPC creates and broadcasts a transaction which sends outputs |
521
|
|
|
* to multiple addresses. |
522
|
|
|
* |
523
|
|
|
* @param string $from The name of the account from which the bitcoins should be spent. |
524
|
|
|
* Use an empty string (“”) for the default account. Bitcoin Core will ensure the account |
525
|
|
|
* has sufficient bitcoins to pay the total amount in the outputs field described below |
526
|
|
|
* (but the transaction fee paid is not included in the calculation, so an account can |
527
|
|
|
* spend a total of its balance plus the transaction fee) |
528
|
|
|
* @param mixed $ouputs either: |
529
|
|
|
* Outputs object Required(exactly 1) An object containing key/value pairs |
530
|
|
|
* corresponding to the addresses and amounts to pay |
531
|
|
|
* Address/Amount string (base58) : number (bitcoins) Required(1 or more) |
532
|
|
|
* A key/value pair with a base58check-encoded string |
533
|
|
|
* containing the P2PKH or P2SH address to pay as the |
534
|
|
|
* key, and an amount of bitcoins to pay as the value |
535
|
|
|
* @param int $confirmations The minimum number of confirmations an incoming transaction |
536
|
|
|
* must have for its outputs to be credited to this account’s balance. Outgoing |
537
|
|
|
* transactions are always counted, as are move transactions made with the move RPC. |
538
|
|
|
* If an account doesn’t have a balance high enough to pay for this transaction, the |
539
|
|
|
* payment will be rejected. Use 0 to spend unconfirmed incoming payments. Default is 1 |
540
|
|
|
* |
541
|
|
|
* Warning: if account1 receives an unconfirmed payment and transfers it to account2 with |
542
|
|
|
* the move RPC, account2 will be able to spend those bitcoins even if this parameter is |
543
|
|
|
* set to 1 or higher. |
544
|
|
|
* |
545
|
|
|
* @param string $comment A locally-stored (not broadcast) comment assigned to this |
546
|
|
|
* transaction. Default is no comment |
547
|
|
|
* @return mixed |
548
|
|
|
*/ |
549
|
|
|
public function sendMany($from,$ouputs,$confirmations = 1,$comment = '') |
550
|
|
|
{ |
551
|
|
|
return $this->send('sendmany',[$from,$ouputs,$confirmations,$comment]); |
552
|
|
|
} |
553
|
|
|
|
554
|
|
|
/** |
555
|
|
|
* The sendtoaddress RPC spends an amount to a given address. |
556
|
|
|
* |
557
|
|
|
* @param string $to A P2PKH or P2SH address to which the bitcoins should be sent |
558
|
|
|
* @param float $amount The amount to spent in bitcoins |
559
|
|
|
* @param string $comment A locally-stored (not broadcast) comment assigned to |
560
|
|
|
* this transaction. Default is no comment |
561
|
|
|
* @param string $comment_to A locally-stored (not broadcast) comment assigned to |
562
|
|
|
* this transaction. Meant to be used for describing who the payment was sent to. |
563
|
|
|
* Default is no comment |
564
|
|
|
* @return mixed |
565
|
|
|
*/ |
566
|
|
|
public function sendToAddress($to,$amount,$comment = '', $comment_to = '') |
567
|
|
|
{ |
568
|
|
|
return $this->send('sendtoaddress',[$to,$amount,$comment,$comment_to]); |
569
|
|
|
} |
570
|
|
|
|
571
|
|
|
/** |
572
|
|
|
* The setaccount RPC puts the specified address in the given account. |
573
|
|
|
* |
574
|
|
|
* @param string $address The P2PKH or P2SH address to put in the account. |
575
|
|
|
* Must already belong to the wallet |
576
|
|
|
* @param string $account The name of the account in which the address should |
577
|
|
|
* be placed. May be the default account, an empty string (“”) |
578
|
|
|
* @return mixed |
579
|
|
|
*/ |
580
|
|
|
public function setAccount($address,$account) |
581
|
|
|
{ |
582
|
|
|
return $this->send('setaccount',[$address,$account]); |
583
|
|
|
} |
584
|
|
|
|
585
|
|
|
/** |
586
|
|
|
* The settxfee RPC sets the transaction fee per kilobyte paid by transactions |
587
|
|
|
* created by this wallet. |
588
|
|
|
* |
589
|
|
|
* @param float $fee The transaction fee to pay, in bitcoins, for each kilobyte |
590
|
|
|
* of transaction data. Be careful setting the fee too low—your transactions |
591
|
|
|
* may not be relayed or included in blocks |
592
|
|
|
* @return mixed |
593
|
|
|
*/ |
594
|
|
|
public function setTxFee($fee) |
595
|
|
|
{ |
596
|
|
|
return $this->send('settxfee',[$fee]); |
597
|
|
|
} |
598
|
|
|
|
599
|
|
|
/** |
600
|
|
|
* The signmessage RPC signs a message with the private key of an address. |
601
|
|
|
* |
602
|
|
|
* @param string $address A P2PKH address whose private key belongs to this wallet |
603
|
|
|
* @param string $message The message to sign |
604
|
|
|
* @return mixed |
605
|
|
|
*/ |
606
|
|
|
public function signMessage($address,$message) |
607
|
|
|
{ |
608
|
|
|
return $this->send('signmessage',[$address,$message]); |
609
|
|
|
} |
610
|
|
|
|
611
|
|
|
/** |
612
|
|
|
* The walletlock RPC removes the wallet encryption key from memory, locking the |
613
|
|
|
* wallet. After calling this method, you will need to call walletpassphrase again |
614
|
|
|
* before being able to call any methods which require the wallet to be unlocked. |
615
|
|
|
* |
616
|
|
|
* @return mixed |
617
|
|
|
*/ |
618
|
|
|
public function walletLock() |
619
|
|
|
{ |
620
|
|
|
return $this->send('walletlock'); |
621
|
|
|
} |
622
|
|
|
|
623
|
|
|
/** |
624
|
|
|
* The walletpassphrase RPC stores the wallet decryption key in memory for the |
625
|
|
|
* indicated number of seconds. Issuing the walletpassphrase command while the wallet |
626
|
|
|
* is already unlocked will set a new unlock time that overrides the old one. |
627
|
|
|
* |
628
|
|
|
* Warning: if using this RPC on the command line, remember that your shell probably |
629
|
|
|
* saves your command lines (including the value of the passphrase parameter). |
630
|
|
|
* |
631
|
|
|
* @param string $passphrase The passphrase that unlocks the wallet |
632
|
|
|
* @param int $seconds The number of seconds after which the decryption key will be |
633
|
|
|
* automatically deleted from memory |
634
|
|
|
* @return mixed |
635
|
|
|
*/ |
636
|
|
|
public function walletPassphrase($passphrase,$seconds) |
637
|
|
|
{ |
638
|
|
|
return $this->send('walletpassphrase',[$passphrase,$seconds]); |
639
|
|
|
} |
640
|
|
|
|
641
|
|
|
/** |
642
|
|
|
* The walletpassphrasechange RPC changes the wallet passphrase from |
643
|
|
|
* ‘old passphrase’ to ‘new passphrase’. |
644
|
|
|
* |
645
|
|
|
* Warning: if using this RPC on the command line, remember that your shell probably |
646
|
|
|
* saves your command lines (including the value of the passphrase parameter). |
647
|
|
|
* |
648
|
|
|
* @param string $current The current wallet passphrase |
649
|
|
|
* @param string $new The new passphrase for the wallet |
650
|
|
|
* @return mixed |
651
|
|
|
*/ |
652
|
|
|
public function walletPassphraseChange($current,$new) |
653
|
|
|
{ |
654
|
|
|
return $this->send('walletpassphrasechange',[$current,$new]); |
655
|
|
|
} |
656
|
|
|
} |