forked from michaeltout/VerusConnect
-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #266 from VerusCoin/dev
v1.2.5-3
- Loading branch information
Showing
17 changed files
with
399 additions
and
79 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
const { | ||
IdentitySignature, | ||
networks, | ||
} = require("@bitgo/utxo-lib"); | ||
|
||
module.exports = (api) => { | ||
/** | ||
* Gets the version, hashtype and height from a signature. | ||
* | ||
* @param {String} coin The chainTicker of the coin to make the call on | ||
* @param {String} systemId The iaddress of the system | ||
* @param {String} signature The signature to process | ||
* @param {String} iaddress The iaddress associated with the signature | ||
*/ | ||
api.getSignatureInfo = (coin, systemId, signature, iaddress) => { | ||
|
||
const network = coin == "VRSC" ? networks.verus : networks.verustest; | ||
|
||
const sig = new IdentitySignature(network); | ||
|
||
sig.fromBuffer(Buffer.from(signature, "base64"), 0, systemId, iaddress); | ||
|
||
return { | ||
version: sig.version, | ||
hashtype: sig.hashType, | ||
height: sig.blockHeight, | ||
}; | ||
} | ||
|
||
api.setPost('/lite/get_signature_info', (req, res, next) => { | ||
const { | ||
chainTicker, | ||
systemId, | ||
signature, | ||
iaddress | ||
} = req.body; | ||
|
||
try { | ||
res.send( | ||
JSON.stringify({ | ||
msg: "success", | ||
result: api.getSignatureInfo(chainTicker, systemId, signature, iaddress), | ||
}) | ||
); | ||
} catch (e) { | ||
res.send( | ||
JSON.stringify({ | ||
msg: "error", | ||
result: e.message, | ||
}) | ||
); | ||
} | ||
}); | ||
|
||
return api; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
module.exports = (api) => { | ||
/** | ||
* Gets the version, hashtype and height from a signature. | ||
* | ||
* @param {String} coin The chainTicker of the coin to make the call on | ||
* @param {String} hashorheight The block hash or height | ||
* @param {String} verbosity The verbosity of the result. 0 for hex encoded data, 1 for a json object, and 2 for json object with transaction data | ||
*/ | ||
api.native.get_block = ( | ||
coin, | ||
hashorheight, | ||
verbosity = 1, | ||
) => { | ||
return new Promise((resolve, reject) => { | ||
api.native | ||
.callDaemon( | ||
coin, | ||
"getblock", | ||
[ | ||
hashorheight, | ||
verbosity | ||
] | ||
) | ||
.then(resultObj => { | ||
resolve(resultObj) | ||
}) | ||
.catch(err => { | ||
reject(err); | ||
}); | ||
}); | ||
}; | ||
|
||
api.setPost('/native/get_block', (req, res, next) => { | ||
const { | ||
chainTicker, | ||
hashorheight, | ||
verbosity | ||
} = req.body; | ||
|
||
api.native | ||
.get_block( | ||
chainTicker, | ||
hashorheight, | ||
verbosity | ||
) | ||
.then(resultObj => { | ||
const retObj = { | ||
msg: "success", | ||
result: resultObj | ||
}; | ||
|
||
res.send(JSON.stringify(retObj)); | ||
}) | ||
.catch(error => { | ||
const retObj = { | ||
msg: "error", | ||
result: error.message | ||
}; | ||
|
||
res.send(JSON.stringify(retObj)); | ||
}); | ||
}); | ||
|
||
return api; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
const IS_TESTNET = false; | ||
|
||
module.exports = { | ||
IS_TESTNET | ||
} |
Oops, something went wrong.