Rename Payload::as_bytes to inner_prog_as_bytes
Also make it private
This commit is contained in:
parent
a446df583c
commit
44d3ec487d
|
@ -537,8 +537,9 @@ impl Payload {
|
||||||
Payload::WitnessProgram(prog)
|
Payload::WitnessProgram(prog)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns a byte slice of the payload
|
/// Returns a byte slice of the inner program of the payload. If the payload
|
||||||
pub fn as_bytes(&self) -> &[u8] {
|
/// is a script hash or pubkey hash, a reference to the hash is returned.
|
||||||
|
fn inner_prog_as_bytes(&self) -> &[u8] {
|
||||||
match self {
|
match self {
|
||||||
Payload::ScriptHash(hash) => hash.as_ref(),
|
Payload::ScriptHash(hash) => hash.as_ref(),
|
||||||
Payload::PubkeyHash(hash) => hash.as_ref(),
|
Payload::PubkeyHash(hash) => hash.as_ref(),
|
||||||
|
@ -930,7 +931,7 @@ impl Address {
|
||||||
/// given key. For taproot addresses, the supplied key is assumed to be tweaked
|
/// given key. For taproot addresses, the supplied key is assumed to be tweaked
|
||||||
pub fn is_related_to_pubkey(&self, pubkey: &PublicKey) -> bool {
|
pub fn is_related_to_pubkey(&self, pubkey: &PublicKey) -> bool {
|
||||||
let pubkey_hash = pubkey.pubkey_hash();
|
let pubkey_hash = pubkey.pubkey_hash();
|
||||||
let payload = self.payload.as_bytes();
|
let payload = self.payload.inner_prog_as_bytes();
|
||||||
let xonly_pubkey = XOnlyPublicKey::from(pubkey.inner);
|
let xonly_pubkey = XOnlyPublicKey::from(pubkey.inner);
|
||||||
|
|
||||||
(*pubkey_hash.as_ref() == *payload)
|
(*pubkey_hash.as_ref() == *payload)
|
||||||
|
@ -943,7 +944,7 @@ impl Address {
|
||||||
/// This will only work for Taproot addresses. The Public Key is
|
/// This will only work for Taproot addresses. The Public Key is
|
||||||
/// assumed to have already been tweaked.
|
/// assumed to have already been tweaked.
|
||||||
pub fn is_related_to_xonly_pubkey(&self, xonly_pubkey: &XOnlyPublicKey) -> bool {
|
pub fn is_related_to_xonly_pubkey(&self, xonly_pubkey: &XOnlyPublicKey) -> bool {
|
||||||
let payload = self.payload.as_bytes();
|
let payload = self.payload.inner_prog_as_bytes();
|
||||||
payload == xonly_pubkey.serialize()
|
payload == xonly_pubkey.serialize()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue