compact blocks should include Orchard transactions

In previous commit, I forgot to include Orchard transactions in compact
blocks (so they will now include transactions with either Sapling or
Orchard transactions).
This commit is contained in:
Larry Ruane 2021-11-30 14:12:47 -07:00 committed by Larry Ruane
parent 4e1910aeea
commit c006cfe5fb
2 changed files with 6 additions and 5 deletions

View File

@ -62,7 +62,7 @@ func (b *Block) GetDisplayPrevHash() []byte {
// HasSaplingTransactions indicates if the block contains any Sapling tx.
func (b *Block) HasSaplingTransactions() bool {
for _, tx := range b.vtx {
if tx.HasSaplingElements() {
if tx.HasShieldedElements() {
return true
}
}
@ -118,7 +118,7 @@ func (b *Block) ToCompact() *walletrpc.CompactBlock {
// Only Sapling transactions have a meaningful compact encoding
saplingTxns := make([]*walletrpc.CompactTx, 0, len(b.vtx))
for idx, tx := range b.vtx {
if tx.HasSaplingElements() {
if tx.HasShieldedElements() {
saplingTxns = append(saplingTxns, tx.ToCompact(idx))
}
}

View File

@ -369,10 +369,11 @@ func (tx *Transaction) Bytes() []byte {
return tx.rawBytes
}
// HasSaplingElements indicates whether a transaction has
// HasShieldedElements indicates whether a transaction has
// at least one shielded input or output.
func (tx *Transaction) HasSaplingElements() bool {
return tx.version >= 4 && (len(tx.shieldedSpends)+len(tx.shieldedOutputs)) > 0
func (tx *Transaction) HasShieldedElements() bool {
nshielded := len(tx.shieldedSpends) + len(tx.shieldedOutputs) + len(tx.orchardActions)
return tx.version >= 4 && nshielded > 0
}
// ToCompact converts the given (full) transaction to compact format.