[NOD-204] Add utxo commitment to get block template result (#316)

* [NOD-204] Add UTXOCommitment to GetBlockTemplateResult

* [NOD-204] Add UTXOCommitment to GetBlockTemplateResult
This commit is contained in:
Ori Newman 2019-05-30 16:59:26 +03:00 committed by Svarog
parent 8323e468da
commit 0bc6e5bc92
4 changed files with 8 additions and 1 deletions

View File

@ -143,6 +143,7 @@ type GetBlockTemplateResult struct {
SizeLimit int64 `json:"sizeLimit,omitempty"` SizeLimit int64 `json:"sizeLimit,omitempty"`
Transactions []GetBlockTemplateResultTx `json:"transactions"` Transactions []GetBlockTemplateResultTx `json:"transactions"`
AcceptedIDMerkleRoot string `json:"acceptedIdMerkleRoot"` AcceptedIDMerkleRoot string `json:"acceptedIdMerkleRoot"`
UTXOCommitment string `json:"utxoCommitment"`
Version int32 `json:"version"` Version int32 `json:"version"`
CoinbaseAux *GetBlockTemplateResultAux `json:"coinbaseAux,omitempty"` CoinbaseAux *GetBlockTemplateResultAux `json:"coinbaseAux,omitempty"`
CoinbaseTxn *GetBlockTemplateResultTx `json:"coinbaseTxn,omitempty"` CoinbaseTxn *GetBlockTemplateResultTx `json:"coinbaseTxn,omitempty"`

View File

@ -41,10 +41,14 @@ func parseBlock(template *btcjson.GetBlockTemplateResult) (*util.Block, error) {
if err != nil { if err != nil {
return nil, fmt.Errorf("Error parsing acceptedIDMerkleRoot: %s", err) return nil, fmt.Errorf("Error parsing acceptedIDMerkleRoot: %s", err)
} }
utxoCommitment, err := daghash.NewHashFromStr(template.UTXOCommitment)
if err != nil {
return nil, fmt.Errorf("Error parsing utxoCommitment: %s", err)
}
// parse rest of block // parse rest of block
msgBlock := wire.NewMsgBlock( msgBlock := wire.NewMsgBlock(
wire.NewBlockHeader(template.Version, parentHashes, &daghash.Hash{}, wire.NewBlockHeader(template.Version, parentHashes, &daghash.Hash{},
acceptedIDMerkleRoot, &daghash.Hash{}, uint32(bits), 0)) acceptedIDMerkleRoot, utxoCommitment, uint32(bits), 0))
for i, txResult := range append([]btcjson.GetBlockTemplateResultTx{*template.CoinbaseTxn}, template.Transactions...) { for i, txResult := range append([]btcjson.GetBlockTemplateResultTx{*template.CoinbaseTxn}, template.Transactions...) {
reader := hex.NewDecoder(strings.NewReader(txResult.Data)) reader := hex.NewDecoder(strings.NewReader(txResult.Data))

View File

@ -1807,6 +1807,7 @@ func (state *gbtWorkState) blockTemplateResult(useCoinbaseValue bool, submitOld
SizeLimit: wire.MaxBlockPayload, SizeLimit: wire.MaxBlockPayload,
Transactions: transactions, Transactions: transactions,
AcceptedIDMerkleRoot: header.AcceptedIDMerkleRoot.String(), AcceptedIDMerkleRoot: header.AcceptedIDMerkleRoot.String(),
UTXOCommitment: header.UTXOCommitment.String(),
Version: header.Version, Version: header.Version,
LongPollID: longPollID, LongPollID: longPollID,
SubmitOld: submitOld, SubmitOld: submitOld,

View File

@ -317,6 +317,7 @@ var helpDescsEnUS = map[string]string{
"getBlockTemplateResult-sizeLimit": "Number of bytes allowed in blocks", "getBlockTemplateResult-sizeLimit": "Number of bytes allowed in blocks",
"getBlockTemplateResult-transactions": "Array of transactions as JSON objects", "getBlockTemplateResult-transactions": "Array of transactions as JSON objects",
"getBlockTemplateResult-acceptedIdMerkleRoot": "The root of the merkle tree of transaction IDs accepted by this block", "getBlockTemplateResult-acceptedIdMerkleRoot": "The root of the merkle tree of transaction IDs accepted by this block",
"getBlockTemplateResult-utxoCommitment": "An ECMH UTXO commitment of this block",
"getBlockTemplateResult-version": "The block version", "getBlockTemplateResult-version": "The block version",
"getBlockTemplateResult-coinbaseAux": "Data that should be included in the coinbase signature script", "getBlockTemplateResult-coinbaseAux": "Data that should be included in the coinbase signature script",
"getBlockTemplateResult-coinbaseTxn": "Information about the coinbase transaction", "getBlockTemplateResult-coinbaseTxn": "Information about the coinbase transaction",