-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
chainhash: add support to legacy-marshaled hashes #2025
Conversation
cc @Roasbeef - this would be helpful as the BitBoxApp stores json-marshalled transactions, which contain the |
chaincfg/chainhash/hash.go
Outdated
@@ -118,6 +118,12 @@ func (hash Hash) MarshalJSON() ([]byte, error) { | |||
|
|||
// UnmarshalJSON parses the hash with JSON appropriate string value. | |||
func (hash *Hash) UnmarshalJSON(input []byte) error { | |||
// If the fist byte indicates an array, the hash could have been marshalled |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typo first
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense, thanks for the fix. Should add a unit test case though.
Recent commits 1d6e578 and 72ea23e introduced a change in the way Hashes are serialized and deserialized. This change could cause errors in downstream applications that persisted hashes serialized using the previous methods. This introduces support for legacy-serialized hashes unmarshaling and restores the compatibility with previous versions.
2c35074
to
3627816
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 🎉
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 👑
Recent btcd updates changed the way hashes are serialized. We proposed a fix (see btcsuite/btcd#2025) to restore backward compatibility. This commit adds a specific test case to ensure that the newer and the legacy serialization methods work.
Recent btcd updates changed the way hashes are serialized. We proposed a fix (see btcsuite/btcd#2025) to restore backward compatibility. This commit adds a specific test case to ensure that the newer and the legacy serialization methods work.
Recent btcd updates changed the way hashes are serialized. We proposed a fix (see btcsuite/btcd#2025) to restore backward compatibility. This commit adds a specific test case to ensure that the newer and the legacy serialization methods work.
Recent btcd updates changed the way hashes are serialized. We proposed a fix (see btcsuite/btcd#2025) to restore backward compatibility. This commit adds a specific test case to ensure that the newer and the legacy serialization methods work.
Recent btcd updates changed the way hashes are serialized. We proposed a fix (see btcsuite/btcd#2025) to restore backward compatibility. This commit adds a specific test case to ensure that the newer and the legacy serialization methods work.
Recent btcd updates changed the way hashes are serialized. We proposed a fix (see btcsuite/btcd#2025) to restore backward compatibility. This commit adds a specific test case to ensure that the newer and the legacy serialization methods work.
Recent btcd updates changed the way hashes are serialized. We proposed a fix (see btcsuite/btcd#2025) to restore backward compatibility. This commit adds a specific test case to ensure that the newer and the legacy serialization methods work.
Recent commits 1d6e578 and 72ea23e introduced a change in the way Hashes are serialized and deserialized. This change could cause errors in downstream applications that persisted hashes serialized using the previous methods.
This introduces support for legacy-serialized hashes unmarshaling and restores the compatibility with previous versions.