Distinguish between P2PKH and P2SH in UA test vectors

This commit is contained in:
str4d 2021-06-18 20:00:38 +01:00 committed by GitHub
parent 0392dd089c
commit 2c97e9a99a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 9 additions and 4 deletions

View File

@ -127,10 +127,11 @@ def main():
else:
orchard_raw_addr = None
is_p2pkh = rand.bool()
receivers = [
orchard_raw_addr,
sapling_raw_addr,
(rand.bool(), t_addr)
(is_p2pkh, t_addr)
]
ua = encode_unified(receivers)
@ -140,7 +141,8 @@ def main():
assert decoded.get('transparent') == t_addr
test_vectors.append({
't_addr_bytes': t_addr,
'p2pkh_bytes': t_addr if is_p2pkh else None,
'p2sh_bytes': None if is_p2pkh else t_addr,
'sapling_raw_addr': sapling_raw_addr,
'orchard_raw_addr': orchard_raw_addr,
'unified_addr': ua.encode()
@ -150,7 +152,11 @@ def main():
args,
'unified_address',
(
('t_addr_bytes', {
('p2pkh_bytes', {
'rust_type': 'Option<[u8; 20]>',
'rust_fmt': lambda x: None if x is None else Some(x),
}),
('p2sh_bytes', {
'rust_type': 'Option<[u8; 20]>',
'rust_fmt': lambda x: None if x is None else Some(x),
}),
@ -170,4 +176,3 @@ def main():
if __name__ == "__main__":
main()