Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Match Bitcoin Core utxo serialization #277

Open
dergoegge opened this issue Jun 21, 2021 · 1 comment
Open

Match Bitcoin Core utxo serialization #277

dergoegge opened this issue Jun 21, 2021 · 1 comment

Comments

@dergoegge
Copy link
Contributor

We should change the way we serialize utxos to match Bitcoin Core:

https://github.com/bitcoin/bitcoin/blob/398dd678338971d2189934713c83c184742f293f/src/coins.h#L60-L65

vs ours:

utreexo/btcacc/leaf.go

Lines 75 to 82 in 2faac6f

err = binary.Write(w, binary.BigEndian, hcb)
err = binary.Write(w, binary.BigEndian, l.Amt)
if len(l.PkScript) > 10000 {
err = fmt.Errorf("pksize too long")
return
}
err = binary.Write(w, binary.BigEndian, uint16(len(l.PkScript)))
_, err = w.Write(l.PkScript)

This has several benfits:

  • its easier to make the utcd node and Bitcoin Core bridge i am working on compatible.
  • saves bandwidth because of the compression that core uses
@kcalvinalvin
Copy link
Member

kcalvinalvin commented Jun 22, 2021

Sounds good but that does require varint encoding and unfortunately we can't import from utcd/btcd because that results in import cycles.

Two ways of going about this:

1: Move package btcacc/ into utcd/btcd
2: Copy over varint code from utcd/btcd

Requesting input from @adiabat

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants