This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#[derive(Clone, Debug, PartialOrd, Ord, PartialEq, Eq, Hash)] | |
pub struct Htlc { | |
recipient_redeem_pubkey_hash: PubkeyHash, | |
sender_refund_pubkey_hash: PubkeyHash, | |
secret_hash: SecretHash, | |
relative_timelock: u32, | |
script: Script, | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#[test] | |
fn compiled_contract_is_same_length_as_template() { | |
let htlc = Erc20Htlc::new( | |
Seconds(100), | |
Address::new(), | |
Address::new(), | |
SecretHash::from_str( | |
"1000000000000000000000000000000000000000000000000000000000000001", | |
) | |
.unwrap(), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fn compile_to_hex(&self) -> ByteCode { | |
let refund_timeout = format!("{:0>8x}", self.refund_timeout.0); | |
let redeem_address = format!("{:x}", self.redeem_address); | |
let refund_address = format!("{:x}", self.refund_address); | |
let secret_hash = format!("{:x}", self.secret_hash); | |
let token_contract_address = format!("{:x}", self.token_contract_address); | |
let amount = format!("{:0>64}", format!("{:x}", self.amount)); | |
let contract_code = Self::CONTRACT_CODE_TEMPLATE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let htlc = Erc20Htlc::new( | |
Seconds(100), | |
Address::new(), | |
Address::new(), | |
SecretHash::from_str( | |
"1000000000000000000000000000000000000000000000000000000000000001", | |
) | |
.unwrap(), | |
Address::new(), | |
U256::from(100), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pub fn new( | |
refund_timeout: Seconds, | |
refund_address: Address, | |
redeem_address: Address, | |
secret_hash: SecretHash, | |
token_contract_address: Address, | |
amount: U256, | |
) -> Self { | |
let htlc = Erc20Htlc { | |
refund_timeout, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#[derive(Debug, Clone)] | |
pub struct Erc20Htlc { | |
refund_timeout: Seconds, | |
refund_address: Address, | |
redeem_address: Address, | |
secret_hash: SecretHash, | |
token_contract_address: Address, | |
amount: U256, | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pragma solidity ^0.4.0; | |
contract gasEstimates { | |
constructor() payable public{ | |
msg.sender.transfer(10); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
document.getElementById('search-transactions-js').addEventListener('click', function () { | |
let container = document.getElementById('transactions-js'); | |
container.innerHTML = ""; | |
let address = document.getElementById('iota-address-transactions-js').value | |
if (iota.valid.isAddress(address)) | |
iota.api.findTransactionObjects( | |
{ | |
addresses: [address] | |
}, function (err, res) { | |
if (err) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sjcl.random.addEventListener("progress", function (p) { | |
if (p != 1) { | |
document.getElementById("seed").innerText = "Sto creando entropia, muovi il tuo mouse!\nProgress: " + p * 100 + "%" | |
} | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sjcl.random.addEventListener("seeded", function () { | |
let seed = genSeed(); | |
document.getElementById("seed").innerHTML = "Seed: <pre>" + seed + "</pre>"; | |
iota.api.getNewAddress( | |
seed, | |
{ | |
index: 0, | |
security: 1 | |
}, | |
(err, res) => { |