* client: use native tls and disable default features for reqwest
* build: bring back reqwest default features except tls
* client: remove tls selection
* config: global instance
* fix: cli tests
* fix: owner api tests
* config: save tor config
* fix: owner rpc tests
* fix: set config file path on init and owner api call
* tor: store launched services, get global config at command loop, remove unused listen args, check for empty global config to set default, do not save empty tor config at owner
* api: update config in memory after successful file write
* arti: restart proxy in loop
* fix: comment for tor config save
* config: set or init, update without error
* config: scoped tor config
* build: update lock file
* config: ability to store multiple configurations at memory from config path
* tor: restart service on config change
* fix: owner api test
* foreign: pass tor config from args, stop service, error handling
* arti: move runtime wrapper to single file
* config: read existing config from file at create_config
* config: handle error on read
* arti: single dir for cache
* foreign: register config listener before launch
* config: save temp
* config: remove unused error type
* config: make path and members not optional, return an error on config creation if it exists, pass default tor config to send if not set
* arti: non public runtime wrapper
* config: migrate comments
* fix: rpc tests
* config: return from cache if exists
* config: save disabled tor config when null provided at owner and tor section was not set
* config: update tor with args at listener
* config: pass pathbuf directly on creation
* config: unique tmp file name, setting permissions and providing config version
* fix global config handling
* fix config persistence
* fix tor service restart
* fix config synchronization
* require wallet close before changing data directory
* unify global config updates
---------
Co-authored-by: wiesche <wiesche89@googlemail.com>
* tor: global client state
* tor: optimize init client thread-safety
* tor: handle config change on client init
* tor: add logging for client reuse or reinit
* tor: do not reuse arti client for requests
* tor: integrated client for listener, update tokio to last version
* tor: send transaction with integrated client
* build: code format
* tor: optimize bootstrap percent check
* tor: handle config build error
* tor: do not show slatepack address if tor not launched
* tor: handle keystore errors
* tor: keep service launched
* tor: bootstrap timeout, clean cache before client launch
* tor: post request timeout
* fix: post timeout
* build: update deps after merge
* tor: store arti runtime
* tor: do not send over tor if `manual` arg presents or `skip_send_attempt` set at config
* fix: arg name
* tor: handle arti runtime creation error
* tor: handle connection error
* tor: handle bootstrap error
* tor: handle start service name error
* tor: handle service config creation error
* tor: service proxy errors
* tor: handle service key creation emptiness
* build: format code
* build: update arti to 0.43, hyper to 0.10.1
* api: start foreign listener before tor connection
* tor: handle json parse errors
* tor: prevent to create several client runtimes, ability to recreate
* tor: return bootstrap error
* tor: handle host parse error
* tor: restart proxy on error
* tor: do not use integrated client when config value use_integrated is missing, add logging
* build: update lock file
* wallet: update lmdb from store crate, migrate single backend from trait to struct, update tests cargo deps and design doc
* backend: do not panic on iter and directory creation
* return iterator errors
* build: update to last node revision
* fix: height selection for scan, remove unused mutability for wallet
* wallet: remove unused mutability conversion
* tx: store slate state at database
* build: cargo fmt
* fix: do not return error when slate not found on tx slate state update
* lmdb: do not collect all tx log records at iterator, show read errors at log
* fix: save slate state, return error if slate not found
* tx: specify amount of bad txs on slate state update error
---------
Co-authored-by: Joerg <wiesche89@googlemail.com>
* scan: save last scanned block info for initial wallet scanning
* scan: save start height at scanned block info on outputs collecting
* scan: 10k blocks batches
* fix: include last height into batch on scan
* scan: save hash of last block
* scan: add larger window (2880 blocks) to scan outputs when updating wallet state
* add test batched scan and resume, add scan doc
* rename corrupted restore test
---------
Co-authored-by: Joerg <wiesche89@googlemail.com>
The introduction still described a /setup endpoint that no longer exists
and called view and revoke future work. Describe the lifecycle as it is:
setup is a step inside new and sign, not a call, and all four actions
have owner API methods and commands.
Prune the TODO and test lists to what is still open, and record what the
contract flows do not support.
save_step writes the signed transaction after the wallet state batch has
committed, so the write can fail with the tx log entry and the input
locks already persisted. store_tx writes a file outside LMDB, as it does
for every transaction in the wallet, so the two cannot share a commit
without moving stored transactions into the database, which backend.rs
already carries a TODO for. Cancelling is the way out: it releases the
inputs without reading the stored tx, and nothing has been broadcast
because the error returns before the caller posts. Tested by removing
the file and cancelling.
Also set stored_tx on the entry, as internal::selection does for a
standard send. It was left unset, so txs reported no transaction data
for every contract even though the transaction was stored.
InvoiceProofBin is a normal Readable, so a malformed encoding must come
back as a serialization error. The two secp keys, the ed25519 sender
address and the memo were unwrapped or copied without a length check.
Map them all to grin_ser errors, and take the proof type with a cast
that cannot lose data rather than a fallible conversion.
controller/tests/contract/mod.rs was never declared as a test module, so
none of it was compiled, and most of it was commented out. Its
create_wallets is an older copy of the one in the shared test module,
which every contract test already uses.
contract view was in the CLI help but the command returned Not
implemented, and there was no owner API entry point for the existing
libwallet implementation. Add owner::contract_view through to the CLI
and the owner RPC, with a display for the result.
The slate is taken from --input or prompted for, as receive does.
is_executed was hardcoded to false. Derive it from our own tx log entry
for the slate, which is confirmed once the contract has executed.
print_slatepack unwrapped prepare_slatepack, which fails on ordinary
file, serialization and encryption errors, so those reached the user as
a panic. Return a Result and propagate it from the contract commands.
Reading the slatepack from stdin used expect for the same reason.
cancel_tx committed each entry separately, so a failure part way through
left some entries cancelled and the rest untouched, and a retry then
stopped on the entry that was already cancelled. Collect the entries and
their outputs first and cancel them in a single commit, so the partial
state cannot arise.
Cancelling an already cancelled transaction still reports an error, as
db_wallet_tx_rollback expects.
add_keys matched a participant on the public excess alone, so an entry
carrying our excess with a nonce that is not ours counted as ours and the
full-slate guard was skipped. add_participant_info only replaces an entry
when both keys match, so that entry was kept and ours appended, leaving a
two party slate with three participants. pub_nonce_sum and pub_blind_sum
fold in every entry, so the partial signature is then made over an
aggregate that includes the spurious one. Match on the excess and nonce
pair, the same test add_participant_info and fill_round_2 already apply,
and reject a list carrying our excess with a foreign nonce rather than
treating that entry as ours.
transition_state turned every other state, including Unknown and an
already completed slate, into a successful Standard3. That happens after
signing and before the wallet state is persisted, so accept only the four
transitions the contract flows use and report anything else.
* client: use native tls and disable default features for reqwest
* build: bring back reqwest default features except tls
* client: remove tls selection
- Context::get_net_change unwrapped setup_args, which is None for the
standard flows that share Context, so a non-contract context reaching
a contract path terminated the wallet. It returns a Result now.
- A recomputed fee that no longer matches the stored one was an
assert_eq, which aborts; report both values instead.
- Selection used abs(), which panics on i64::MIN, and unchecked addition
for the amount equation.
- build_output_amount_list subtracted the custom output sum from the
input sum as u64, before the checked conversion that was meant to
guard it. A receiver without a payjoin contributes no inputs while
--make-outputs is still allowed, so that underflows. The balance is
evaluated in checked i64 now, with a test for the no-payjoin case.
add_payment_proof read the clock again after generate_invoice_signature
had already signed over its own reading. The promise signature binds the
timestamp, so a tick between the two reads produced a proof that failed
verification with 'Invalid recipient signature'.
Carry over the timestamp that was signed.
find_index_matching_context accepted an entry matching either our excess
or our nonce, while fill_round_2 requires both, so the two could disagree
on which entry is ours and signing could return success without adding a
signature. Both also indexed participant_data by position up to
num_participants, which a counterparty can send short.
Match on both keys and iterate the entries the slate carries. Require the
participant count to be exact before signing a contract, and check for two
participants in the contract tx log before pairing them with 'xor 1'.
A legacy send proof uses no V5 field: V4 carries the sender and receiver
addresses and the signature, and only the timestamp and memo need V5.
Sending those as V5 stopped V4-only wallets from reading the slate.
Add SlateVersion::lowest_for and use it from create_slatepack and from
the contract owner API methods, which returned V4 unconditionally and so
dropped the timestamp and memo that an early proof's promise signature
binds. contract_sign keeps the version the counterparty sent when the
slate does not need more.
VersionedSlate and VersionedBinSlate are untagged and try V5 first, so
without a version check a V4 slate parses as V5. Only visible without a
payment proof; with one the V4 and V5 proof shapes differ enough for
serde to pick the right variant by chance.
Reject a mismatched version in the V4 and V5 deserializers, for both the
JSON and binary encodings, and set the declared version from the
conversion so it always matches the structure emitted. Add V4/V5 round
trip tests over both encodings, with and without a proof.
The V3 API examples showed V4 slates declaring version 5; they now
declare 4.
NaiveDateTime::from_timestamp_opt and DateTime::from_utc are deprecated
in favour of DateTime::from_timestamp.
Two call sites in contract::proofs converted a timestamp to a
NaiveDateTime and immediately back to the same i64; those now use the
value directly, which also removes an unwrap.
- Remove unused imports in api_impl::owner, backend, contract::utils,
v5_bin and the contract tests.
- Remove unused test bindings, and document the shared slate test
fixtures module.
- Drop the commented-out assertion block in the mwixnet contract test,
along with the height bookkeeping and import that only it used.
Brings the branch current with staging for review.
- ed25519-dalek 1.0.0-pre.4 to 2: PublicKey is now VerifyingKey, Keypair
is replaced by SigningKey, and from_bytes takes a fixed-size array.
Ported the contract proof code and the V5 slate serializers, following
the pattern staging already uses in v4_bin.
- owner_single_use and foreign_single_use now take the wallet instance
and a config path rather than an optional API handle. Updated the
contract call sites in command.rs and the contract tests.
- update_tx_slate_state moved to api_impl::types; dropped the local copy.
- Took staging's fixed-size-array form of the slate signature guards; it
is equivalent to 25a5434 and keeps the file in sync with upstream.
- The grin node is now a submodule, so a build needs
git submodule update --init.