fix: use var_str in 'reject' msgs
CommandString is (de)serialized as 12 bytes. However, BIP-61 defines the 'response-to-msg' (message that triggered the reject) field to be a var_str [1]. [1]: https://github.com/bitcoin/bips/blob/master/bip-0061.mediawiki#common-payload
This commit is contained in:
parent
cb4d34fd40
commit
fc572aba86
|
@ -472,7 +472,7 @@ mod test {
|
||||||
NetworkMessage::GetCFCheckpt(GetCFCheckpt{filter_type: 17, stop_hash: hash([25u8; 32]).into()}),
|
NetworkMessage::GetCFCheckpt(GetCFCheckpt{filter_type: 17, stop_hash: hash([25u8; 32]).into()}),
|
||||||
NetworkMessage::CFCheckpt(CFCheckpt{filter_type: 27, stop_hash: hash([77u8; 32]).into(), filter_headers: vec![hash([3u8; 32]).into(), hash([99u8; 32]).into()]}),
|
NetworkMessage::CFCheckpt(CFCheckpt{filter_type: 27, stop_hash: hash([77u8; 32]).into(), filter_headers: vec![hash([3u8; 32]).into(), hash([99u8; 32]).into()]}),
|
||||||
NetworkMessage::Alert(vec![45,66,3,2,6,8,9,12,3,130]),
|
NetworkMessage::Alert(vec![45,66,3,2,6,8,9,12,3,130]),
|
||||||
NetworkMessage::Reject(Reject{message: CommandString::try_from("Test reject").unwrap(), ccode: RejectReason::Duplicate, reason: "Cause".into(), hash: hash([255u8; 32])}),
|
NetworkMessage::Reject(Reject{message: "Test reject".into(), ccode: RejectReason::Duplicate, reason: "Cause".into(), hash: hash([255u8; 32])}),
|
||||||
NetworkMessage::FeeFilter(1000),
|
NetworkMessage::FeeFilter(1000),
|
||||||
NetworkMessage::WtxidRelay,
|
NetworkMessage::WtxidRelay,
|
||||||
NetworkMessage::AddrV2(vec![AddrV2Message{ addr: AddrV2::Ipv4(Ipv4Addr::new(127, 0, 0, 1)), port: 0, services: ServiceFlags::NONE, time: 0 }]),
|
NetworkMessage::AddrV2(vec![AddrV2Message{ addr: AddrV2::Ipv4(Ipv4Addr::new(127, 0, 0, 1)), port: 0, services: ServiceFlags::NONE, time: 0 }]),
|
||||||
|
|
|
@ -26,7 +26,6 @@ use network::address::Address;
|
||||||
use network::constants::{self, ServiceFlags};
|
use network::constants::{self, ServiceFlags};
|
||||||
use consensus::{Encodable, Decodable, ReadExt};
|
use consensus::{Encodable, Decodable, ReadExt};
|
||||||
use consensus::encode;
|
use consensus::encode;
|
||||||
use network::message::CommandString;
|
|
||||||
use hashes::sha256d;
|
use hashes::sha256d;
|
||||||
|
|
||||||
/// Some simple messages
|
/// Some simple messages
|
||||||
|
@ -133,7 +132,7 @@ impl Decodable for RejectReason {
|
||||||
#[derive(PartialEq, Eq, Clone, Debug)]
|
#[derive(PartialEq, Eq, Clone, Debug)]
|
||||||
pub struct Reject {
|
pub struct Reject {
|
||||||
/// message type rejected
|
/// message type rejected
|
||||||
pub message: CommandString,
|
pub message: Cow<'static, str>,
|
||||||
/// reason of rejection as code
|
/// reason of rejection as code
|
||||||
pub ccode: RejectReason,
|
pub ccode: RejectReason,
|
||||||
/// reason of rejectection
|
/// reason of rejectection
|
||||||
|
|
Loading…
Reference in New Issue