Remove needless references
This commit is contained in:
parent
16eb81e1f7
commit
3f2d428706
|
@ -658,29 +658,29 @@ impl fmt::Debug for All {
|
||||||
impl All {
|
impl All {
|
||||||
/// Classifies an Opcode into a broad class
|
/// Classifies an Opcode into a broad class
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn classify(&self) -> Class {
|
pub fn classify(self) -> Class {
|
||||||
// 17 opcodes
|
// 17 opcodes
|
||||||
if *self == all::OP_VERIF || *self == all::OP_VERNOTIF ||
|
if self == all::OP_VERIF || self == all::OP_VERNOTIF ||
|
||||||
*self == all::OP_CAT || *self == all::OP_SUBSTR ||
|
self == all::OP_CAT || self == all::OP_SUBSTR ||
|
||||||
*self == all::OP_LEFT || *self == all::OP_RIGHT ||
|
self == all::OP_LEFT || self == all::OP_RIGHT ||
|
||||||
*self == all::OP_INVERT || *self == all::OP_AND ||
|
self == all::OP_INVERT || self == all::OP_AND ||
|
||||||
*self == all::OP_OR || *self == all::OP_XOR ||
|
self == all::OP_OR || self == all::OP_XOR ||
|
||||||
*self == all::OP_2MUL || *self == all::OP_2DIV ||
|
self == all::OP_2MUL || self == all::OP_2DIV ||
|
||||||
*self == all::OP_MUL || *self == all::OP_DIV || *self == all::OP_MOD ||
|
self == all::OP_MUL || self == all::OP_DIV || self == all::OP_MOD ||
|
||||||
*self == all::OP_LSHIFT || *self == all::OP_RSHIFT {
|
self == all::OP_LSHIFT || self == all::OP_RSHIFT {
|
||||||
Class::IllegalOp
|
Class::IllegalOp
|
||||||
// 11 opcodes
|
// 11 opcodes
|
||||||
} else if *self == all::OP_NOP ||
|
} else if self == all::OP_NOP ||
|
||||||
(all::OP_NOP1.code <= self.code &&
|
(all::OP_NOP1.code <= self.code &&
|
||||||
self.code <= all::OP_NOP10.code) {
|
self.code <= all::OP_NOP10.code) {
|
||||||
Class::NoOp
|
Class::NoOp
|
||||||
// 75 opcodes
|
// 75 opcodes
|
||||||
} else if *self == all::OP_RESERVED || *self == all::OP_VER || *self == all::OP_RETURN ||
|
} else if self == all::OP_RESERVED || self == all::OP_VER || self == all::OP_RETURN ||
|
||||||
*self == all::OP_RESERVED1 || *self == all::OP_RESERVED2 ||
|
self == all::OP_RESERVED1 || self == all::OP_RESERVED2 ||
|
||||||
self.code >= all::OP_RETURN_186.code {
|
self.code >= all::OP_RETURN_186.code {
|
||||||
Class::ReturnOp
|
Class::ReturnOp
|
||||||
// 1 opcode
|
// 1 opcode
|
||||||
} else if *self == all::OP_PUSHNUM_NEG1 {
|
} else if self == all::OP_PUSHNUM_NEG1 {
|
||||||
Class::PushNum(-1)
|
Class::PushNum(-1)
|
||||||
// 16 opcodes
|
// 16 opcodes
|
||||||
} else if all::OP_PUSHNUM_1.code <= self.code &&
|
} else if all::OP_PUSHNUM_1.code <= self.code &&
|
||||||
|
@ -691,13 +691,13 @@ impl All {
|
||||||
Class::PushBytes(self.code as u32)
|
Class::PushBytes(self.code as u32)
|
||||||
// 60 opcodes
|
// 60 opcodes
|
||||||
} else {
|
} else {
|
||||||
Class::Ordinary(Ordinary::try_from_all(*self).unwrap())
|
Class::Ordinary(Ordinary::try_from_all(self).unwrap())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Encode as a byte
|
/// Encode as a byte
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn into_u8(&self) -> u8 {
|
pub fn into_u8(self) -> u8 {
|
||||||
self.code
|
self.code
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -809,8 +809,8 @@ ordinary_opcode! {
|
||||||
impl Ordinary {
|
impl Ordinary {
|
||||||
/// Encode as a byte
|
/// Encode as a byte
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn into_u8(&self) -> u8 {
|
pub fn into_u8(self) -> u8 {
|
||||||
*self as u8
|
self as u8
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -598,8 +598,8 @@ pub enum SigHashType {
|
||||||
|
|
||||||
impl SigHashType {
|
impl SigHashType {
|
||||||
/// Break the sighash flag into the "real" sighash flag and the ANYONECANPAY boolean
|
/// Break the sighash flag into the "real" sighash flag and the ANYONECANPAY boolean
|
||||||
pub(crate) fn split_anyonecanpay_flag(&self) -> (SigHashType, bool) {
|
pub(crate) fn split_anyonecanpay_flag(self) -> (SigHashType, bool) {
|
||||||
match *self {
|
match self {
|
||||||
SigHashType::All => (SigHashType::All, false),
|
SigHashType::All => (SigHashType::All, false),
|
||||||
SigHashType::None => (SigHashType::None, false),
|
SigHashType::None => (SigHashType::None, false),
|
||||||
SigHashType::Single => (SigHashType::Single, false),
|
SigHashType::Single => (SigHashType::Single, false),
|
||||||
|
@ -626,7 +626,7 @@ impl SigHashType {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Converts to a u32
|
/// Converts to a u32
|
||||||
pub fn as_u32(&self) -> u32 { *self as u32 }
|
pub fn as_u32(self) -> u32 { self as u32 }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -89,9 +89,9 @@ impl Network {
|
||||||
/// let network = Network::Bitcoin;
|
/// let network = Network::Bitcoin;
|
||||||
/// assert_eq!(network.magic(), 0xD9B4BEF9);
|
/// assert_eq!(network.magic(), 0xD9B4BEF9);
|
||||||
/// ```
|
/// ```
|
||||||
pub fn magic(&self) -> u32 {
|
pub fn magic(self) -> u32 {
|
||||||
// Note: any new entries here must be added to `from_magic` above
|
// Note: any new entries here must be added to `from_magic` above
|
||||||
match *self {
|
match self {
|
||||||
Network::Bitcoin => 0xD9B4BEF9,
|
Network::Bitcoin => 0xD9B4BEF9,
|
||||||
Network::Testnet => 0x0709110B,
|
Network::Testnet => 0x0709110B,
|
||||||
Network::Regtest => 0xDAB5BFFA,
|
Network::Regtest => 0xDAB5BFFA,
|
||||||
|
@ -154,12 +154,12 @@ impl ServiceFlags {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Check whether [ServiceFlags] are included in this one.
|
/// Check whether [ServiceFlags] are included in this one.
|
||||||
pub fn has(&self, flags: ServiceFlags) -> bool {
|
pub fn has(self, flags: ServiceFlags) -> bool {
|
||||||
(self.0 | flags.0) == self.0
|
(self.0 | flags.0) == self.0
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Get the integer representation of this [ServiceFlags].
|
/// Get the integer representation of this [ServiceFlags].
|
||||||
pub fn as_u64(&self) -> u64 {
|
pub fn as_u64(self) -> u64 {
|
||||||
self.0
|
self.0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -178,11 +178,10 @@ impl fmt::UpperHex for ServiceFlags {
|
||||||
|
|
||||||
impl fmt::Display for ServiceFlags {
|
impl fmt::Display for ServiceFlags {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||||
if *self == ServiceFlags::NONE {
|
let mut flags = *self;
|
||||||
|
if flags == ServiceFlags::NONE {
|
||||||
return write!(f, "ServiceFlags(NONE)");
|
return write!(f, "ServiceFlags(NONE)");
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut flags = self.clone();
|
|
||||||
let mut first = true;
|
let mut first = true;
|
||||||
macro_rules! write_flag {
|
macro_rules! write_flag {
|
||||||
($f:ident) => {
|
($f:ident) => {
|
||||||
|
|
|
@ -340,7 +340,7 @@ impl Amount {
|
||||||
/// Express this [Amount] as a floating-point value in the given denomination.
|
/// Express this [Amount] as a floating-point value in the given denomination.
|
||||||
///
|
///
|
||||||
/// Please be aware of the risk of using floating-point numbers.
|
/// Please be aware of the risk of using floating-point numbers.
|
||||||
pub fn to_float_in(&self, denom: Denomination) -> f64 {
|
pub fn to_float_in(self, denom: Denomination) -> f64 {
|
||||||
f64::from_str(&self.to_string_in(denom)).unwrap()
|
f64::from_str(&self.to_string_in(denom)).unwrap()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -349,7 +349,7 @@ impl Amount {
|
||||||
/// Equivalent to `to_float_in(Denomination::Bitcoin)`.
|
/// Equivalent to `to_float_in(Denomination::Bitcoin)`.
|
||||||
///
|
///
|
||||||
/// Please be aware of the risk of using floating-point numbers.
|
/// Please be aware of the risk of using floating-point numbers.
|
||||||
pub fn as_btc(&self) -> f64 {
|
pub fn as_btc(self) -> f64 {
|
||||||
self.to_float_in(Denomination::Bitcoin)
|
self.to_float_in(Denomination::Bitcoin)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -370,14 +370,14 @@ impl Amount {
|
||||||
/// Format the value of this [Amount] in the given denomination.
|
/// Format the value of this [Amount] in the given denomination.
|
||||||
///
|
///
|
||||||
/// Does not include the denomination.
|
/// Does not include the denomination.
|
||||||
pub fn fmt_value_in(&self, f: &mut fmt::Write, denom: Denomination) -> fmt::Result {
|
pub fn fmt_value_in(self, f: &mut fmt::Write, denom: Denomination) -> fmt::Result {
|
||||||
fmt_satoshi_in(self.as_sat(), false, f, denom)
|
fmt_satoshi_in(self.as_sat(), false, f, denom)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Get a string number of this [Amount] in the given denomination.
|
/// Get a string number of this [Amount] in the given denomination.
|
||||||
///
|
///
|
||||||
/// Does not include the denomination.
|
/// Does not include the denomination.
|
||||||
pub fn to_string_in(&self, denom: Denomination) -> String {
|
pub fn to_string_in(self, denom: Denomination) -> String {
|
||||||
let mut buf = String::new();
|
let mut buf = String::new();
|
||||||
self.fmt_value_in(&mut buf, denom).unwrap();
|
self.fmt_value_in(&mut buf, denom).unwrap();
|
||||||
buf
|
buf
|
||||||
|
@ -385,7 +385,7 @@ impl Amount {
|
||||||
|
|
||||||
/// Get a formatted string of this [Amount] in the given denomination,
|
/// Get a formatted string of this [Amount] in the given denomination,
|
||||||
/// suffixed with the abbreviation for the denomination.
|
/// suffixed with the abbreviation for the denomination.
|
||||||
pub fn to_string_with_denomination(&self, denom: Denomination) -> String {
|
pub fn to_string_with_denomination(self, denom: Denomination) -> String {
|
||||||
let mut buf = String::new();
|
let mut buf = String::new();
|
||||||
self.fmt_value_in(&mut buf, denom).unwrap();
|
self.fmt_value_in(&mut buf, denom).unwrap();
|
||||||
write!(buf, " {}", denom).unwrap();
|
write!(buf, " {}", denom).unwrap();
|
||||||
|
@ -637,7 +637,7 @@ impl SignedAmount {
|
||||||
/// Express this [SignedAmount] as a floating-point value in the given denomination.
|
/// Express this [SignedAmount] as a floating-point value in the given denomination.
|
||||||
///
|
///
|
||||||
/// Please be aware of the risk of using floating-point numbers.
|
/// Please be aware of the risk of using floating-point numbers.
|
||||||
pub fn to_float_in(&self, denom: Denomination) -> f64 {
|
pub fn to_float_in(self, denom: Denomination) -> f64 {
|
||||||
f64::from_str(&self.to_string_in(denom)).unwrap()
|
f64::from_str(&self.to_string_in(denom)).unwrap()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -646,7 +646,7 @@ impl SignedAmount {
|
||||||
/// Equivalent to `to_float_in(Denomination::Bitcoin)`.
|
/// Equivalent to `to_float_in(Denomination::Bitcoin)`.
|
||||||
///
|
///
|
||||||
/// Please be aware of the risk of using floating-point numbers.
|
/// Please be aware of the risk of using floating-point numbers.
|
||||||
pub fn as_btc(&self) -> f64 {
|
pub fn as_btc(self) -> f64 {
|
||||||
self.to_float_in(Denomination::Bitcoin)
|
self.to_float_in(Denomination::Bitcoin)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -667,7 +667,7 @@ impl SignedAmount {
|
||||||
/// Format the value of this [SignedAmount] in the given denomination.
|
/// Format the value of this [SignedAmount] in the given denomination.
|
||||||
///
|
///
|
||||||
/// Does not include the denomination.
|
/// Does not include the denomination.
|
||||||
pub fn fmt_value_in(&self, f: &mut fmt::Write, denom: Denomination) -> fmt::Result {
|
pub fn fmt_value_in(self, f: &mut fmt::Write, denom: Denomination) -> fmt::Result {
|
||||||
let sats = self.as_sat().checked_abs().map(|a: i64| a as u64).unwrap_or_else(|| {
|
let sats = self.as_sat().checked_abs().map(|a: i64| a as u64).unwrap_or_else(|| {
|
||||||
// We could also hard code this into `9223372036854775808`
|
// We could also hard code this into `9223372036854775808`
|
||||||
u64::max_value() - self.as_sat() as u64 +1
|
u64::max_value() - self.as_sat() as u64 +1
|
||||||
|
@ -678,7 +678,7 @@ impl SignedAmount {
|
||||||
/// Get a string number of this [SignedAmount] in the given denomination.
|
/// Get a string number of this [SignedAmount] in the given denomination.
|
||||||
///
|
///
|
||||||
/// Does not include the denomination.
|
/// Does not include the denomination.
|
||||||
pub fn to_string_in(&self, denom: Denomination) -> String {
|
pub fn to_string_in(self, denom: Denomination) -> String {
|
||||||
let mut buf = String::new();
|
let mut buf = String::new();
|
||||||
self.fmt_value_in(&mut buf, denom).unwrap();
|
self.fmt_value_in(&mut buf, denom).unwrap();
|
||||||
buf
|
buf
|
||||||
|
@ -686,7 +686,7 @@ impl SignedAmount {
|
||||||
|
|
||||||
/// Get a formatted string of this [SignedAmount] in the given denomination,
|
/// Get a formatted string of this [SignedAmount] in the given denomination,
|
||||||
/// suffixed with the abbreviation for the denomination.
|
/// suffixed with the abbreviation for the denomination.
|
||||||
pub fn to_string_with_denomination(&self, denom: Denomination) -> String {
|
pub fn to_string_with_denomination(self, denom: Denomination) -> String {
|
||||||
let mut buf = String::new();
|
let mut buf = String::new();
|
||||||
self.fmt_value_in(&mut buf, denom).unwrap();
|
self.fmt_value_in(&mut buf, denom).unwrap();
|
||||||
write!(buf, " {}", denom).unwrap();
|
write!(buf, " {}", denom).unwrap();
|
||||||
|
@ -1313,12 +1313,12 @@ mod tests {
|
||||||
use super::Denomination as D;
|
use super::Denomination as D;
|
||||||
let amt = Amount::from_sat(42);
|
let amt = Amount::from_sat(42);
|
||||||
let denom = Amount::to_string_with_denomination;
|
let denom = Amount::to_string_with_denomination;
|
||||||
assert_eq!(Amount::from_str(&denom(&amt, D::Bitcoin)), Ok(amt));
|
assert_eq!(Amount::from_str(&denom(amt, D::Bitcoin)), Ok(amt));
|
||||||
assert_eq!(Amount::from_str(&denom(&amt, D::MilliBitcoin)), Ok(amt));
|
assert_eq!(Amount::from_str(&denom(amt, D::MilliBitcoin)), Ok(amt));
|
||||||
assert_eq!(Amount::from_str(&denom(&amt, D::MicroBitcoin)), Ok(amt));
|
assert_eq!(Amount::from_str(&denom(amt, D::MicroBitcoin)), Ok(amt));
|
||||||
assert_eq!(Amount::from_str(&denom(&amt, D::Bit)), Ok(amt));
|
assert_eq!(Amount::from_str(&denom(amt, D::Bit)), Ok(amt));
|
||||||
assert_eq!(Amount::from_str(&denom(&amt, D::Satoshi)), Ok(amt));
|
assert_eq!(Amount::from_str(&denom(amt, D::Satoshi)), Ok(amt));
|
||||||
assert_eq!(Amount::from_str(&denom(&amt, D::MilliSatoshi)), Ok(amt));
|
assert_eq!(Amount::from_str(&denom(amt, D::MilliSatoshi)), Ok(amt));
|
||||||
|
|
||||||
assert_eq!(Amount::from_str("42 satoshi BTC"), Err(ParseAmountError::InvalidFormat));
|
assert_eq!(Amount::from_str("42 satoshi BTC"), Err(ParseAmountError::InvalidFormat));
|
||||||
assert_eq!(SignedAmount::from_str("-42 satoshi BTC"), Err(ParseAmountError::InvalidFormat));
|
assert_eq!(SignedAmount::from_str("-42 satoshi BTC"), Err(ParseAmountError::InvalidFormat));
|
||||||
|
|
|
@ -241,7 +241,7 @@ impl GCSFilterReader {
|
||||||
pub fn match_any(&self, reader: &mut io::Read, query: &mut Iterator<Item=&[u8]>) -> Result<bool, Error> {
|
pub fn match_any(&self, reader: &mut io::Read, query: &mut Iterator<Item=&[u8]>) -> Result<bool, Error> {
|
||||||
let mut decoder = reader;
|
let mut decoder = reader;
|
||||||
let n_elements: VarInt = Decodable::consensus_decode(&mut decoder).unwrap_or(VarInt(0));
|
let n_elements: VarInt = Decodable::consensus_decode(&mut decoder).unwrap_or(VarInt(0));
|
||||||
let ref mut reader = decoder;
|
let reader = &mut decoder;
|
||||||
// map hashes to [0, n_elements << grp]
|
// map hashes to [0, n_elements << grp]
|
||||||
let nm = n_elements.0 * self.m;
|
let nm = n_elements.0 * self.m;
|
||||||
let mut mapped = query.map(|e| map_to_range(self.filter.hash(e), nm)).collect::<Vec<_>>();
|
let mut mapped = query.map(|e| map_to_range(self.filter.hash(e), nm)).collect::<Vec<_>>();
|
||||||
|
@ -281,7 +281,7 @@ impl GCSFilterReader {
|
||||||
pub fn match_all(&self, reader: &mut io::Read, query: &mut Iterator<Item=&[u8]>) -> Result<bool, Error> {
|
pub fn match_all(&self, reader: &mut io::Read, query: &mut Iterator<Item=&[u8]>) -> Result<bool, Error> {
|
||||||
let mut decoder = reader;
|
let mut decoder = reader;
|
||||||
let n_elements: VarInt = Decodable::consensus_decode(&mut decoder).unwrap_or(VarInt(0));
|
let n_elements: VarInt = Decodable::consensus_decode(&mut decoder).unwrap_or(VarInt(0));
|
||||||
let ref mut reader = decoder;
|
let reader = &mut decoder;
|
||||||
// map hashes to [0, n_elements << grp]
|
// map hashes to [0, n_elements << grp]
|
||||||
let nm = n_elements.0 * self.m;
|
let nm = n_elements.0 * self.m;
|
||||||
let mut mapped = query.map(|e| map_to_range(self.filter.hash(e), nm)).collect::<Vec<_>>();
|
let mut mapped = query.map(|e| map_to_range(self.filter.hash(e), nm)).collect::<Vec<_>>();
|
||||||
|
|
|
@ -124,15 +124,15 @@ impl ChildNumber {
|
||||||
/// Returns `true` if the child number is a [`Normal`] value.
|
/// Returns `true` if the child number is a [`Normal`] value.
|
||||||
///
|
///
|
||||||
/// [`Normal`]: #variant.Normal
|
/// [`Normal`]: #variant.Normal
|
||||||
pub fn is_normal(&self) -> bool {
|
pub fn is_normal(self) -> bool {
|
||||||
!self.is_hardened()
|
!self.is_hardened()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns `true` if the child number is a [`Hardened`] value.
|
/// Returns `true` if the child number is a [`Hardened`] value.
|
||||||
///
|
///
|
||||||
/// [`Hardened`]: #variant.Hardened
|
/// [`Hardened`]: #variant.Hardened
|
||||||
pub fn is_hardened(&self) -> bool {
|
pub fn is_hardened(self) -> bool {
|
||||||
match *self {
|
match self {
|
||||||
ChildNumber::Hardened {..} => true,
|
ChildNumber::Hardened {..} => true,
|
||||||
ChildNumber::Normal {..} => false,
|
ChildNumber::Normal {..} => false,
|
||||||
}
|
}
|
||||||
|
@ -548,7 +548,7 @@ impl ExtendedPubKey {
|
||||||
i: ChildNumber,
|
i: ChildNumber,
|
||||||
) -> Result<ExtendedPubKey, Error> {
|
) -> Result<ExtendedPubKey, Error> {
|
||||||
let (sk, chain_code) = self.ckd_pub_tweak(i)?;
|
let (sk, chain_code) = self.ckd_pub_tweak(i)?;
|
||||||
let mut pk = self.public_key.clone();
|
let mut pk = self.public_key;
|
||||||
pk.key.add_exp_assign(secp, &sk[..]).map_err(Error::Ecdsa)?;
|
pk.key.add_exp_assign(secp, &sk[..]).map_err(Error::Ecdsa)?;
|
||||||
|
|
||||||
Ok(ExtendedPubKey {
|
Ok(ExtendedPubKey {
|
||||||
|
@ -604,9 +604,9 @@ impl FromStr for ExtendedPrivKey {
|
||||||
let cn_int: u32 = endian::slice_to_u32_be(&data[9..13]);
|
let cn_int: u32 = endian::slice_to_u32_be(&data[9..13]);
|
||||||
let child_number: ChildNumber = ChildNumber::from(cn_int);
|
let child_number: ChildNumber = ChildNumber::from(cn_int);
|
||||||
|
|
||||||
let network = if &data[0..4] == [0x04u8, 0x88, 0xAD, 0xE4] {
|
let network = if data[0..4] == [0x04u8, 0x88, 0xAD, 0xE4] {
|
||||||
Network::Bitcoin
|
Network::Bitcoin
|
||||||
} else if &data[0..4] == [0x04u8, 0x35, 0x83, 0x94] {
|
} else if data[0..4] == [0x04u8, 0x35, 0x83, 0x94] {
|
||||||
Network::Testnet
|
Network::Testnet
|
||||||
} else {
|
} else {
|
||||||
return Err(base58::Error::InvalidVersion((&data[0..4]).to_vec()));
|
return Err(base58::Error::InvalidVersion((&data[0..4]).to_vec()));
|
||||||
|
@ -661,9 +661,9 @@ impl FromStr for ExtendedPubKey {
|
||||||
let child_number: ChildNumber = ChildNumber::from(cn_int);
|
let child_number: ChildNumber = ChildNumber::from(cn_int);
|
||||||
|
|
||||||
Ok(ExtendedPubKey {
|
Ok(ExtendedPubKey {
|
||||||
network: if &data[0..4] == [0x04u8, 0x88, 0xB2, 0x1E] {
|
network: if data[0..4] == [0x04u8, 0x88, 0xB2, 0x1E] {
|
||||||
Network::Bitcoin
|
Network::Bitcoin
|
||||||
} else if &data[0..4] == [0x04u8, 0x35, 0x87, 0xCF] {
|
} else if data[0..4] == [0x04u8, 0x35, 0x87, 0xCF] {
|
||||||
Network::Testnet
|
Network::Testnet
|
||||||
} else {
|
} else {
|
||||||
return Err(base58::Error::InvalidVersion((&data[0..4]).to_vec()));
|
return Err(base58::Error::InvalidVersion((&data[0..4]).to_vec()));
|
||||||
|
|
|
@ -67,8 +67,8 @@ impl PartiallySignedTransaction {
|
||||||
let mut tx: Transaction = self.global.unsigned_tx;
|
let mut tx: Transaction = self.global.unsigned_tx;
|
||||||
|
|
||||||
for (vin, psbtin) in tx.input.iter_mut().zip(self.inputs.into_iter()) {
|
for (vin, psbtin) in tx.input.iter_mut().zip(self.inputs.into_iter()) {
|
||||||
vin.script_sig = psbtin.final_script_sig.unwrap_or_else(|| Script::new());
|
vin.script_sig = psbtin.final_script_sig.unwrap_or_else(Script::new);
|
||||||
vin.witness = psbtin.final_script_witness.unwrap_or_else(|| Vec::new());
|
vin.witness = psbtin.final_script_witness.unwrap_or_else(Vec::new);
|
||||||
}
|
}
|
||||||
|
|
||||||
tx
|
tx
|
||||||
|
|
Loading…
Reference in New Issue