@multiplechain/bitcoin 0.1.16 → 0.1.18
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 new Promise(r => setTimeout(r, (timer*1000)));
|
|
121
122
|
|
|
122
|
-
|
|
123
|
+
await this.getData();
|
|
123
124
|
|
|
124
|
-
|
|
125
|
+
let result = null;
|
|
125
126
|
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
if (this.data.status.block_height) {
|
|
130
|
-
result = true;
|
|
131
|
-
}
|
|
132
|
-
}
|
|
127
|
+
if (this.data && this.data.status.block_height) {
|
|
128
|
+
result = true;
|
|
129
|
+
}
|
|
133
130
|
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
clearInterval(this.intervalValidate);
|
|
148
|
-
reject(error);
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
}, (this.timer*1000));
|
|
152
|
-
});
|
|
131
|
+
if (typeof result == 'boolean') {
|
|
132
|
+
return result;
|
|
133
|
+
}
|
|
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;
|