Started modifying scriptSig to be compatible with atomicdex-style HTLCs. This removes support for P2PKH inputs, but Pirate doesn't support these anyway.

This commit is contained in:
CalDescent 2022-05-18 22:51:45 +01:00
parent dda640b336
commit 01f0bacf79

View File

@ -248,14 +248,17 @@ impl TransparentInputs {
let mut sig_bytes: Vec<u8> = sig.serialize_der()[..].to_vec(); let mut sig_bytes: Vec<u8> = sig.serialize_der()[..].to_vec();
sig_bytes.extend(&[SIGHASH_ALL as u8]); sig_bytes.extend(&[SIGHASH_ALL as u8]);
if (!&info.secret.is_empty()) { if (!&info.secret.is_empty()) { // Redeem
// Include secret and redeem script let is_refund : u8 = 0;
mtx.vin[i].script_sig = Script::default() << &info.secret[..] << &sig_bytes[..] << &info.pubkey[..] << &info.redeem_script[..]; mtx.vin[i].script_sig = Script::default() << &sig_bytes[..] << &info.pubkey[..] << &info.secret[..] << is_refund << &info.redeem_script[..];
} }
else { else { // Refund
// P2PKH scriptSig let is_refund : u8 = 1;
mtx.vin[i].script_sig = Script::default() << &sig_bytes[..] << &info.pubkey[..]; mtx.vin[i].script_sig = Script::default() << &sig_bytes[..] << &info.pubkey[..] << is_refund << &info.redeem_script[..];
} }
// No longer supports P2PKH scriptSig since this is a P2SH-only implementation
// mtx.vin[i].script_sig = Script::default() << &sig_bytes[..] << &info.pubkey[..];
} }
} }