Skip to content
This repository was archived by the owner on Apr 13, 2021. It is now read-only.

Commit ef9440a

Browse files
committed
remove timestamp_raw function from builder
1 parent 8bfd6df commit ef9440a

File tree

2 files changed

+5
-15
lines changed

2 files changed

+5
-15
lines changed

src/lib.rs

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -479,16 +479,6 @@ impl<D: tb::Bool, T: tb::Bool> InvoiceBuilder<D, tb::False, T> {
479479
}
480480

481481
impl<D: tb::Bool, H: tb::Bool> InvoiceBuilder<D, H, tb::False> {
482-
/// Sets the timestamp. `time` is a UNIX timestamp.
483-
pub fn timestamp_raw(mut self, time: u64) -> InvoiceBuilder<D, H, tb::True> {
484-
match PositiveTimestamp::from_unix_timestamp(time) {
485-
Ok(t) => self.timestamp = Some(t),
486-
Err(e) => self.error = Some(e),
487-
}
488-
489-
self.set_flags()
490-
}
491-
492482
/// Sets the timestamp.
493483
pub fn timestamp(mut self, time: SystemTime) -> InvoiceBuilder<D, H, tb::True> {
494484
match PositiveTimestamp::from_system_time(time) {
@@ -1407,7 +1397,7 @@ mod test {
14071397

14081398
let builder = InvoiceBuilder::new(Currency::BitcoinTestnet)
14091399
.amount_pico_btc(123)
1410-
.timestamp_raw(1234567)
1400+
.timestamp(UNIX_EPOCH + Duration::from_secs(1234567))
14111401
.payee_pub_key(public_key.clone())
14121402
.expiry_time(Duration::from_secs(54321))
14131403
.min_final_cltv_expiry(144)

tests/ser_de.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use bitcoin_hashes::hex::FromHex;
66
use bitcoin_hashes::sha256::Sha256Hash;
77
use lightning_invoice::*;
88
use secp256k1::{Secp256k1, RecoverableSignature, RecoveryId};
9-
use std::time::Duration;
9+
use std::time::{Duration, UNIX_EPOCH};
1010

1111
// TODO: add more of the examples from BOLT11 and generate ones causing SemanticErrors
1212

@@ -17,7 +17,7 @@ fn get_test_tuples() -> Vec<(String, SignedRawInvoice, Option<SemanticError>)> {
1717
wd5kgetjypeh2ursdae8g6twvus8g6rfwvs8qun0dfjkxaq8rkx3yf5tcsyz3d73gafnh3cax9rn449d9p5uxz9\
1818
ezhhypd0elx87sjle52x86fux2ypatgddc6k63n7erqz25le42c4u4ecky03ylcqca784w".to_owned(),
1919
InvoiceBuilder::new(Currency::Bitcoin)
20-
.timestamp_raw(1496314658)
20+
.timestamp(UNIX_EPOCH + Duration::from_secs(1496314658))
2121
.payment_hash(Sha256Hash::from_hex(
2222
"0001020304050607080900010203040506070809000102030405060708090102"
2323
).unwrap())
@@ -46,7 +46,7 @@ fn get_test_tuples() -> Vec<(String, SignedRawInvoice, Option<SemanticError>)> {
4646
9zw97j25emudupq63nyw24cg27h2rspfj9srp".to_owned(),
4747
InvoiceBuilder::new(Currency::Bitcoin)
4848
.amount_pico_btc(2500000000)
49-
.timestamp_raw(1496314658)
49+
.timestamp(UNIX_EPOCH + Duration::from_secs(1496314658))
5050
.payment_hash(Sha256Hash::from_hex(
5151
"0001020304050607080900010203040506070809000102030405060708090102"
5252
).unwrap())
@@ -76,7 +76,7 @@ fn get_test_tuples() -> Vec<(String, SignedRawInvoice, Option<SemanticError>)> {
7676
hhr8wpald05e92xw006sq94mg8v2ndf4sefvf9sygkshp5zfem29trqq2yxxz7".to_owned(),
7777
InvoiceBuilder::new(Currency::Bitcoin)
7878
.amount_pico_btc(20000000000)
79-
.timestamp_raw(1496314658)
79+
.timestamp(UNIX_EPOCH + Duration::from_secs(1496314658))
8080
.payment_hash(Sha256Hash::from_hex(
8181
"0001020304050607080900010203040506070809000102030405060708090102"
8282
).unwrap())

0 commit comments

Comments
 (0)