@multiplechain/bitcoin 0.1.16 → 0.1.17
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/dist/bitcoin-provider.js +1 -1
- package/package.json +1 -1
- package/src/entity/transaction.js +24 -33
package/package.json
CHANGED
|
@@ -114,42 +114,33 @@ class Transaction {
|
|
|
114
114
|
/**
|
|
115
115
|
* @returns {Boolean}
|
|
116
116
|
*/
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
117
|
+
async validate(timer = 1) {
|
|
118
|
+
timer = this.timer || timer;
|
|
119
|
+
try {
|
|
120
|
+
|
|
121
|
+
await this.getData();
|
|
121
122
|
|
|
122
|
-
|
|
123
|
+
let result = null;
|
|
123
124
|
|
|
124
|
-
|
|
125
|
+
if (this.data && this.data.status.block_height) {
|
|
126
|
+
result = true;
|
|
127
|
+
}
|
|
125
128
|
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
if (this.data.status.block_height) {
|
|
130
|
-
result = true;
|
|
131
|
-
}
|
|
132
|
-
}
|
|
129
|
+
if (typeof result == 'boolean') {
|
|
130
|
+
return result;
|
|
131
|
+
}
|
|
133
132
|
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
this.validateTransaction();
|
|
146
|
-
} else {
|
|
147
|
-
clearInterval(this.intervalValidate);
|
|
148
|
-
reject(error);
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
}, (this.timer*1000));
|
|
152
|
-
});
|
|
133
|
+
await new Promise(r => setTimeout(r, (timer*1000)));
|
|
134
|
+
|
|
135
|
+
return this.validate(timer);
|
|
136
|
+
} catch (error) {
|
|
137
|
+
|
|
138
|
+
if (error.message == 'There was a problem retrieving transaction data!') {
|
|
139
|
+
return this.validate(timer);
|
|
140
|
+
} else {
|
|
141
|
+
throw error;
|
|
142
|
+
}
|
|
143
|
+
}
|
|
153
144
|
}
|
|
154
145
|
|
|
155
146
|
/**
|
|
@@ -158,7 +149,7 @@ class Transaction {
|
|
|
158
149
|
*/
|
|
159
150
|
async verifyTransferWithData(config) {
|
|
160
151
|
|
|
161
|
-
if (await this.
|
|
152
|
+
if (await this.validate()) {
|
|
162
153
|
|
|
163
154
|
let index = this.data.vout.findIndex(object => {
|
|
164
155
|
return object.scriptpubkey_address == config.receiver;
|