@multiplechain/bitcoin 0.1.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "namespace": "multiplechain",
3
3
  "name": "@multiplechain/bitcoin",
4
- "version": "0.1.0",
4
+ "version": "0.1.1",
5
5
  "description": "Bitcoin JS provider",
6
6
  "scripts": {
7
7
  "serve": "parcel test.html --no-cache --dist-dir test",
package/src/provider.js CHANGED
@@ -36,6 +36,13 @@ class Provider {
36
36
 
37
37
  let data = await fetch(apiUrl).then(res => res.json());
38
38
 
39
+ if (data.length == 0) {
40
+ return {
41
+ hash: null,
42
+ amount: 0
43
+ }
44
+ }
45
+
39
46
  if (data.txs) {
40
47
 
41
48
  let tx = data.txs[0];
@@ -166,11 +166,10 @@ class Transaction {
166
166
  }
167
167
 
168
168
  /**
169
- * @param {String} receiver
170
- * @param {Number} amount
169
+ * @param {Object} config
171
170
  * @returns {Boolean}
172
171
  */
173
- async verifyTransferWithData(receiver, amount) {
172
+ async verifyTransferWithData(config) {
174
173
 
175
174
  if (await this.validateTransaction()) {
176
175
 
@@ -178,7 +177,7 @@ class Transaction {
178
177
  if (this.provider.testnet) {
179
178
 
180
179
  let index = this.data.vout.findIndex(object => {
181
- return object.scriptpubkey_address == receiver;
180
+ return object.scriptpubkey_address == config.receiver;
182
181
  });
183
182
 
184
183
  data = this.data.vout[index];
@@ -190,7 +189,7 @@ class Transaction {
190
189
  } else {
191
190
 
192
191
  let index = this.data.out.findIndex(object => {
193
- return object.addr == receiver;
192
+ return object.addr == config.receiver;
194
193
  });
195
194
 
196
195
  data = this.data.out[index];
@@ -201,7 +200,7 @@ class Transaction {
201
200
  };
202
201
  }
203
202
 
204
- if (data.receiver == receiver && data.amount == amount) {
203
+ if (data.receiver == config.receiver && data.amount == config.amount) {
205
204
  return true;
206
205
  } else {
207
206
  return false;