-
Notifications
You must be signed in to change notification settings - Fork 100
Labels
bugSomething isn't workingSomething isn't working
Description
Support for parsing v5 transactions (as specified in ZIP 225) was added in #367. However, the txid computation for v5 transactions (as specified in ZIP 244) was not implemented. This means that at present, lightwalletd returns incorrect txids for v5 transactions in compact blocks:
Lines 261 to 274 in ab4c0fe
| block := parser.NewBlock() | |
| rest, err := block.ParseFromSlice(blockData) | |
| if err != nil { | |
| return nil, errors.Wrap(err, "error parsing block") | |
| } | |
| if len(rest) != 0 { | |
| return nil, errors.New("received overlong message") | |
| } | |
| if block.GetHeight() != height { | |
| return nil, errors.New("received unexpected height block") | |
| } | |
| return block.ToCompact(), nil |
Lines 108 to 127 in ab4c0fe
| // ToCompact returns the compact representation of the full block. | |
| func (b *Block) ToCompact() *walletrpc.CompactBlock { | |
| compactBlock := &walletrpc.CompactBlock{ | |
| //TODO ProtoVersion: 1, | |
| Height: uint64(b.GetHeight()), | |
| PrevHash: b.hdr.HashPrevBlock, | |
| Hash: b.GetEncodableHash(), | |
| Time: b.hdr.Time, | |
| } | |
| // Only Sapling transactions have a meaningful compact encoding | |
| saplingTxns := make([]*walletrpc.CompactTx, 0, len(b.vtx)) | |
| for idx, tx := range b.vtx { | |
| if tx.HasShieldedElements() { | |
| saplingTxns = append(saplingTxns, tx.ToCompact(idx)) | |
| } | |
| } | |
| compactBlock.Vtx = saplingTxns | |
| return compactBlock | |
| } |
lightwalletd/parser/transaction.go
Lines 379 to 383 in ab4c0fe
| // ToCompact converts the given (full) transaction to compact format. | |
| func (tx *Transaction) ToCompact(index int) *walletrpc.CompactTx { | |
| ctx := &walletrpc.CompactTx{ | |
| Index: uint64(index), // index is contextual | |
| Hash: tx.GetEncodableHash(), |
lightwalletd/parser/transaction.go
Lines 346 to 365 in ab4c0fe
| // GetDisplayHash returns the transaction hash in big-endian display order. | |
| func (tx *Transaction) GetDisplayHash() []byte { | |
| if tx.cachedTxID != nil { | |
| return tx.cachedTxID | |
| } | |
| // SHA256d | |
| digest := sha256.Sum256(tx.rawBytes) | |
| digest = sha256.Sum256(digest[:]) | |
| // Convert to big-endian | |
| tx.cachedTxID = Reverse(digest[:]) | |
| return tx.cachedTxID | |
| } | |
| // GetEncodableHash returns the transaction hash in little-endian wire format order. | |
| func (tx *Transaction) GetEncodableHash() []byte { | |
| digest := sha256.Sum256(tx.rawBytes) | |
| digest = sha256.Sum256(digest[:]) | |
| return digest[:] | |
| } |
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working