Skip to content

Commit

Permalink
fix: force segwit bip-141 off in tx serialisation (#31)
Browse files Browse the repository at this point in the history
* disable segwit

* only for asset_unlock
  • Loading branch information
ogabrielides authored Dec 4, 2023
1 parent 53893b5 commit 319124b
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion dash/src/blockdata/transaction/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -610,6 +610,10 @@ impl Encodable for Transaction {
break;
}
}
// Forcing have_witness to false for AssetUnlock, as currently Core doesn't support BIP141 SegWit.
if self.tx_type() == TransactionType::AssetUnlock {
have_witness= false;
}
if !have_witness {
len += self.input.consensus_encode(w)?;
len += self.output.consensus_encode(w)?;
Expand Down Expand Up @@ -640,7 +644,12 @@ impl Decodable for Transaction {
let special_transaction_type = TransactionType::try_from(special_transaction_type_u16).map_err(|_| encode::Error::UnknownSpecialTransactionType(special_transaction_type_u16))?;
let input = Vec::<TxIn>::consensus_decode_from_finite_reader(r)?;
// segwit
if input.is_empty() {
let mut segwit = input.is_empty();
// Forcing segwit to false for AssetUnlock, as currently Core doesn't support BIP141 SegWit.
if special_transaction_type == TransactionType::AssetUnlock {
segwit = false;
}
if segwit {
let segwit_flag = u8::consensus_decode_from_finite_reader(r)?;
match segwit_flag {
// BIP144 input witnesses
Expand Down

0 comments on commit 319124b

Please sign in to comment.