<p>There is no mandatory ordering. If you assume your parser is correct, then it is fine to compare the objects themselves. However, to be sure everything is correct, I would suggest that you compare the serialized PSBTs themselves.</p>

CC BY-SA 4.0
2019-03-18T20:10:14.220Z
2019-03-18T20:10:14.220Z
Ava Chow
<p>When serializing a <a href="https://github.com/bitcoin/bips/blob/master/bip-0174.mediawiki" rel="nofollow noreferrer">PSBT</a> (BIP-174, Partially Signed Bitcoin Transaction), I cannot find any information if the keys should be ordered when serializing the PSBT?</p>

<p>Under the "Test Vectors" section for the BIP-174 in the last example it is only mentioned that:</p>

<blockquote>
  <p>A combiner which orders keys <em>lexicographically</em> must produce the
  following PSBT[...]</p>
</blockquote>

<p>But it does nowhere say that it is mandatory to order the keys. What is expected?</p>

<p>I am implementing test cases for a PSBT library and would like to know this to decide if I should compare the serialized PSBTs (where ordering does matter) or the objects themselves (regardless of ordering of keys). </p>

<bip174-psbt>
PSBT (BIP-174, Partially Signed Bitcoin Transaction) Ordering of keys
Bjarne Magnussen
# PSBT (BIP-174, Partially Signed Bitcoin Transaction) Ordering of keys

(Asked by: username_0 on 2019-03-18)

When serializing a [PSBT](https://github.com/bitcoin/bips/blob/master/bip-0174.mediawiki) (BIP-174, Partially Signed Bitcoin Transaction), I cannot find any information if the keys should be ordered when serializing the PSBT?

Under the "Test Vectors" section for the BIP-174 in the last example it is only mentioned that:

> A combiner which orders keys *lexicographically* must produce the
> following PSBT[...]

But it does nowhere say that it is mandatory to order the keys. What is expected?

I am implementing test cases for a PSBT library and would like to know this to decide if I should compare the serialized PSBTs (where ordering does matter) or the objects themselves (regardless of ordering of keys).

**Tags:** bip174-psbt


---

## 1 answers

### Answer by username_1 on 2019-03-18. Score: 3 | Accepted answer

There is no mandatory ordering. If you assume your parser is correct, then it is fine to compare the objects themselves. However, to be sure everything is correct, I would suggest that you compare the serialized PSBTs themselves.


---

