mirror of
https://github.com/ElementsProject/elements.git
synced 2026-08-14 12:43:40 +02:00
Use Elements PSBT magic when in Elements mode
Elements PSBTs are incompatible with normal PSBTs due to differing transaction formats, so use different magic bytes to distinguish.
This commit is contained in:
parent
3fa355c767
commit
34e1350114
1 changed files with 13 additions and 3 deletions
16
src/psbt.h
16
src/psbt.h
|
|
@ -665,7 +665,11 @@ struct PartiallySignedTransaction
|
|||
inline void Serialize(Stream& s) const {
|
||||
|
||||
// magic bytes
|
||||
s << PSBT_MAGIC_BYTES;
|
||||
if (g_con_elementsmode) {
|
||||
s << PSBT_ELEMENTS_MAGIC_BYTES;
|
||||
} else {
|
||||
s << PSBT_MAGIC_BYTES;
|
||||
}
|
||||
|
||||
// unsigned tx flag
|
||||
SerializeToVector(s, PSBT_GLOBAL_UNSIGNED_TX);
|
||||
|
|
@ -699,8 +703,14 @@ struct PartiallySignedTransaction
|
|||
// Read the magic bytes
|
||||
uint8_t magic[5];
|
||||
s >> magic;
|
||||
if (!std::equal(magic, magic + 5, PSBT_MAGIC_BYTES)) {
|
||||
throw std::ios_base::failure("Invalid PSBT magic bytes");
|
||||
if (g_con_elementsmode) {
|
||||
if (!std::equal(magic, magic + 5, PSBT_ELEMENTS_MAGIC_BYTES)) {
|
||||
throw std::ios_base::failure("Invalid PSBT magic bytes");
|
||||
}
|
||||
} else {
|
||||
if (!std::equal(magic, magic + 5, PSBT_MAGIC_BYTES)) {
|
||||
throw std::ios_base::failure("Invalid PSBT magic bytes");
|
||||
}
|
||||
}
|
||||
|
||||
// Read global data
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue