diff --git a/Cargo.lock b/Cargo.lock index 671e617..1f2af04 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -157,6 +157,54 @@ dependencies = [ "libc", ] +[[package]] +name = "anstream" +version = "0.6.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d96bd03f33fe50a863e394ee9718a706f988b9079b20c3784fb726e7678b62fb" +dependencies = [ + "anstyle", + "anstyle-parse", + "anstyle-query", + "anstyle-wincon", + "colorchoice", + "utf8parse", +] + +[[package]] +name = "anstyle" +version = "1.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8901269c6307e8d93993578286ac0edf7f195079ffff5ebdeea6a59ffb7e36bc" + +[[package]] +name = "anstyle-parse" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c75ac65da39e5fe5ab759307499ddad880d724eed2f6ce5b5e8a26f4f387928c" +dependencies = [ + "utf8parse", +] + +[[package]] +name = "anstyle-query" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e28923312444cdd728e4738b3f9c9cac739500909bb3d3c94b43551b16517648" +dependencies = [ + "windows-sys 0.52.0", +] + +[[package]] +name = "anstyle-wincon" +version = "3.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1cd54b81ec8d6180e24654d0b371ad22fc3dd083b6ff8ba325b72e00c87660a7" +dependencies = [ + "anstyle", + "windows-sys 0.52.0", +] + [[package]] name = "arrayref" version = "0.3.7" @@ -757,6 +805,46 @@ dependencies = [ "zeroize", ] +[[package]] +name = "clap" +version = "4.5.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "90bc066a67923782aa8515dbaea16946c5bcc5addbd668bb80af688e53e548a0" +dependencies = [ + "clap_builder", + "clap_derive", +] + +[[package]] +name = "clap_builder" +version = "4.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ae129e2e766ae0ec03484e609954119f123cc1fe650337e155d03b022f24f7b4" +dependencies = [ + "anstream", + "anstyle", + "clap_lex", + "strsim", +] + +[[package]] +name = "clap_derive" +version = "4.5.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "528131438037fd55894f62d6e9f068b8f45ac57ffa77517819645d10aed04f64" +dependencies = [ + "heck 0.5.0", + "proc-macro2", + "quote", + "syn 2.0.52", +] + +[[package]] +name = "clap_lex" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "98cc8fbded0c607b7ba9dd60cd98df59af97e84d24e49c8557331cfc26d301ce" + [[package]] name = "cloudabi" version = "0.0.3" @@ -766,6 +854,12 @@ dependencies = [ "bitflags 1.3.2", ] +[[package]] +name = "colorchoice" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "acbf1af155f9b9ef647e42cdc158db4b64a1b61f743629225fde6f3e0be2a7c7" + [[package]] name = "commit_encoding_derive" version = "0.10.0" @@ -1403,6 +1497,12 @@ version = "0.28.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4271d37baee1b8c7e4b708028c57d816cf9d2434acb33a549475f78c181f6253" +[[package]] +name = "glob" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b" + [[package]] name = "gloo-timers" version = "0.2.6" @@ -1477,6 +1577,12 @@ dependencies = [ "unicode-segmentation", ] +[[package]] +name = "heck" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" + [[package]] name = "hermit-abi" version = "0.3.9" @@ -2134,7 +2240,7 @@ version = "0.17.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ec4c6225c69b4ca778c0aea097321a64c421cf4577b331c61b229267edabb6f8" dependencies = [ - "heck", + "heck 0.4.1", "proc-macro-error", "proc-macro2", "quote", @@ -2916,7 +3022,7 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3bd3534a9978d0aa7edd2808dc1f8f31c4d0ecd31ddf71d997b3c98e9f3c9114" dependencies = [ - "heck", + "heck 0.4.1", "proc-macro-error", "proc-macro2", "quote", @@ -2945,13 +3051,30 @@ dependencies = [ "url", ] +[[package]] +name = "sea-orm-cli" +version = "0.12.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "620bc560062ae251b1366bde43b3f1508445cab5c2c8cbdb397034638ab1b357" +dependencies = [ + "chrono", + "clap", + "dotenvy", + "glob", + "regex", + "sea-schema", + "tracing", + "tracing-subscriber", + "url", +] + [[package]] name = "sea-orm-macros" version = "0.12.14" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ec13bfb4c4aef208f68dbea970dd40d13830c868aa8dcb4e106b956e6bb4f2fa" dependencies = [ - "heck", + "heck 0.4.1", "proc-macro2", "quote", "sea-bae", @@ -2966,8 +3089,11 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ac734b6e5610c2764056cc8495fbc293cd1c8ebe084fdfb74c3b0cdaaff9bb92" dependencies = [ "async-trait", + "clap", + "dotenvy", "futures", "sea-orm", + "sea-orm-cli", "sea-schema", "tracing", "tracing-subscriber", @@ -3001,7 +3127,7 @@ version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "25a82fcb49253abcb45cdcb2adf92956060ec0928635eb21b4f7a6d8f25ab0bc" dependencies = [ - "heck", + "heck 0.4.1", "proc-macro2", "quote", "syn 2.0.52", @@ -3025,7 +3151,7 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c6f686050f76bffc4f635cda8aea6df5548666b830b52387e8bc7de11056d11e" dependencies = [ - "heck", + "heck 0.4.1", "proc-macro2", "quote", "syn 1.0.109", @@ -3442,7 +3568,7 @@ dependencies = [ "atomic-write-file", "dotenvy", "either", - "heck", + "heck 0.4.1", "hex", "once_cell", "proc-macro2", @@ -3588,7 +3714,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "37064ec285e2a633465eb525c8698eea51373dee889fe310e0d32df8343e7f4f" dependencies = [ "amplify_syn", - "heck", + "heck 0.4.1", "proc-macro2", "quote", "syn 1.0.109", @@ -3634,6 +3760,12 @@ dependencies = [ "unicode-normalization", ] +[[package]] +name = "strsim" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" + [[package]] name = "strum" version = "0.25.0" @@ -4054,6 +4186,12 @@ version = "2.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "daf8dba3b7eb870caf1ddeed7bc9d2a049f3cfdfae7cb521b087cc33ae4c49da" +[[package]] +name = "utf8parse" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "711b9620af191e0cdc7468a8d14e709c3dcdb115b36f838e601583af800a370a" + [[package]] name = "value-bag" version = "1.7.0" diff --git a/migration/Cargo.toml b/migration/Cargo.toml index 0491fdc..0f0e019 100644 --- a/migration/Cargo.toml +++ b/migration/Cargo.toml @@ -25,5 +25,6 @@ sea-orm-migration = { version = "=0.12.14", default-features = false, features = "sqlx-mysql", "sqlx-postgres", "sqlx-sqlite", - "runtime-async-std-native-tls" + "runtime-async-std-native-tls", + "cli", ] } diff --git a/migration/src/m20230608_071249_init_db.rs b/migration/src/m20230608_071249_init_db.rs index 8630b13..9ba702e 100644 --- a/migration/src/m20230608_071249_init_db.rs +++ b/migration/src/m20230608_071249_init_db.rs @@ -124,6 +124,7 @@ impl MigrationTrait for Migration { .not_null(), ) .col(ColumnDef::new(BatchTransfer::Expiration).big_unsigned()) + .col(ColumnDef::new(BatchTransfer::ExactExpiry).boolean()) .col( ColumnDef::new(BatchTransfer::MinConfirmations) .tiny_unsigned() @@ -646,6 +647,7 @@ pub enum BatchTransfer { CreatedAt, UpdatedAt, Expiration, + ExactExpiry, MinConfirmations, } diff --git a/src/database/entities/batch_transfer.rs b/src/database/entities/batch_transfer.rs index 1bac73d..e55e028 100644 --- a/src/database/entities/batch_transfer.rs +++ b/src/database/entities/batch_transfer.rs @@ -21,6 +21,7 @@ pub struct Model { pub created_at: i64, pub updated_at: i64, pub expiration: Option, + pub exact_expiry: Option, pub min_confirmations: u8, } @@ -32,6 +33,7 @@ pub enum Column { CreatedAt, UpdatedAt, Expiration, + ExactExpiry, MinConfirmations, } @@ -62,6 +64,7 @@ impl ColumnTrait for Column { Self::CreatedAt => ColumnType::BigInteger.def(), Self::UpdatedAt => ColumnType::BigInteger.def(), Self::Expiration => ColumnType::BigInteger.def().null(), + Self::ExactExpiry => ColumnType::Boolean.def().null(), Self::MinConfirmations => ColumnType::SmallInteger.def(), } } diff --git a/src/database/mod.rs b/src/database/mod.rs index 1f25d53..49ad959 100644 --- a/src/database/mod.rs +++ b/src/database/mod.rs @@ -279,6 +279,7 @@ pub(crate) struct TransferData { pub(crate) created_at: i64, pub(crate) updated_at: i64, pub(crate) expiration: Option, + pub(crate) exact_expiry: Option, } pub struct RgbLibDatabase { @@ -936,6 +937,7 @@ impl RgbLibDatabase { created_at: batch_transfer.created_at, updated_at: batch_transfer.updated_at, expiration: batch_transfer.expiration, + exact_expiry: batch_transfer.exact_expiry, }) } diff --git a/src/wallet/mod.rs b/src/wallet/mod.rs index e2b1561..1d28482 100644 --- a/src/wallet/mod.rs +++ b/src/wallet/mod.rs @@ -1093,7 +1093,7 @@ pub struct Transfer { /// Change UTXO of an outgoing transfer pub change_utxo: Option, /// Expiration of the transfer - pub expiration: Option, + pub expiration: Option<(i64, bool)>, /// Transport endpoints for the transfer pub transport_endpoints: Vec, } @@ -1119,7 +1119,7 @@ impl Transfer { recipient_id: x.recipient_id.clone(), receive_utxo: td.receive_utxo, change_utxo: td.change_utxo, - expiration: td.expiration, + expiration: td.expiration.map(|e| (e, td.exact_expiry.unwrap())), transport_endpoints, } }