use bitcoin::blockdata::script::{Script,Builder};
use bitcoin::blockdata::opcodes;
use bitcoin::blockdata::transaction::{TxIn,TxOut,OutPoint,Transaction};
use bitcoin::blockdata::script::{Script,Builder};
use bitcoin::blockdata::opcodes;
use bitcoin::blockdata::transaction::{TxIn,TxOut,OutPoint,Transaction};
use bitcoin_hashes::{Hash, HashEngine};
use bitcoin_hashes::sha256::Hash as Sha256;
use bitcoin_hashes::ripemd160::Hash as Ripemd160;
use bitcoin_hashes::hash160::Hash as Hash160;
use bitcoin_hashes::{Hash, HashEngine};
use bitcoin_hashes::sha256::Hash as Sha256;
use bitcoin_hashes::ripemd160::Hash as Ripemd160;
use bitcoin_hashes::hash160::Hash as Hash160;
- let hashkey = PublicKey::from_secret_key(&secp_ctx, &SecretKey::from_slice(&secp_ctx, &res)?);
- base_point.combine(&secp_ctx, &hashkey)
+ let hashkey = PublicKey::from_secret_key(&secp_ctx, &SecretKey::from_slice(&res)?);
+ base_point.combine(&hashkey)
};
let commit_append_rev_hash_key = {
let mut sha = Sha256::engine();
sha.input(&per_commitment_point.serialize());
sha.input(&revocation_base_point.serialize());
};
let commit_append_rev_hash_key = {
let mut sha = Sha256::engine();
sha.input(&per_commitment_point.serialize());
sha.input(&revocation_base_point.serialize());
- part_b.mul_assign(&secp_ctx, &commit_append_rev_hash_key)?;
- part_a.add_assign(&secp_ctx, &part_b)?;
+ part_b.mul_assign(&commit_append_rev_hash_key)?;
+ part_a.add_assign(&part_b[..])?;
};
let commit_append_rev_hash_key = {
let mut sha = Sha256::engine();
sha.input(&per_commitment_point.serialize());
sha.input(&revocation_base_point.serialize());
};
let commit_append_rev_hash_key = {
let mut sha = Sha256::engine();
sha.input(&per_commitment_point.serialize());
sha.input(&revocation_base_point.serialize());
};
let mut part_a = revocation_base_point.clone();
part_a.mul_assign(&secp_ctx, &rev_append_commit_hash_key)?;
let mut part_b = per_commitment_point.clone();
part_b.mul_assign(&secp_ctx, &commit_append_rev_hash_key)?;
};
let mut part_a = revocation_base_point.clone();
part_a.mul_assign(&secp_ctx, &rev_append_commit_hash_key)?;
let mut part_b = per_commitment_point.clone();
part_b.mul_assign(&secp_ctx, &commit_append_rev_hash_key)?;
/// Gets the "to_local" output redeemscript, ie the script which is time-locked or spendable by
/// the revocation key
pub fn get_revokeable_redeemscript(revocation_key: &PublicKey, to_self_delay: u16, delayed_payment_key: &PublicKey) -> Script {
/// Gets the "to_local" output redeemscript, ie the script which is time-locked or spendable by
/// the revocation key
pub fn get_revokeable_redeemscript(revocation_key: &PublicKey, to_self_delay: u16, delayed_payment_key: &PublicKey) -> Script {
}
#[inline]
pub fn get_htlc_redeemscript_with_explicit_keys(htlc: &HTLCOutputInCommitment, a_htlc_key: &PublicKey, b_htlc_key: &PublicKey, revocation_key: &PublicKey) -> Script {
let payment_hash160 = Ripemd160::hash(&htlc.payment_hash.0[..]).into_inner();
if htlc.offered {
}
#[inline]
pub fn get_htlc_redeemscript_with_explicit_keys(htlc: &HTLCOutputInCommitment, a_htlc_key: &PublicKey, b_htlc_key: &PublicKey, revocation_key: &PublicKey) -> Script {
let payment_hash160 = Ripemd160::hash(&htlc.payment_hash.0[..]).into_inner();
if htlc.offered {
- .push_opcode(opcodes::All::OP_EQUAL)
- .push_opcode(opcodes::All::OP_IF)
- .push_opcode(opcodes::All::OP_CHECKSIG)
- .push_opcode(opcodes::All::OP_ELSE)
+ .push_opcode(opcodes::all::OP_EQUAL)
+ .push_opcode(opcodes::all::OP_IF)
+ .push_opcode(opcodes::all::OP_CHECKSIG)
+ .push_opcode(opcodes::all::OP_ELSE)
- .push_opcode(opcodes::All::OP_EQUAL)
- .push_opcode(opcodes::All::OP_NOTIF)
- .push_opcode(opcodes::All::OP_DROP)
+ .push_opcode(opcodes::all::OP_EQUAL)
+ .push_opcode(opcodes::all::OP_NOTIF)
+ .push_opcode(opcodes::all::OP_DROP)
- .push_opcode(opcodes::All::OP_CHECKMULTISIG)
- .push_opcode(opcodes::All::OP_ELSE)
- .push_opcode(opcodes::All::OP_HASH160)
+ .push_opcode(opcodes::all::OP_CHECKMULTISIG)
+ .push_opcode(opcodes::all::OP_ELSE)
+ .push_opcode(opcodes::all::OP_HASH160)
- .push_opcode(opcodes::All::OP_EQUALVERIFY)
- .push_opcode(opcodes::All::OP_CHECKSIG)
- .push_opcode(opcodes::All::OP_ENDIF)
- .push_opcode(opcodes::All::OP_ENDIF)
+ .push_opcode(opcodes::all::OP_EQUALVERIFY)
+ .push_opcode(opcodes::all::OP_CHECKSIG)
+ .push_opcode(opcodes::all::OP_ENDIF)
+ .push_opcode(opcodes::all::OP_ENDIF)
- .push_opcode(opcodes::All::OP_EQUAL)
- .push_opcode(opcodes::All::OP_IF)
- .push_opcode(opcodes::All::OP_CHECKSIG)
- .push_opcode(opcodes::All::OP_ELSE)
+ .push_opcode(opcodes::all::OP_EQUAL)
+ .push_opcode(opcodes::all::OP_IF)
+ .push_opcode(opcodes::all::OP_CHECKSIG)
+ .push_opcode(opcodes::all::OP_ELSE)
- .push_opcode(opcodes::All::OP_EQUAL)
- .push_opcode(opcodes::All::OP_IF)
- .push_opcode(opcodes::All::OP_HASH160)
+ .push_opcode(opcodes::all::OP_EQUAL)
+ .push_opcode(opcodes::all::OP_IF)
+ .push_opcode(opcodes::all::OP_HASH160)
- .push_opcode(opcodes::All::OP_CHECKMULTISIG)
- .push_opcode(opcodes::All::OP_ELSE)
- .push_opcode(opcodes::All::OP_DROP)
+ .push_opcode(opcodes::all::OP_CHECKMULTISIG)
+ .push_opcode(opcodes::all::OP_ELSE)
+ .push_opcode(opcodes::all::OP_DROP)
- .push_opcode(opcodes::All::OP_DROP)
- .push_opcode(opcodes::All::OP_CHECKSIG)
- .push_opcode(opcodes::All::OP_ENDIF)
- .push_opcode(opcodes::All::OP_ENDIF)
+ .push_opcode(opcodes::all::OP_DROP)
+ .push_opcode(opcodes::all::OP_CHECKSIG)
+ .push_opcode(opcodes::all::OP_ENDIF)
+ .push_opcode(opcodes::all::OP_ENDIF)
get_htlc_redeemscript_with_explicit_keys(htlc, &keys.a_htlc_key, &keys.b_htlc_key, &keys.revocation_key)
}
get_htlc_redeemscript_with_explicit_keys(htlc, &keys.a_htlc_key, &keys.b_htlc_key, &keys.revocation_key)
}
pub fn build_htlc_transaction(prev_hash: &Sha256dHash, feerate_per_kw: u64, to_self_delay: u16, htlc: &HTLCOutputInCommitment, a_delayed_payment_key: &PublicKey, revocation_key: &PublicKey) -> Transaction {
let mut txins: Vec<TxIn> = Vec::new();
txins.push(TxIn {
previous_output: OutPoint {
txid: prev_hash.clone(),
pub fn build_htlc_transaction(prev_hash: &Sha256dHash, feerate_per_kw: u64, to_self_delay: u16, htlc: &HTLCOutputInCommitment, a_delayed_payment_key: &PublicKey, revocation_key: &PublicKey) -> Transaction {
let mut txins: Vec<TxIn> = Vec::new();
txins.push(TxIn {
previous_output: OutPoint {
txid: prev_hash.clone(),