-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathpegout-waiting-confirmation.js
More file actions
28 lines (24 loc) · 1.12 KB
/
pegout-waiting-confirmation.js
File metadata and controls
28 lines (24 loc) · 1.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
const ethUtils = require('ethereumjs-util');
const RLP = ethUtils.rlp;
const { BN } = ethUtils;
const { bufferToRskTxHashHex } = require('./hash-utils');
class PegoutWaitingConfirmation {
constructor(btcRawTx, pegoutCreationBlockNumber, rskTxHash) {
this.btcRawTx = btcRawTx;
this.pegoutCreationBlockNumber = pegoutCreationBlockNumber;
this.rskTxHash = rskTxHash;
}
}
const parseRLPToPegoutWaitingConfirmations = rlp => {
const rlpReleaseTransactionSet = RLP.decode(rlp);
const releaseTransactionSet = [];
for (let i = 0; i < rlpReleaseTransactionSet.length / 3; i++) {
const btcRawTx = rlpReleaseTransactionSet[i * 3].toString('hex');
const rskBlockNumber = new BN(rlpReleaseTransactionSet[i * 3 + 1]).toString();
const rskTxHashBuffer = rlpReleaseTransactionSet[i * 3 + 2];
const rskTxHash = bufferToRskTxHashHex(rskTxHashBuffer);
releaseTransactionSet.push(new PegoutWaitingConfirmation(btcRawTx, rskBlockNumber, rskTxHash));
}
return releaseTransactionSet;
};
exports.parseRLPToPegoutWaitingConfirmations = parseRLPToPegoutWaitingConfirmations;