| 85 | } |
| 86 | |
| 87 | bool cn::extra::is_valid(const BinaryArray &extra) { |
| 88 | try { |
| 89 | common::MemoryInputStream iss(extra.data(), extra.size()); |
| 90 | |
| 91 | while (!iss.empty()) { |
| 92 | int c = iss.read_byte(); |
| 93 | if (c == extra::Padding::tag) |
| 94 | return true; // last field |
| 95 | if (c == extra::TransactionPublicKey::tag) { |
| 96 | extra::TransactionPublicKey value; |
| 97 | iss.read(value.public_key.data, sizeof(value.public_key.data)); |
| 98 | continue; |
| 99 | } |
| 100 | // other tags have uniform format |
| 101 | BinaryArray field_data; |
| 102 | auto size = iss.read_varint<size_t>(); |
| 103 | iss.read(field_data, size); |
| 104 | } |
| 105 | return true; |
| 106 | } catch (std::exception &) { |
| 107 | } |
| 108 | return false; |
| 109 | } |
| 110 | |
| 111 | void cn::extra::add_transaction_public_key(BinaryArray &tx_extra, const PublicKey &tx_pub_key) { |
| 112 | tx_extra.push_back(TransactionPublicKey::tag); |