UNPKG

10.2 kBMarkdownView Raw
1Wallet Service
2======
3
4[![NPM Package](https://img.shields.io/npm/v/wallet-service.svg?style=flat-square)](https://www.npmjs.org/package/wallet-service)
5[![Build Status](https://img.shields.io/travis/owstack/wallet-service.svg?branch=master&style=flat-square)](https://travis-ci.org/owstack/wallet-service)
6[![Coverage Status](https://coveralls.io/repos/owstack/=wallet-service/badge.svg?branch=master)](https://coveralls.io/r/owstack/wallet-service?branch=master)
7
8A multisignature HD Bitcoin wallet service.
9
10# Description
11
12The wallet-service facilitates multisig HD wallets creation and operation through a (hopefully) simple and intuitive REST API.
13
14The wallet-service can usually be installed within minutes and accommodates all the needed infrastructure for peers in a multisig wallet to communicate and operate – with minimum server trust.
15
16See [wallet-client](https://github.com/owstack/wallet-client) for the client library that communicates to wallet-service and verifies its response. Also check [wallet-cli](https://github.com/owstack/wallet-cli) for a simple command line wallet implementation that relays on wallet-service.
17
18# Getting Started
19```
20 git clone https://github.com/owstack/wallet-service.git
21 cd wallet-service && npm start
22```
23
24This will launch the wallet-service (with default settings) at `http://localhost:3232/ws/api`.
25
26The wallet-sevice needs mongoDB. You can configure the connection at `config.js`
27
28The wallet-service supports SSL and Clustering. For a detailed guide on installing the wallet-service with extra features see [Installing Wallet Service](https://github.com/owstack/wallet-service/blob/master/installation.md).
29
30The wallet-service uses by default a Request Rate Limitation to CreateWallet endpoint. If you need to modify it, check defaults.js' `Defaults.RateLimit`
31
32# Security Considerations
33 * Private keys are never sent to the wallet-service, wallets store them locally.
34 * Extended public keys are stored on the wallet-service. This allows the wallet-service to easily check wallet balance, send offline notifications to copayers, etc.
35 * During wallet creation, the initial copayer creates a wallet secret that contains a private key. All copayers need to prove they have the secret by signing their information with this private key when joining the wallet. The secret should be shared using secured channels.
36 * A copayer could join the wallet more than once, and there is no mechanism to prevent this. See [wallet-cli](https://github.com/owstack/wallet-cli)'s confirm command, for a method for confirming copayers.
37 * All wallet-service responses are verified:
38 ** Addresses and change addresses are derived independently and locally by the copayers from their local data.
39 ** TX Proposals templates are signed by copayers and verified by others, so the wallet-service cannot create or tamper with them.
40
41# REST API
42## Authentication
43
44 In order to access a wallet, clients are required to send the headers:
45```
46 x-identity
47 x-signature
48```
49Identity is the Peer-ID, this will identify the peer and its wallet. Signature is the current request signature, using `requestSigningKey`, the `m/1/1` derivative of the Extended Private Key.
50
51See [Wallet Client](https://github.com/owstack/wallet-client/blob/master/lib/api.js) for implementation details.
52
53## GET Endpoints
54`/v1/wallets/`: Get wallet information
55
56Returns:
57 * Wallet object. (see [fields on the source code](https://github.com/owstack/wallet-service/blob/master/lib/model/wallet.js)).
58
59`/v1/txhistory/`: Get Wallet's transaction history
60
61Optional Arguments:
62 * skip: Records to skip from the result (defaults to 0)
63 * limit: Total number of records to return (return all available records if not specified).
64
65Returns:
66 * History of incoming and outgoing transactions of the wallet. The list is paginated using the `skip` & `limit` params. Each item has the following fields:
67 * action ('sent', 'received', 'moved')
68 * amount
69 * fees
70 * time
71 * addressTo
72 * confirmations
73 * proposalId
74 * creatorName
75 * message
76 * actions array ['createdOn', 'type', 'copayerId', 'copayerName', 'comment']
77
78
79`/v1/txproposals/`: Get Wallet's pending transaction proposals and their status
80Returns:
81 * List of pending TX Proposals. (see [fields on the source code](https://github.com/owstack/wallet-service/blob/master/lib/model/txproposal.js))
82
83`/v1/addresses/`: Get Wallet's main addresses (does not include change addresses)
84
85Returns:
86 * List of Addresses object: (https://github.com/owstack/wallet-service/blob/master/lib/model/address.js)). This call is mainly provided so the client check this addresses for incoming transactions (using a service like [Explorer](https://github.com/owstack/ows-explorer)
87
88`/v1/balance/`: Get Wallet's balance
89
90Returns:
91 * totalAmount: Wallet's total balance
92 * lockedAmount: Current balance of outstanding transaction proposals, that cannot be used on new transactions.
93 * availableAmount: Funds available for new proposals.
94 * totalConfirmedAmount: Same as totalAmount for confirmed UTXOs only.
95 * lockedConfirmedAmount: Same as lockedAmount for confirmed UTXOs only.
96 * availableConfirmedAmount: Same as availableAmount for confirmed UTXOs only.
97 * byAddress array ['address', 'path', 'amount']: A list of addresses holding funds.
98 * totalKbToSendMax: An estimation of the number of KiB required to include all available UTXOs in a tx (including unconfirmed).
99
100`/v1/txnotes/:txid`: Get user notes associated to the specified transaction.
101Returns:
102 * The note associated to the `txid` as a string.
103
104`/v1/fiatrates/:code`: Get the fiat rate for the specified ISO 4217 code.
105Optional Arguments:
106 * provider: An identifier representing the source of the rates.
107 * ts: The timestamp for the fiat rate (defaults to now).
108
109Returns:
110 * The fiat exchange rate.
111
112## POST Endpoints
113`/v1/wallets/`: Create a new Wallet
114
115 Required Arguments:
116 * name: Name of the wallet
117 * m: Number of required peers to sign transactions
118 * n: Number of total peers on the wallet
119 * pubKey: Wallet Creation Public key to check joining copayer's signatures (the private key is unknown by wallet-service and must be communicated
120 by the creator peer to other peers).
121
122Returns:
123 * walletId: Id of the new created wallet
124
125`/v1/wallets/:id/copayers/`: Join a Wallet in creation
126
127Required Arguments:
128 * walletId: Id of the wallet to join
129 * name: Copayer Name
130 * xPubKey - Extended Public Key for this copayer.
131 * requestPubKey - Public Key used to check requests from this copayer.
132 * copayerSignature - Signature used by other copayers to verify that the copayer joining knows the wallet secret.
133
134Returns:
135 * copayerId: Assigned ID of the copayer (to be used on x-identity header)
136 * wallet: Object with wallet's information
137
138`/v1/txproposals/`: Add a new transaction proposal
139
140Required Arguments:
141 * toAddress: RCPT Bitcoin address.
142 * amount: amount (in satoshis) of the mount proposed to be transfered
143 * proposalsSignature: Signature of the proposal by the creator peer, using prososalSigningKey.
144 * (opt) message: Encrypted private message to peers.
145 * (opt) payProUrl: Paypro URL for peers to verify TX
146 * (opt) feePerKb: Use an alternative fee per KB for this TX.
147 * (opt) excludeUnconfirmedUtxos: Do not use UTXOs of unconfirmed transactions as inputs for this TX.
148
149Returns:
150 * TX Proposal object. (see [fields on the source code](https://github.com/owstack/wallet-service/blob/master/lib/model/txproposal.js)). `.id` is probably needed in this case.
151
152`/v1/addresses/`: Request a new main address from wallet
153
154Returns:
155 * Address object: (https://github.com/owstack/wallet-service/blob/master/lib/model/address.js)). Note that `path` is returned so client can derive the address independently and check server's response.
156
157`/v1/txproposals/:id/signatures/`: Sign a transaction proposal
158
159Required Arguments:
160 * signatures: All Transaction's input signatures, in order of appearance.
161
162Returns:
163 * TX Proposal object. (see [fields on the source code](https://github.com/owstack/wallet-service/blob/master/lib/model/txproposal.js)). `.status` is probably needed in this case.
164
165`/v1/txproposals/:id/broadcast/`: Broadcast a transaction proposal
166
167Returns:
168 * TX Proposal object. (see [fields on the source code](https://github.com/owstack/wallet-service/blob/master/lib/model/txproposal.js)). `.status` is probably needed in this case.
169
170`/v1/txproposals/:id/rejections`: Reject a transaction proposal
171
172Returns:
173 * TX Proposal object. (see [fields on the source code](https://github.com/owstack/wallet-service/blob/master/lib/model/txproposal.js)). `.status` is probably needed in this case.
174
175`/v1/addresses/scan`: Start an address scan process looking for activity.
176
177 Optional Arguments:
178 * includeCopayerBranches: Scan all copayer branches following BIP45 recommendation (defaults to false).
179
180`/v1/txconfirmations/`: Subscribe to receive push notifications when the specified transaction gets confirmed.
181Required Arguments:
182 * txid: The transaction to subscribe to.
183
184## PUT Endpoints
185`/v1/txnotes/:txid/`: Modify a note for a tx.
186
187## DELETE Endpoints
188`/v1/txproposals/:id/`: Deletes a transaction proposal. Only the creator can delete a TX Proposal, and only if it has no other signatures or rejections
189
190 Returns:
191 * TX Proposal object. (see [fields on the source code](https://github.com/owstack/wallet-service/blob/master/lib/model/txproposal.js)). `.id` is probably needed in this case.
192
193`/v1/txconfirmations/:txid`: Unsubscribe from transaction `txid` and no longer listen to its confirmation.
194
195# Push Notifications
196 Recomended to complete config.js file:
197
198 * [GCM documentation to get your API key](https://developers.google.com/cloud-messaging/gcm)
199 * [Apple's Notification guide to know how to get your certificates for APN](https://developer.apple.com/library/ios/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/Chapters/Introduction.html)
200
201## POST Endpoints
202`/v1/pushnotifications/subscriptions/`: Adds subscriptions for push notifications service at database.
203
204## DELETE Endopints
205`/v1/pushnotifications/subscriptions/`: Remove subscriptions for push notifications service from database.