Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release 0.3 #107

Closed
wants to merge 469 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
469 commits
Select commit Hold shift + click to select a range
b853242
Improve update function
ssantos21 Jan 9, 2024
ea83244
Improve GUI
ssantos21 Jan 9, 2024
8b3d3dc
Remove DB transaction to avoid race condition
ssantos21 Jan 9, 2024
e27436b
config
Jan 10, 2024
e074afc
config
Jan 10, 2024
02c0dce
add token server
Jan 8, 2024
61362d4
Merge branch 'token_server' into dev
ssantos21 Jan 10, 2024
311d117
Update tokens.md
tomt1664 Jan 11, 2024
6691575
Update Token struct
ssantos21 Jan 12, 2024
0dcefbd
Add WASM packages
ssantos21 Jan 12, 2024
990b030
Improve UI
ssantos21 Jan 13, 2024
204ef97
Change react-app config file
ssantos21 Jan 13, 2024
efcb4b4
chore: add changes to get locofy-ui working
rk16449 Jan 17, 2024
83f484f
chore: add key to wizard
rk16449 Jan 19, 2024
94c476c
chore: add deposit process ui
rk16449 Jan 23, 2024
7d8317c
chore: add token ui logic
rk16449 Jan 23, 2024
7e1b4db
chore: huge locofy ai changes, remove old code as wasn't scalable, le…
rk16449 Jan 25, 2024
135d1a5
chore: fix up icons
rk16449 Jan 25, 2024
1fae849
chore: hook token info card and deposit page
rk16449 Jan 25, 2024
3036365
chore: update token card UI
rk16449 Jan 25, 2024
3a8cf48
chore: add more validation to deposit process, and modal windows
rk16449 Jan 26, 2024
98e48a8
chore: update deposit pages
rk16449 Jan 26, 2024
576ad16
add expiry time
Jan 29, 2024
28323b5
fix
Jan 29, 2024
c592712
fix
Jan 29, 2024
f913c11
chore: finish the tab ui logic
rk16449 Jan 29, 2024
05e6bf4
chore: add changes to deposit, hook up live methods to the deposit pr…
rk16449 Jan 31, 2024
a4b1161
add key check
Jan 31, 2024
584c75f
fix serialisation
Jan 31, 2024
87c556a
chore: add token insertion into wallet object, various other changes,…
rk16449 Feb 1, 2024
999c0e7
chore: fix wallet load code
rk16449 Feb 1, 2024
0d039c9
chore: add back in validation for wizard page 2, cleanup the main hea…
rk16449 Feb 1, 2024
7b161f7
chore: refactor, add a logged in wallet hook, add validation to walle…
rk16449 Feb 2, 2024
30e4e59
chore: show seed key in wizard states
rk16449 Feb 2, 2024
d060c47
chore: fix error if coins / activities is null
rk16449 Feb 2, 2024
1161299
Modify Token struct
ssantos21 Feb 2, 2024
c4c0f89
chore: fix error message ordering in wizard page
rk16449 Feb 2, 2024
1d3dec5
Merge branch 'fix/locofy-ui' of https://github.com/commerceblock/merc…
rk16449 Feb 2, 2024
9dad6bc
chore: move order of destructure variable in main page
rk16449 Feb 2, 2024
c77f572
chore: fix coin item, display some info to user about their statecoin
rk16449 Feb 2, 2024
c112b31
chore: add changes to main header panel, add up btc values
rk16449 Feb 2, 2024
48783d4
chore: fix deposit addresses
rk16449 Feb 5, 2024
4f14bbc
chore: change to testnet server, add withdraw ui components
rk16449 Feb 7, 2024
c682b4c
chore: fix more withdrawal logic, fix bug in deposit 3 page
rk16449 Feb 8, 2024
636554a
chore: do not show withdrawn coins
rk16449 Feb 8, 2024
17e3a04
chore: add send page and logic
rk16449 Feb 12, 2024
945c2bb
chore: fix receive page
rk16449 Feb 13, 2024
91825d9
chore: fix activities table
rk16449 Feb 13, 2024
a6c5ede
chore: fix some navigation errors and settings page errors
rk16449 Feb 14, 2024
ebe263f
Add Settings property to wallet
ssantos21 Feb 15, 2024
d4497fb
chore: add password encrypted db wallets, add error message handling …
rk16449 Feb 18, 2024
6f67f0c
chore: add backup from file/load into db
rk16449 Feb 18, 2024
844ab51
Merge branch 'dev' into feat/token_server
tomt1664 Feb 19, 2024
745793a
Merge pull request #25 from commerceblock/feat/token_server
tomt1664 Feb 19, 2024
c2fc21a
Merge pull request #24 from commerceblock/fix/existing_key
tomt1664 Feb 19, 2024
327568b
chore: add changes to main load wallet
rk16449 Feb 19, 2024
2177ba0
chore: get latest password
rk16449 Feb 19, 2024
63a980e
chore: change settings page
rk16449 Feb 19, 2024
05a8654
chore: remove manage transactions from settings page as will be in modal
rk16449 Feb 19, 2024
38e2539
chore: add settings ui hooked with redux state and notifications
rk16449 Feb 19, 2024
58e44c8
chore: add the reloading of wallets within load wallet page
rk16449 Feb 19, 2024
288ec45
chore: remove debugging, add check on wizard for encrypted wallets in…
rk16449 Feb 20, 2024
ee435ef
chore: fix loading from backup file to include backup tx
rk16449 Feb 21, 2024
47974f0
chore: add more responsive main bar page, and add modal ui
rk16449 Feb 22, 2024
5f27b76
chore: fix coin modal and help page
rk16449 Feb 23, 2024
ac1b931
chore: remove amount
rk16449 Feb 23, 2024
a760d96
chore: downgrade sql
rk16449 Feb 27, 2024
f7b79a1
chore: enable debug mode
rk16449 Feb 28, 2024
6477199
chore: replace icon of app
rk16449 Feb 28, 2024
2f467f2
chore: huge fix for resources in wallet
rk16449 Feb 28, 2024
19da815
chore: add build
rk16449 Feb 29, 2024
750487f
chore: add dev branch
rk16449 Feb 29, 2024
49d5a34
Merge pull request #27 from commerceblock/fix/locofy-ui
tomt1664 Mar 1, 2024
1413ca5
chore: fix clearnet config issues, start a build
rk16449 Mar 4, 2024
f9151e6
chore: change actions
rk16449 Mar 4, 2024
26b4bf4
chore: remove mainnet
rk16449 Mar 4, 2024
4b4dd61
chore: remove mainnet
rk16449 Mar 4, 2024
9536953
chore: change github actions
rk16449 Mar 4, 2024
303cdab
chore: change app icon
rk16449 Mar 4, 2024
4ade93d
chore: change app icon
rk16449 Mar 4, 2024
48b24b7
chore: remove unused files
rk16449 Mar 4, 2024
0a485c7
Merge pull request #31 from commerceblock/fix/release-issues
rk16449 Mar 4, 2024
40a7994
version: update to 0.1.1
rk16449 Mar 4, 2024
9848842
Merge pull request #33 from commerceblock/release/version-change-0-1-1
rk16449 Mar 4, 2024
3fd146a
DB file path
tomt1664 Mar 11, 2024
9dccba7
Update atomic_transfer.md
tomt1664 Mar 12, 2024
d801946
Update atomic_transfer.md
nicosey Mar 13, 2024
ae7c7c1
Update atomic_transfer.md
nicosey Mar 13, 2024
0e1f549
Update atomic_transfer.md
tomt1664 Mar 13, 2024
7f4c900
Update protocol.md
tomt1664 Mar 21, 2024
4a4d259
Update transfer_sender_sequence.md
tomt1664 Mar 21, 2024
110790e
Update transfer_receiver_sequence.md
tomt1664 Mar 21, 2024
f757dc3
Update transfer_sender_sequence.md
tomt1664 Mar 21, 2024
0b395d5
Update transfer_receiver_sequence.md
tomt1664 Mar 21, 2024
95056b3
Update protocol.md
tomt1664 Mar 21, 2024
592ef18
Add ChaCha20-Poly1305 encryption scheme
ssantos21 Mar 31, 2024
6a0d459
Add password to add-mnemonic call
ssantos21 Apr 15, 2024
624e8d4
Add Dockerfiles to SGX SIM mode
ssantos21 Apr 17, 2024
818831a
Add docker files to the server
ssantos21 Apr 17, 2024
c9693b2
Update protocol.md
tomt1664 Apr 17, 2024
ba2f062
Merge pull request #36 from commerceblock/fix/mac_db_path
tomt1664 Apr 17, 2024
6d06139
Update README.md
tomt1664 Apr 17, 2024
fa1dee2
Update deposit_sequence.md
tomt1664 Apr 17, 2024
e5ec2dd
Update transfer_sender_sequence.md
tomt1664 Apr 17, 2024
283946a
Update transfer_receiver_sequence.md
tomt1664 Apr 17, 2024
17a9dbe
Add docker files to the enclave - HW mode
ssantos21 Apr 18, 2024
d9d56ba
Remove r2 and blind commitments
ssantos21 Apr 23, 2024
2256f41
Change HRP to 'ml' and 'tml'
ssantos21 Apr 25, 2024
33b545a
Add address validation and remove standalone rust client
ssantos21 Apr 26, 2024
9660b00
Update WASM and rename lib
ssantos21 Apr 27, 2024
a6db3b7
Update atomic_transfer.md
tomt1664 Apr 30, 2024
0e2fd0f
Update atomic_transfer.md
tomt1664 Apr 30, 2024
ad221dc
Add UniFFI
ssantos21 Apr 29, 2024
3a0255a
Re-add nodejs client
ssantos21 May 2, 2024
a7138f7
Add kotlin client
ssantos21 May 2, 2024
f0439a0
Merge pull request #43 from commerceblock/doc/atomic_update
tomt1664 May 2, 2024
5f4a4aa
Use TransferReceiverPostResponsePayload
ssantos21 May 2, 2024
a6008c6
Add Atomic transfer
ssantos21 May 9, 2024
c5c9a7b
Merge branch 'dev' into feat/commit_remove
tomt1664 May 14, 2024
4547422
Merge pull request #42 from commerceblock/feat/commit_remove
tomt1664 May 14, 2024
e5249e0
Use statechain_info to verify transfers
ssantos21 May 15, 2024
a800f63
Add automatic seed generation and replication
ssantos21 May 17, 2024
15659f0
Update react-app package.json
ssantos21 May 20, 2024
373ca81
Increase the maximum amount of time to spend waiting for a connection…
ssantos21 May 21, 2024
6eb2cfa
Allow coin to be withdrawn if in IN_TRANSFER status
ssantos21 May 21, 2024
815a904
Fix minor errors regarding IN_TRANSFER status
ssantos21 May 22, 2024
1b3e08d
Update Kotlin client
ssantos21 May 22, 2024
b121aa2
fix: server config with env for mercury & token server
DhananjayPurohit May 23, 2024
990aa91
feat: add docker build for github actions
DhananjayPurohit May 23, 2024
d6385a4
feat: add dev branch to yaml
DhananjayPurohit Mar 26, 2024
95340ac
fix: token server port
DhananjayPurohit May 23, 2024
020aa1f
fix: expose port in dockerfile for token-server
DhananjayPurohit May 23, 2024
b709104
fix: move Rocket.toml from sub folder to parent folder
DhananjayPurohit May 23, 2024
eb05651
fix: add tls feature to sqlx
DhananjayPurohit May 23, 2024
a677de3
fix: route for endpoint /info
DhananjayPurohit May 23, 2024
7275089
feat: add explorer
DhananjayPurohit May 23, 2024
bc8973b
feat: add keylist cronjob
DhananjayPurohit May 23, 2024
4ff122f
fix: version for docker images in ci/cd
DhananjayPurohit May 23, 2024
0bdc4a8
fix: add dev2 branch to ci/cd
DhananjayPurohit May 23, 2024
ad7ed6e
fix: import error with token server
DhananjayPurohit May 23, 2024
ccdb8b6
fix: mercury server start cmd
DhananjayPurohit May 23, 2024
658dfc9
fix: start cmd for mercury server
DhananjayPurohit May 23, 2024
1a4dc80
debug: mercury server dockerfile
DhananjayPurohit May 23, 2024
2d93785
fix: config for mercury and token server
DhananjayPurohit May 24, 2024
36d5be4
fix: mercury server dockerfile
DhananjayPurohit May 24, 2024
47af7b8
fix: dockerfile for mercury server
DhananjayPurohit May 24, 2024
9c6f90b
Merge pull request #53 from commerceblock/feat/server-config-dockerfiles
tomt1664 May 24, 2024
504bac9
Fix the mainnet address conversion
ssantos21 May 24, 2024
9e4e863
Add address reuse functionality
ssantos21 May 23, 2024
f63427e
Merge pull request #50 from ssantos21/address_reuse
ssantos21 May 25, 2024
d849680
Create rust client lib
ssantos21 May 26, 2024
cb11d64
Create nodejs client lib
ssantos21 May 26, 2024
b51bd98
Update ECIES package and restructure project folders
ssantos21 May 29, 2024
10dd65f
Add a new test file that uses the nodejs lib
ssantos21 May 30, 2024
157b43f
Fix docker error preventing Mercury server from starting
ssantos21 Jun 4, 2024
067c908
Move signature validation from rust client lib to Mercury lib
ssantos21 Jun 4, 2024
53bbf84
Refactor `clients/libs/rust/src/transfer_receiver.rs`. No change in b…
ssantos21 Jun 4, 2024
f45553f
Use `validateSignatureScheme` in `clients/libs/nodejs/transfer_receiv…
ssantos21 Jun 4, 2024
9660fbf
Use `validateSignatureScheme` in `clients/apps/kotlin/TransferReceive…
ssantos21 Jun 4, 2024
648890a
Add web client lib
ssantos21 Jun 6, 2024
237b945
Add `max_fee_rate` setting to rust lib
ssantos21 Jun 9, 2024
a5194f8
Add `max_fee_rate` setting to nodejs lib
ssantos21 Jun 10, 2024
1f95981
Create client_guide.md
tomt1664 Jun 10, 2024
9a72655
Add `max_fee_rate` setting to web lib
ssantos21 Jun 10, 2024
ed6681a
Update client_guide.md
tomt1664 Jun 10, 2024
822a1c2
Update client_guide.md
tomt1664 Jun 10, 2024
cf47f30
Update client_guide.md
tomt1664 Jun 10, 2024
89b7fe0
Add `max_fee_rate` setting to Kotlin client
ssantos21 Jun 11, 2024
cf8dba1
Add multiple enclave support
ssantos21 Jun 13, 2024
81aee2f
Remove outdated react-app
ssantos21 Jun 20, 2024
d3912c2
Handle fee rate < 0 in broadcast command
ssantos21 Jun 24, 2024
d5cc865
Feat/fee unit
tomt1664 May 24, 2024
0970d03
Add integration tests on regtest mode
ssantos21 Jul 1, 2024
99f8a2e
Add Lightning Latch atomic transfer
ssantos21 Jul 1, 2024
c7b6f0c
Improve transfer message verification
ssantos21 Jul 3, 2024
7ff5e92
Add basic Rust integration tests
ssantos21 Jul 5, 2024
4be5f0f
Add `batchtimeout` to `/info/config`
ssantos21 Jul 5, 2024
b506f3b
fix: directory for Rocket.toml
DhananjayPurohit Jul 5, 2024
cbdbb9f
feat: add tests for coin expiry
DhananjayPurohit Jun 26, 2024
eab776b
fix: add test for transfer-sender that make coin expired by sending
DhananjayPurohit Jun 27, 2024
07820d4
fix: assertion for broadcast tx
DhananjayPurohit Jul 3, 2024
4e8b4b1
fix: add dev3 for integration tests
DhananjayPurohit Jul 5, 2024
1cf2134
Add TB02 - Transfer Address Reuse
ssantos21 Jul 7, 2024
77fa2e0
Add TM01 - Sender Double Spends
ssantos21 Jul 8, 2024
3475c0c
chore: remove dev3 branch from integration tests
DhananjayPurohit Jul 9, 2024
4d8c40f
Add TA01 - 'signSecond not called' and return the pubnonce if the cha…
ssantos21 Jul 8, 2024
6a04010
Merge pull request #70 from commerceblock/fix/host-in-mercury
DhananjayPurohit Jul 9, 2024
339086f
Merge pull request #71 from commerceblock/feat/tests-for-coin-expiry
DhananjayPurohit Jul 9, 2024
1841829
Refactor transfer-receive to make it non-blocking
ssantos21 Jul 10, 2024
76fa200
Refactor transfer-receive in nodeJS library to make it non-blocking
ssantos21 Jul 11, 2024
11033b5
Adjust tests to the new transferReceive function
ssantos21 Jul 11, 2024
8a97299
Add web lib tests
ssantos21 Jul 16, 2024
f839817
Fix minor error in nodeJS transfer-receive
ssantos21 Jul 16, 2024
31bb7ee
Add lightning latch functions to the nodeJS client
ssantos21 Jul 16, 2024
ebce52a
Add Rust lightning latch test
ssantos21 Jul 16, 2024
1220b55
Add nodeJs lightning latch test
ssantos21 Jul 17, 2024
81037f7
Feat/tests for atomic swap (#72)
DhananjayPurohit Jul 18, 2024
d6a752f
Add lightning latch functions to web client
ssantos21 Jul 18, 2024
a66ea50
Improve nodeJS API parameters
ssantos21 Jul 18, 2024
373c063
Change fee rate to f64 instead of u64
ssantos21 Jul 18, 2024
6791166
fix: ci build on main branch only (#78)
DhananjayPurohit Jul 19, 2024
1061840
Handle multiple deposit transactions
ssantos21 Jul 20, 2024
8a37a9a
Add multiple deposit support to the nodeJS client
ssantos21 Jul 24, 2024
75290f6
Update test_basic_workflow2 to support duplicated deposits
ssantos21 Jul 25, 2024
b5c1866
Update web client to support multiple deposits
ssantos21 Jul 27, 2024
a75fee4
Automate web client testing
ssantos21 Jul 29, 2024
b0103ff
Add Vitest to web client tests
ssantos21 Jul 31, 2024
e37b627
Update Dockerfile (#81)
tomt1664 Aug 2, 2024
71c7c72
Merge branch 'main' into dev
tomt1664 Aug 2, 2024
1c87d91
Revert "Update Dockerfile (#81)" (#83)
tomt1664 Aug 2, 2024
579d35b
Add GET `/transfer/paymenthash/<batch_id>`
ssantos21 Aug 6, 2024
746f5cd
Add payment hash verification to nodeJS client
ssantos21 Aug 6, 2024
7fa1b95
Fix/dockerfile token server (#85)
DhananjayPurohit Aug 12, 2024
6ff4790
Add payment hash verification to web client
ssantos21 Aug 12, 2024
d80d0e8
Add log crate to the server
ssantos21 Aug 12, 2024
57727bd
fix: The pre-image is now only revealed if the transfer is unlocked.
ssantos21 Aug 13, 2024
6488f35
Set getrandom version
ssantos21 Aug 20, 2024
b7cc762
Add rust-toolchain file to wasm project
ssantos21 Aug 20, 2024
a4b5269
feat: add LND containers for testing (#77)
DhananjayPurohit Aug 23, 2024
78a9d2c
Update Cargo.toml
tomt1664 Aug 23, 2024
e73dceb
fix: upgrade sqlx version
DhananjayPurohit Aug 27, 2024
d858cc7
Update sqlx and toolchain
ssantos21 Aug 27, 2024
403e316
Change transaction sequence to 0
ssantos21 Sep 2, 2024
045c697
Receiver now compares the backup transaction locktime with the curren…
ssantos21 Sep 2, 2024
e0a0857
Validate backup transaction signatures using SIGHASH_ALL
ssantos21 Sep 2, 2024
8de6633
Validate transaction version
ssantos21 Sep 2, 2024
0af1bd9
Validate transaction output size
ssantos21 Sep 2, 2024
a370e0d
Add blockheight in web library receive functionality
ssantos21 Sep 3, 2024
7dbfc77
Receiver constructs backup transactions for verification
ssantos21 Sep 4, 2024
e6dc17c
Add tx and locktime checks
tomt1664 Sep 4, 2024
7471adc
Version number
tomt1664 Sep 5, 2024
e23f5e1
Update Cargo.toml
tomt1664 Sep 5, 2024
2661ae1
Merge branch 'main' into dev
tomt1664 Sep 5, 2024
4c7d0b8
Add server version number to /info/config
ssantos21 Sep 9, 2024
b9973ee
feat: add tnc to token (#89)
DhananjayPurohit Sep 9, 2024
c83622a
Connection string secret as separate ENV.
ssantos21 Sep 10, 2024
28f2408
Change the PubKeyInfo struct to show creation date
ssantos21 Sep 11, 2024
75a8243
feat: add tnc to explorer page (#99)
DhananjayPurohit Sep 12, 2024
f4b02d9
version number
tomt1664 Sep 12, 2024
d2d245b
Merge branch 'main' into dev
tomt1664 Sep 12, 2024
15a21ad
Update env var
ssantos21 Sep 17, 2024
a648e9f
Allow `token_server::endpoints::token::{RTLQuery, RTLInvoice}` to cap…
ssantos21 Oct 4, 2024
cb4027a
Update Cargo.toml
tomt1664 Oct 4, 2024
e8ca1e9
Merge branch 'main' into dev
tomt1664 Oct 4, 2024
7760cf7
Update token.rs
tomt1664 Oct 4, 2024
7b15c73
Add 'wallet' column in the 'backup_txs' table
ssantos21 Oct 23, 2024
ee556c1
Add multiple deposit feature
ssantos21 Oct 23, 2024
da76505
Add multiple deposit feature in web lib
ssantos21 Nov 3, 2024
30a2c35
Add extra validation for duplicated coins in rust lib
ssantos21 Nov 5, 2024
23c3be9
Add extra validation for duplicated coins in web lib
ssantos21 Nov 5, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Cargo.lock

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

5 changes: 3 additions & 2 deletions clients/apps/rust/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ enum Commands {
force_send: Option<bool>,
/// Batch id for atomic transfers
batch_id: Option<String>,
duplicated_indexes: Option<Vec<u32>>,
},
/// Send a statechain coin to a transfer address
TransferReceive { wallet_name: String },
Expand Down Expand Up @@ -158,12 +159,12 @@ async fn main() -> Result<()> {

println!("{}", serde_json::to_string_pretty(&obj).unwrap());
},
Commands::TransferSend { wallet_name, statechain_id, to_address, force_send, batch_id } => {
Commands::TransferSend { wallet_name, statechain_id, to_address, force_send, batch_id, duplicated_indexes } => {
mercuryrustlib::coin_status::update_coins(&client_config, &wallet_name).await?;

let force_send = force_send.unwrap_or(false);

mercuryrustlib::transfer_sender::execute(&client_config, &to_address, &wallet_name, &statechain_id, force_send, batch_id).await?;
mercuryrustlib::transfer_sender::execute(&client_config, &to_address, &wallet_name, &statechain_id, duplicated_indexes, force_send, batch_id).await?;

let obj = json!({"Transfer": "sent"});

Expand Down
2 changes: 2 additions & 0 deletions clients/libs/nodejs/coin_enum.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ const CoinStatus = {
TRANSFERRED: "TRANSFERRED", // the coin was transferred
WITHDRAWN: "WITHDRAWN", // the coin was withdrawn
DUPLICATED: "DUPLICATED", // the coin was withdrawn
DUPLICATED: "DUPLICATED", // the coin was withdrawn
INVALIDATED: "INVALIDATED", // the coin was invalidated
};

module.exports = { CoinStatus };
1 change: 1 addition & 0 deletions clients/libs/rust/migrations/0001_signer_data_table.sql
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ CREATE TABLE IF NOT EXISTS wallet (
);

CREATE TABLE IF NOT EXISTS backup_txs (
wallet_name TEXT NOT NULL,
statechain_id TEXT NOT NULL,
txs TEXT NOT NULL
);
2 changes: 1 addition & 1 deletion clients/libs/rust/src/broadcast_backup_tx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ pub async fn execute(client_config: &ClientConfig, wallet_name: &str, statechain
}
}

let backup_txs = get_backup_txs(&client_config.pool, &statechain_id).await?;
let backup_txs = get_backup_txs(&client_config.pool, &wallet.name, &statechain_id).await?;

// If the user sends to himself, he will have two coins with same statechain_id
// In this case, we need to find the one with the lowest locktime
Expand Down
29 changes: 26 additions & 3 deletions clients/libs/rust/src/coin_status.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,20 @@ async fn check_deposit(client_config: &ClientConfig, coin: &mut Coin, wallet_net
let utxo_txid = utxo.tx_hash.to_string();
let utxo_vout = utxo.tx_pos as u32;

let backup_tx = create_tx1(client_config, coin, wallet_netwotk, &utxo_txid, utxo_vout).await?;
if coin.status != CoinStatus::INITIALISED {
return Err(anyhow!("The coin with the public key {} is not in the INITIALISED state", coin.user_pubkey.to_string()));
}

coin.utxo_txid = Some(utxo_txid.to_string());
coin.utxo_vout = Some(utxo_vout);

coin.status = CoinStatus::IN_MEMPOOL;

let backup_tx = create_tx1(client_config, coin, wallet_netwotk, 1u32).await?;

let activity_utxo = format!("{}:{}", utxo.tx_hash.to_string(), utxo.tx_pos);

let activity = Some(create_activity(&activity_utxo, utxo.value as u32, "deposit"));
// return Ok(Some(activity));

deposit_result = Some(DepositResult {
activity: activity.unwrap(),
Expand Down Expand Up @@ -238,7 +246,7 @@ pub async fn update_coins(client_config: &ClientConfig, wallet_name: &str) -> Re
let backup_tx = deposit_result.backup_tx;

wallet.activities.push(activity);
insert_backup_txs(&client_config.pool, &coin.statechain_id.as_ref().unwrap(), &[backup_tx].to_vec()).await?;
insert_backup_txs(&client_config.pool, &wallet.name, &coin.statechain_id.as_ref().unwrap(), &[backup_tx].to_vec()).await?;
}
} else if coin.status == CoinStatus::IN_TRANSFER {

Expand All @@ -257,6 +265,21 @@ pub async fn update_coins(client_config: &ClientConfig, wallet_name: &str) -> Re

wallet.coins.extend(duplicated_coins);

// invalidate duplicated coins that were not transferred
for i in 0..wallet.coins.len() {
if wallet.coins[i].status == CoinStatus::DUPLICATED {
let is_transferred = (0..wallet.coins.len()).any(|j|
i != j && // Skip comparing with self
wallet.coins[j].statechain_id == wallet.coins[i].statechain_id &&
wallet.coins[j].locktime == wallet.coins[i].locktime &&
wallet.coins[j].status == CoinStatus::TRANSFERRED
);
if is_transferred {
wallet.coins[i].status = CoinStatus::INVALIDATED;
}
}
}

update_wallet(&client_config.pool, &wallet).await?;

Ok(())
Expand Down
19 changes: 4 additions & 15 deletions clients/libs/rust/src/deposit.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use anyhow::{anyhow, Result, Ok};
use mercurylib::{deposit::{create_deposit_msg1, create_aggregated_address}, wallet::{Wallet, BackupTx, CoinStatus, Coin}, transaction:: get_user_backup_address, utils::get_blockheight};
use mercurylib::{deposit::{create_deposit_msg1, create_aggregated_address}, wallet::{Wallet, BackupTx, Coin}, transaction:: get_user_backup_address, utils::get_blockheight};

use crate::{client_config::ClientConfig, sqlite_manager::{get_wallet, update_wallet}, transaction::new_transaction, utils::info_config};

Expand All @@ -23,19 +23,8 @@ pub async fn get_deposit_bitcoin_address(client_config: &ClientConfig, wallet_na
Ok(aggregated_public_key.aggregate_address)
}

pub async fn create_tx1(client_config: &ClientConfig, coin: &mut Coin, wallet_netwotk: &str, tx0_hash: &str, tx0_vout: u32) -> Result<BackupTx> {

if coin.status != CoinStatus::INITIALISED {
return Err(anyhow!("The coin with the public key {} is not in the INITIALISED state", coin.user_pubkey.to_string()));
}

if coin.utxo_txid.is_some() && coin.utxo_vout.is_some() {
return Err(anyhow!("The coin with the public key {} has already been deposited", coin.user_pubkey.to_string()));
}
coin.utxo_txid = Some(tx0_hash.to_string());
coin.utxo_vout = Some(tx0_vout);

coin.status = CoinStatus::IN_MEMPOOL;
// When sending duplicated coins, the tx_n of the backup_tx must be different
pub async fn create_tx1(client_config: &ClientConfig, coin: &mut Coin, wallet_netwotk: &str, tx_n: u32) -> Result<BackupTx> {

let to_address = get_user_backup_address(&coin, wallet_netwotk.to_string())?;

Expand Down Expand Up @@ -73,7 +62,7 @@ pub async fn create_tx1(client_config: &ClientConfig, coin: &mut Coin, wallet_ne
}

let backup_tx = BackupTx {
tx_n: 1,
tx_n,
tx: signed_tx,
client_public_nonce: coin.public_nonce.as_ref().unwrap().to_string(),
server_public_nonce: coin.server_public_nonce.as_ref().unwrap().to_string(),
Expand Down
1 change: 1 addition & 0 deletions clients/libs/rust/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ pub use mercurylib::wallet::CoinStatus;
pub use mercurylib::wallet::Coin;
pub use mercurylib::wallet::BackupTx;
pub use mercurylib::wallet::Activity;
pub use mercurylib::wallet::get_previous_outpoint;

pub use mercurylib::transfer::sender::{TransferSenderRequestPayload, TransferSenderResponsePayload, create_transfer_signature, create_transfer_update_msg};
pub use mercurylib::transaction::{SignFirstRequestPayload, SignFirstResponsePayload, create_and_commit_nonces};
Expand Down
23 changes: 14 additions & 9 deletions clients/libs/rust/src/sqlite_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,14 @@ pub async fn update_wallet(pool: &Pool<Sqlite>, wallet: &Wallet) -> Result<()> {
Ok(())
}

pub async fn insert_backup_txs(pool: &Pool<Sqlite>, statechain_id: &str, backup_txs: &Vec<BackupTx>) -> Result<()> {
pub async fn insert_backup_txs(pool: &Pool<Sqlite>, wallet_name: &str, statechain_id: &str, backup_txs: &Vec<BackupTx>) -> Result<()> {

let backup_txs_json = json!(backup_txs).to_string();

let query = "INSERT INTO backup_txs (statechain_id, txs) VALUES ($1, $2)";
let query = "INSERT INTO backup_txs (wallet_name, statechain_id, txs) VALUES ($1, $2, $3)";

let _ = sqlx::query(query)
.bind(wallet_name)
.bind(statechain_id)
.bind(backup_txs_json)
.execute(pool)
Expand All @@ -68,27 +69,29 @@ pub async fn insert_backup_txs(pool: &Pool<Sqlite>, statechain_id: &str, backup_
Ok(())
}

pub async fn update_backup_txs(pool: &Pool<Sqlite>, statechain_id: &str, backup_txs: &Vec<BackupTx>) -> Result<()> {
pub async fn update_backup_txs(pool: &Pool<Sqlite>, wallet_name: &str, statechain_id: &str, backup_txs: &Vec<BackupTx>) -> Result<()> {

let backup_txs_json = json!(backup_txs).to_string();

let query = "UPDATE backup_txs SET txs = $1 WHERE statechain_id = $2";
let query = "UPDATE backup_txs SET txs = $1 WHERE statechain_id = $2 AND wallet_name = $3";

let _ = sqlx::query(query)
.bind(backup_txs_json)
.bind(statechain_id)
.bind(wallet_name)
.execute(pool)
.await?;

Ok(())
}

pub async fn get_backup_txs(pool: &Pool<Sqlite>, statechain_id: &str,) -> Result<Vec<BackupTx>> {
pub async fn get_backup_txs(pool: &Pool<Sqlite>, wallet_name: &str, statechain_id: &str,) -> Result<Vec<BackupTx>> {

let query = "SELECT txs FROM backup_txs WHERE statechain_id = $1";
let query = "SELECT txs FROM backup_txs WHERE statechain_id = $1 AND wallet_name = $2";

let row = sqlx::query(query)
.bind(statechain_id)
.bind(wallet_name)
.fetch_one(pool)
.await?;

Expand All @@ -103,23 +106,25 @@ pub async fn get_backup_txs(pool: &Pool<Sqlite>, statechain_id: &str,) -> Result
Ok(backup_txs)
}

pub async fn insert_or_update_backup_txs(pool: &Pool<Sqlite>, statechain_id: &str, backup_txs: &Vec<BackupTx>) -> Result<()> {
pub async fn insert_or_update_backup_txs(pool: &Pool<Sqlite>, wallet_name: &str, statechain_id: &str, backup_txs: &Vec<BackupTx>) -> Result<()> {

let mut transaction = pool.begin().await?;

let backup_txs_json = json!(backup_txs).to_string();

let query = "DELETE FROM backup_txs WHERE statechain_id = $1";
let query = "DELETE FROM backup_txs WHERE statechain_id = $1 AND wallet_name = $2";

let _ = sqlx::query(query)
.bind(statechain_id)
.bind(wallet_name)
.execute(&mut *transaction)
.await?;

let query = "INSERT INTO backup_txs (statechain_id, txs) VALUES ($1, $2)";
let query = "INSERT INTO backup_txs (statechain_id, wallet_name, txs) VALUES ($1, $2, $3)";

let _ = sqlx::query(query)
.bind(statechain_id)
.bind(wallet_name)
.bind(backup_txs_json)
.execute(&mut *transaction)
.await?;
Expand Down
Loading
Loading