Skip to content

Commit

Permalink
feat: add helpers with common consensus-related code for spending con…
Browse files Browse the repository at this point in the history
…ditions
  • Loading branch information
troggy committed Jun 15, 2019
1 parent 4dfe4ea commit b08b0ec
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lib/consensus/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import spendingCondition from './spendingCondition';

export default { spendingCondition };
12 changes: 12 additions & 0 deletions lib/consensus/spendingCondition.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { ripemd160, keccak256 } from 'ethereumjs-util';

const getScriptHash = script =>
ripemd160(keccak256(script.length), keccak256(script));

const getAddress = script =>
`0x${getScriptHash(script).toString('hex')}`;

export default {
getScriptHash,
getAddress,
};
2 changes: 2 additions & 0 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,5 @@ export { default as Output } from './output';
export { default as Outpoint } from './outpoint';
export { default as Util } from './util';
export { default as Exit } from './exit';

export { default as Consensus } from './consensus/';

0 comments on commit b08b0ec

Please sign in to comment.