Don't support signed messages with p2wpkh addresses

This commit is contained in:
Steven Roose 2020-10-14 15:38:11 +02:00
parent f7422fb8d1
commit 3f65fb1aed
No known key found for this signature in database
GPG Key ID: 2F2A88D7F8D68E87
1 changed files with 2 additions and 6 deletions

View File

@ -156,11 +156,7 @@ mod message_signing {
*address == Address::p2pkh(&pubkey, address.network) *address == Address::p2pkh(&pubkey, address.network)
} }
Some(AddressType::P2sh) => false, Some(AddressType::P2sh) => false,
Some(AddressType::P2wpkh) => { Some(AddressType::P2wpkh) => false,
// Only compressed pubkeys are allowed in p2wpkh.
pubkey.compressed &&
*address == Address::p2wpkh(&pubkey, address.network).expect("compressed pk")
}
Some(AddressType::P2wsh) => false, Some(AddressType::P2wsh) => false,
None => false, None => false,
}) })
@ -323,7 +319,7 @@ mod tests {
let p2pkh = ::Address::p2pkh(&pubkey, ::Network::Bitcoin); let p2pkh = ::Address::p2pkh(&pubkey, ::Network::Bitcoin);
assert_eq!(signature2.is_signed_by_address(&secp, &p2pkh, msg_hash), Ok(true)); assert_eq!(signature2.is_signed_by_address(&secp, &p2pkh, msg_hash), Ok(true));
let p2wpkh = ::Address::p2wpkh(&pubkey, ::Network::Bitcoin).unwrap(); let p2wpkh = ::Address::p2wpkh(&pubkey, ::Network::Bitcoin).unwrap();
assert_eq!(signature2.is_signed_by_address(&secp, &p2wpkh, msg_hash), Ok(true)); assert_eq!(signature2.is_signed_by_address(&secp, &p2wpkh, msg_hash), Ok(false));
let p2shwpkh = ::Address::p2shwpkh(&pubkey, ::Network::Bitcoin).unwrap(); let p2shwpkh = ::Address::p2shwpkh(&pubkey, ::Network::Bitcoin).unwrap();
assert_eq!(signature2.is_signed_by_address(&secp, &p2shwpkh, msg_hash), Ok(false)); assert_eq!(signature2.is_signed_by_address(&secp, &p2shwpkh, msg_hash), Ok(false));
} }