Commit Graph

30 Commits

Author SHA1 Message Date
Louis Singer
7606b4cd00 Drop unconditional forfeits txs in offline payment (#344)
* remove unconditionnal forfeit tx

* fix sqlite vtxo repo

* remove pendingData struct

* delete uncond_forfeits_tx table
2024-10-04 18:06:00 +02:00
Dusan Sekulic
d37af7daf5 Add GetTransactionsStream RPC (#345)
* RPC GetPaymentsStream

This introduces a new feature to the ArkService API that allows clients to subscribe to payment events. Here's a breakdown of the changes:

1. **OpenAPI Specification (`service.swagger.json`):**
   - A new endpoint `/v1/payments` is added to the API, supporting a `GET` operation for streaming payment events.
   - New definitions `v1GetPaymentsStreamResponse`, `v1RoundPayment`, and `v1AsyncPayment` are added to describe the structure of the streaming responses.

2. **Protobuf Definition (`service.proto`):**
   - Added a new RPC method `GetPaymentsStream` that streams `GetPaymentsStreamResponse` messages.
   - Defined new message types: `GetPaymentsStreamRequest`, `GetPaymentsStreamResponse`, `RoundPayment`, and `AsyncPayment`.

3. **Generated Protobuf Code (`service.pb.go`, `service.pb.gw.go`, `service_grpc.pb.go`):**
   - The generated code is updated to include the new RPC method and message types.
   - The gateway code includes functions to handle HTTP requests and responses for the new streaming endpoint.

4. **Application Logic (`covenant.go`, `covenantless.go`):**
   - New payment events channels are introduced (`paymentEventsCh`).
   - Payment events are propagated to these channels when a round is finalized or an async payment is completed.
   - New event types `RoundPaymentEvent` and `AsyncPaymentEvent` are defined, implementing a `PaymentEvent` interface.

5. **gRPC Handlers (`arkservice.go`):**
   - Added logic to handle `GetPaymentsStream` requests and manage payment listeners.
   - A new goroutine is started to listen to payment events and forward them to active listeners.

Overall, this patch extends the ArkService to support real-time streaming of payment events, allowing clients to receive updates on both round payments and async payments as they occur.

* Move emit events in updateVtxoSet & Use generics and parsers (#1)

* Move sending event to updateVtxoSet

* Use generics and parsers

* pr review refactor

* pr review refactor

* fix

---------

Co-authored-by: Pietralberto Mazza <18440657+altafan@users.noreply.github.com>
2024-10-04 12:23:16 +02:00
Pietralberto Mazza
3271776954 Rename API fields (#337)
* Update api-spec

* Update ASP (also domain to drop "pool" completely)

* Update sdk

* Update protos

* Update asp

* Update sdk

* Fixes
2024-09-27 15:35:31 +02:00
Pietralberto Mazza
f36a747c59 API Renaming (#334)
* Update service.proto

Signed-off-by: Marco Argentieri <3596602+tiero@users.noreply.github.com>

* Update buf.yaml

* Fix API order and naming

* Update server

* Update sdk

* Revert update to buf.yaml

* Fix permissions

---------

Signed-off-by: Marco Argentieri <3596602+tiero@users.noreply.github.com>
Co-authored-by: Marco Argentieri <3596602+tiero@users.noreply.github.com>
2024-09-26 19:21:41 +02:00
Louis Singer
2be78b0115 Add forfeit address in GetInfo (#326)
* keep track of forfeit transaction funds

* [btc-embedded] use p2wpkh address

* [sdk] fix clients

* use script as argument of BuildForfeitTxs
2024-09-25 13:15:44 +02:00
Louis Singer
9e3d667b51 Fix: "tree signing session not found" error (#323)
* failing test

* fix duplicate input register

* fix btc-embedded coin selection

* rename test

* add checks in failing test case

* fixes GetEventStream

* add TODO comment in createPoolTx

* update with master changes

* fix server unit test

* increase liquidity of testing ASP

* simplify AliceSeveralPaymentsBob test
2024-09-20 12:03:12 +02:00
Pietralberto Mazza
5c2065ad47 Make change of async payment spendable (#324)
* Drop unused ComputeOutputScript & use ParseTaprootScript internally

* Add pending field to vtxo domain

* Add check to handle async change as claimed vtxo & Move check to prevent spending penidng vtxos to app level

* Rename utils.go to parser.go & Fixes

* Ignore sent-and-reversible vtxos in ListVtxos

* Fixes

Co-authored-by: Louis Singer <louisinger@users.noreply.github.com>

* Fix e2e test

Co-authored-by: Louis Singer <louisinger@users.noreply.github.com>
Co-authored-by: João Bordalo <bordalix@users.noreply.github.com>

* Fix

* Add PendingChange field to vtxo

* Add PendingChange field to Transaction

* Fixes

* Remove logs

---------

Co-authored-by: Louis Singer <louisinger@users.noreply.github.com>
Co-authored-by: João Bordalo <bordalix@users.noreply.github.com>
2024-09-19 19:44:22 +02:00
Louis Singer
10ef0dbffa Add reversible policy to pending vtxos (#311)
* [server] descriptor-based vtxo script

* [server] fix unit tests

* [sdk] descriptor based vtxo

* empty config check & version flag support

* fix: empty config check & version flag support (#309)

* fix

* [sdk] several fixes

* [sdk][server] several fixes

* [common][sdk] add reversible VtxoScript type, use it in async payment

* [common] improve parser

* [common] fix reversible vtxo parser

* [sdk] remove logs

* fix forfeit map

* remove debug log

* [sdk] do not allow reversible vtxo script in case of self-transfer

* remove signing pubkey

* remove signer public key, craft forfeit txs client side

* go work sync

* fix linter errors

* rename MakeForfeitTxs to BuildForfeitTxs

* fix conflicts

* fix tests

* comment VtxoScript type

* revert ROUND_INTERVAL value

---------

Co-authored-by: Pietralberto Mazza <18440657+altafan@users.noreply.github.com>
Co-authored-by: sekulicd <sekula87@gmail.com>
2024-09-19 10:01:33 +02:00
Louis Singer
0fb34cb13d Dynamic min-relay-fee and dust amount (#280)
* [btc-embedded] add chainfee.Estimator and extraAPI interfaces

* dynamic fee amount

* dynamic dust amount

* [client] fix linter errors

* [domain] fix unit tests

* [server] return dust amount in GetInfo RPC

* [sdk] fix lnd dependencie

* go work sync

* fix witness stack size forfeit tx size estimator

* remove hardcoded fee values in covenant txbuilder

* lower liquid feerate

* fix after reviews

* go work sync
2024-09-10 17:22:09 +02:00
Louis Singer
4da76ec88b New boarding protocol (#279)
* [domain] add reverse boarding inputs in Payment struct

* [tx-builder] support reverse boarding script

* [wallet] add GetTransaction

* [api-spec][application] add reverse boarding support in covenantless

* [config] add reverse boarding config

* [api-spec] add ReverseBoardingAddress RPC

* [domain][application] support empty forfeits txs in EndFinalization events

* [tx-builder] optional connector output in round tx

* [btc-embedded] fix getTx and taproot finalizer

* whitelist ReverseBoardingAddress RPC

* [test] add reverse boarding integration test

* [client] support reverse boarding

* [sdk] support reverse boarding

* [e2e] add sleep time after faucet

* [test] run using bitcoin-core RPC

* [tx-builder] fix GetSweepInput

* [application][tx-builder] support reverse onboarding in covenant

* [cli] support reverse onboarding in covenant CLI

* [test] rework integration tests

* [sdk] remove onchain wallet, replace by onboarding address

* remove old onboarding protocols

* [sdk] Fix RegisterPayment

* [e2e] add more funds to covenant ASP

* [e2e] add sleeping time

* several fixes

* descriptor boarding

* remove boarding delay from info

* [sdk] implement descriptor boarding

* go mod tidy

* fixes and revert error msgs

* move descriptor pkg to common

* add replace in go.mod

* [sdk] fix unit tests

* rename DescriptorInput --> BoardingInput

* genrest in SDK

* remove boarding input from domain

* remove all "reverse boarding"

* rename "onboarding" ==> "boarding"

* remove outdate payment unit test

* use tmpfs docker volument for compose testing files

* several fixes
2024-09-04 19:21:26 +02:00
Louis Singer
c183f99244 Make the round participants sign the vtxo tree (#271)
* [proto] add APIs to send and receive musig2 signing data

* [common] add serialization functions for nonces and signatures

* [application] implements tree signing

* fix: remove old debug logs

* [proto] cleaning

* [common] fix musig2.go

* [application] fixes and logs

* [interface] fix: stop forwarding 2 times the events

* [client] add musig2 support + sign the tree when joining a round

* [interface] add new APIs into permissions.go

* [application][proto] rework PingResponse (return all events type)

* [common] split SetKeys into 2 distinct methods

* [client] fixes according to musig2.go changes

* [sdk] support tree signing + new PingResponse

* [sdk] fixes

* [application] revert event channel type

* [application] use domain.RoundEvent as lastEvent type

* [application] remove IsCovenantLess

* comments

* [application] revert roundAborted changes

* [interface] remove bitcointree dependencie
2024-08-30 14:32:35 +02:00
Marco Argentieri
1b0252f3e4 Migrate to Go Workspaces (#243)
* api-spec: move the api-spec to root and init go.mod

* go mod tidy

* move buf files in the root as well

* gh action for api-spec changes only

* gh action for api-spec on push and pr

* introduce go.work and remove all replaces

* solve dependencies and force btcd/btcec@v2.3.3

* go work sync

* force btcd/btcec@v2.3.3

* go mod tidy
2024-08-13 03:27:41 +02:00
Pietralberto Mazza
72a7f29bab Add CreatePayment and CompletePayment (#229)
Co-authored-by: Marco Argentieri <tiero@users.noreply.github.com>

* Add claim command

* Persist pending data in sqlite repo

* Remove debug log

* Return pending data at interface level

* Fix unlocking btc wallet after restart

* Lint & Fix whitelist permissions

* Fix send command for covenant

* Update client/covenantless/claim.go

Signed-off-by: Marco Argentieri <3596602+tiero@users.noreply.github.com>

* Fix

* Pay for min relay fee instead of estimating fees for redeem and unconf forfeit txs

* Add support for pending payments (coventanless)

* Fixes

* Fixes

* Improve verbosity

* Fix coin selection

* Fix

---------

Signed-off-by: Marco Argentieri <3596602+tiero@users.noreply.github.com>
Co-authored-by: louisinger <louis@vulpem.com>
Co-authored-by: Marco Argentieri <tiero@users.noreply.github.com>
Co-authored-by: Marco Argentieri <3596602+tiero@users.noreply.github.com>
2024-08-10 19:18:02 +02:00
Pietralberto Mazza
57ce08f239 Support macaroons and TLS && Add arkd wallet cmds (#232)
* Update protos

* Update handlers

* Support macaroons and TLS

* Add arkd cli

* Minor fixes

* Update deps

* Fixes

* Update makefile

* Fixes

* Fix

* Fix

* Fix

* Remove trusted onboarding from client

* Completely remove trusted onboarding

* Fix compose files and add --no-macaroon flag to arkd cli

* Lint

* Remove e2e for trusted onboarding

* Add sleep time
2024-08-09 17:59:31 +02:00
Dusan Sekulic
1f42843a69 Add first version of client SDK (#193)
* Add gRPC, REST, and gRPC-Web clients for server access

This commit introduces clients for gRPC, REST, and gRPC-Web to access the server.

- gRPC client: Includes additional argument opts ...grpc.CallOption in the interface for future extensibility.
- REST client: Factory function accepts http.Client as an argument to allow user customization.
- gRPC-Web client: Added a Log method for fast debugging in JavaScript.

The decision to use different interfaces for each client type is to accommodate specific features and extensibility requirements for each protocol.

* remove grpc web

* generate rest

* use grpc sdk in CLI

* temp wasm

* ark sdk

* renaming

* pr review refactor

* pr review refactor

* walletStore & configStore

* ark sdk wasm wrapper

* handle event stream with rest

* wip on supporting rest

* store init

* simulate event stream with rest

* fix rest sdk wip

* Fix returning forfeit txs in round event

* wasm first working e2e example

* pr review refactor

* pr review refactor

* pr review refactor

* Fixes

---------

Co-authored-by: altafan <18440657+altafan@users.noreply.github.com>
2024-07-18 16:27:14 +02:00
Pietralberto Mazza
498394a191 Add endpoint to get round via id & round stage (#202) 2024-07-12 15:42:21 +02:00
Pietralberto Mazza
4ff1c7c87a Add RoundFinalizationEvent to PingResponse (#200) 2024-07-11 14:21:12 +02:00
Louis Singer
dca302df69 Dynamic amount in unroll closure (#173)
* update UnrollClosure

* update TrustedOnboarding flow + add TrustedOnboarding e2e test

* fix linter: grpc.Dial

* add comment

* integration tests: faucet the ASP with 2 utxos
2024-05-28 12:13:03 +02:00
Louis Singer
34aff2c4c3 ListVtxos rpc: return swept vtxos (#168) 2024-05-06 11:09:11 -05:00
Louis Singer
f1b83bd522 Add expireAt member in ListVtxo RPC (#160) 2024-05-01 16:42:13 +02:00
Louis Singer
02ff7c7ed9 Add roundInterval, network and minRelayFee to GetInfo RPC (#159) 2024-05-01 16:15:29 +02:00
Louis Singer
3597594fe7 add spentBy member in ListVtxos 2024-04-30 17:46:12 +02:00
Louis Singer
dc64947d28 returns forfeitsTxs in Ping RPC while the finalization started (#161) 2024-04-29 18:58:11 +02:00
Pietralberto Mazza
7fc8d7d07d Get current round & Return spent vtxos for user (#139) 2024-04-23 16:14:35 +02:00
Louis Singer
740d4fb7b1 Add TrustedOnboarding RPC (#138)
* add CreateOnboardingAddress rpc

* add TrustedOnboarding rpc

* remove log.Info in notifications.go
2024-04-23 14:54:27 +02:00
Pietralberto Mazza
fb64bd35d8 Support connectors validation client-side & Minor fixes (#126)
* Validate connectors client-side when sending offchain

* Minor fixes

* validate connector input in forfeit txs

---------

Co-authored-by: Louis <louis@vulpem.com>
2024-03-05 13:04:32 +01:00
Pietralberto Mazza
6d0d03e316 Cleanup (#121)
* Cleanup common

* Cleanup client

* Cleanup server

* Renamings

* Tidy up proto

* Update ocean protos

* Fixes

* Fixes
2024-02-28 18:05:03 +01:00
Pietralberto Mazza
1650ea5935 Support onboarding & Drop faucet (#119)
* Renaming

* Add server-side support for onboarding

* add onboard --amount command

* support client side onboarding

* Drop dummy tx builder

* Drop faucet

* Fixes

* fix public key encoding

* fix schnorr pub key check in validation

* fix server/README to accomodate onboarding

---------

Co-authored-by: Louis <louis@vulpem.com>
Co-authored-by: João Bordalo <bordalix@users.noreply.github.com>
2024-02-23 16:24:00 +01:00
Louis Singer
a95a829b20 Delay unilateral exit and support send to onchain address (#117)
* add delay on redeem close + forfeit close

* increase default round lifetime (16 minutes min)

* add sequence to final pset

* update CLI and server to support delayed vtxos oncahin

* rename future to "locked"

* add configurable EXIT_DELAY variable

* renaming

* rename "close" --> "closure"

* rename "close" to "closure"

* error message config.go
2024-02-22 16:47:52 +01:00
Pietralberto Mazza
dc00d60585 Rename folders (#97)
* Rename arkd folder & drop cli

* Rename ark cli folder & update docs

* Update readme

* Fix

* scripts: add build-all

* Add target to build cli for all platforms

* Update build scripts

---------

Co-authored-by: tiero <3596602+tiero@users.noreply.github.com>
2024-02-09 19:32:58 +01:00