Created
April 16, 2020 11:31
-
-
Save pinheadmz/406c0d28751c969e46d4ed57823a26df to your computer and use it in GitHub Desktop.
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
const coin1 = { | |
"version": 0, | |
"height": 10301, | |
"value": 93228200, | |
"address": "hs1qe2wy3vz45ke42429jmmnv85ce5kcst080qd598", | |
"covenant": { | |
"type": 0, | |
"action": "NONE", | |
"items": [] | |
}, | |
"coinbase": false, | |
"hash": "c69ac24dfac03ef8a565ab5f31c53b278f97bd48004d6214d438380855ef8fc1", | |
"index": 4 | |
}; | |
const coin2 = { | |
"version": 0, | |
"height": 10267, | |
"value": 9716875, | |
"address": "hs1qx62ytdv87hmd4mkcrwyn0yj8pvkt2mvwnnrvk0", | |
"covenant": { | |
"type": 0, | |
"action": "NONE", | |
"items": [] | |
}, | |
"coinbase": false, | |
"hash": "ab13bf3e1e69579fa31301eaed6854ca065a6513c34ef19ce84cadc177fcfcd0", | |
"index": 0 | |
}; | |
const coin3 = { | |
"version": 0, | |
"height": 10342, | |
"value": 167462000, | |
"address": "hs1qcs7gpgdhu68wcnvp0m2d0etqlrn80p8k84akeh", | |
"covenant": { | |
"type": 0, | |
"action": "NONE", | |
"items": [] | |
}, | |
"coinbase": false, | |
"hash": "840e633c841dfb256d4d66530c679cf153653f90bbe0c6e4d19b36b7ac5ecc4a", | |
"index": 2 | |
}; | |
const rawtx = "0000000003840e633c841dfb256d4d66530c679cf153653f90bbe0c6e4d19b36b7ac5ecc4a02000000ffffffffab13bf3e1e69579fa31301eaed6854ca065a6513c34ef19ce84cadc177fcfcd000000000ffffffffc69ac24dfac03ef8a565ab5f31c53b278f97bd48004d6214d438380855ef8fc104000000ffffffff0231d12206000000000014e4a955ac0616d5f9737679a954b3884a7506790100007044fb09000000000014369445b587f5f6daeed81b893792470b2cb56d8e00000000000002410006b98d50eb071230b454fa298fe7273f25e6060cedfcbdbb88f9ccc7b26e2e59d60caa954de7471aead7cb67635121832f96207f22ba08f3ead4913bf8318f012103cfd4fa27bbf7815217c254bf525b190ad39d2ee6a1a118dacef38d6767055fb30241f6f33065a9df93e7dbd82d31fc91c9be32b96cbbbcb8e646542259730bb3be3b478598aa27c5f899fa90ae6bc06e71232a139249bf06fa32369ca83ab3f1ab090121037b43c1b9b7a4645e0a72721843142b71a51e839be55ac4ff038397546484e9f002411d4f12e24f05608abd6290c923ccb3962dea852321111ab79f1b0454fd2e55567047b59bb6fee829ca9ac166a51c0fdaf4884f67d89007073b768b146ccc9ae1012102720289fdcf63d856f714d38d81ef39b24cc43d994002ccc6f53114ea8b449d1a"; | |
const hsd = require('hsd'); | |
const view = new hsd.CoinView(); | |
view.addCoin(hsd.Coin.fromJSON(coin1)); | |
view.addCoin(hsd.Coin.fromJSON(coin2)); | |
view.addCoin(hsd.Coin.fromJSON(coin3)); | |
const tx = hsd.TX.fromRaw(Buffer.from(rawtx, 'hex')); | |
console.log('check', tx.check(view)); | |
console.log('stdinputs', tx.hasStandardInputs(view)); | |
const entry = hsd.MempoolEntry.fromTX(tx, view, 100); | |
console.log('min fee', hsd.policy.getMinFee(entry.size, 1000)); | |
console.log('tx fee', entry.fee); | |
console.log('is free', entry.isFree(100)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment