From 651218419088df8b760daa830d1d06fd059e25d2 Mon Sep 17 00:00:00 2001 From: Dave Collins Date: Sat, 24 Feb 2018 20:43:00 -0600 Subject: [PATCH] chaingen: Export vote commitment script function. This exports the VoteCommitmentScript function so callers can make use of it to create new vote commitment scripts. --- blockchain/chaingen/generator.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/blockchain/chaingen/generator.go b/blockchain/chaingen/generator.go index 07a9a99f..f0378054 100644 --- a/blockchain/chaingen/generator.go +++ b/blockchain/chaingen/generator.go @@ -533,10 +533,10 @@ func isRevocationTx(tx *wire.MsgTx) bool { return scriptClass == txscript.StakeRevocationTy } -// voteBlockScript returns a standard provably-pruneable OP_RETURN script +// VoteCommitmentScript returns a standard provably-pruneable OP_RETURN script // suitable for use in a vote tx (ssgen) given the block hash and height to vote // on. -func voteCommitmentScript(hash chainhash.Hash, height uint32) []byte { +func VoteCommitmentScript(hash chainhash.Hash, height uint32) []byte { // The vote commitment consists of a 32-byte hash of the block it is // voting on along with its expected height as a 4-byte little-endian // uint32. 32-byte hash + 4-byte uint32 = 36 bytes. @@ -554,7 +554,7 @@ func voteCommitmentScript(hash chainhash.Hash, height uint32) []byte { // voteBlockScript returns a standard provably-pruneable OP_RETURN script // suitable for use in a vote tx (ssgen) given the block to vote on. func voteBlockScript(parentBlock *wire.MsgBlock) []byte { - return voteCommitmentScript(parentBlock.BlockHash(), + return VoteCommitmentScript(parentBlock.BlockHash(), parentBlock.Header.Height) } @@ -1825,7 +1825,7 @@ func updateVoteCommitments(block *wire.MsgBlock) { continue } - stx.TxOut[0].PkScript = voteCommitmentScript(block.Header.PrevBlock, + stx.TxOut[0].PkScript = VoteCommitmentScript(block.Header.PrevBlock, block.Header.Height-1) } }