Skip to content

Commit

Permalink
Support AuxPOW block header format (DOGE). CanRefundHtlc::HaveToWait …
Browse files Browse the repository at this point in the history
…max 1 hour.
  • Loading branch information
artemii235 committed Mar 4, 2021
1 parent 9f6398b commit 76c1711
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 10 deletions.
16 changes: 8 additions & 8 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions mm2src/coins/utxo/utxo_common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2606,15 +2606,15 @@ where
let now = now_ms() / 1000;
if now < locktime {
let to_wait = locktime - now + 1;
return Box::new(futures01::future::ok(CanRefundHtlc::HaveToWait(to_wait)));
return Box::new(futures01::future::ok(CanRefundHtlc::HaveToWait(to_wait.max(3600))));
}
Box::new(coin.get_current_mtp().compat().map(move |mtp| {
let mtp = mtp as u64;
if locktime < mtp {
CanRefundHtlc::CanRefundNow
} else {
let to_wait = locktime - mtp + 1;
CanRefundHtlc::HaveToWait(to_wait)
CanRefundHtlc::HaveToWait(to_wait.max(3600))
}
}))
}
Expand Down
14 changes: 14 additions & 0 deletions mm2src/coins/utxo/utxo_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2343,3 +2343,17 @@ fn test_generate_tx_doge_fee() {
let expected_fee = 300000000;
assert_eq!(expected_fee, data.fee_amount);
}

#[test]
fn doge_mtp() {
let electrum = electrum_client_for_test(&[
"electrum1.cipig.net:10060",
"electrum2.cipig.net:10060",
"electrum3.cipig.net:10060",
]);
let mtp = electrum
.get_median_time_past(3631820, NonZeroU64::new(11).unwrap())
.wait()
.unwrap();
assert_eq!(mtp, 1614849084);
}

0 comments on commit 76c1711

Please sign in to comment.