Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
88 commits
Select commit Hold shift + click to select a range
f0cf8b0
Simple contracts restructured v3 (#675)
Mar 20, 2023
2c38081
contract test fixes (#676)
Mar 22, 2023
23baff1
Merge branch 'master' into contracts
Apr 12, 2023
063e91d
[Contracts] Experimental Slate v5 (#677)
Apr 18, 2023
ddd3e01
Merge branch 'master' into contracts
Aug 1, 2023
54ee12a
update
Aug 2, 2023
e674c4a
Merge branch 'master' into contracts
Aug 8, 2023
1c6442c
commit cargo.lock
Aug 8, 2023
58659d8
Merge branch 'contracts' of https://github.com/mimblewimble/grin-wall…
Aug 8, 2023
e3148d0
[WIP] [Contracts] Early payment proofs (#681)
Aug 8, 2023
3da7695
fix Cargo.lock
Aug 8, 2023
fa78d72
Contracts - Test fixes + warning cleanups (#694)
Aug 10, 2023
008d2a8
added explicit payment proof tests for both rsr and srs (#695)
Aug 12, 2023
165632b
Basic mwmixnet send (#696)
Oct 3, 2023
febffd4
[Contracts] Add self spend transaction state (#697)
Oct 19, 2023
b3d90c9
[Contracts] Slatepack v5 Deserialization fix (#698)
Nov 21, 2023
02af391
update cargo lock, use latest grin packages
Feb 8, 2024
074fa24
addition of self-spend cancel + tests (#699)
Feb 15, 2024
f94a0a4
add tests + legacy self send cancel (#702)
Feb 22, 2024
6f226ea
[Contracts] Cancel self-spend TX Pt. 2 (#703)
Feb 23, 2024
57bf8be
merge from 5.3.0 master release
Apr 30, 2024
d8d1269
Merge branch 'master' into contracts
May 20, 2024
c06c91d
Update grin to latest master, change versioning label to include cont…
May 20, 2024
93464a8
Add owner_api_listen_interface as hidden configuration field (#714)
May 30, 2024
5e69881
updates for rust 1.80
Aug 26, 2024
d022f26
updates for rust 1.80
Aug 26, 2024
0b24640
update from 1_80 branch
Aug 27, 2024
96b5d24
[CONTRACTS] update/rename mwixnet onion classes (#719)
Aug 27, 2024
5327f2c
[CONTRACTS] Add Owner API function to create mwixnet request (#720)
Sep 3, 2024
f7d3692
Merge branch 'master' into contracts
jwinterm Jun 2, 2026
79a4031
Fix VersionedSlate::version() misreporting V5 slates as V4
jwinterm Jun 2, 2026
475db1d
Fix contract_srs_mwmixnet test import after merge
jwinterm Jun 3, 2026
46999ce
Make payment proofs opt-in to fix #729
jwinterm Jun 3, 2026
25dab9f
Harden v5 payment-proof deserialization against malformed input
jwinterm Jun 3, 2026
311140f
De-panic contract CLI argument parsing
jwinterm Jun 3, 2026
3a86bb4
Replace reachable panics in contract flow with typed errors
jwinterm Jun 3, 2026
9d040b4
Harden the contract signing-context forget invariant
jwinterm Jun 3, 2026
2e3b044
De-panic and validate contract CLI input handling
jwinterm Jun 3, 2026
3fcf3b7
De-panic output_amounts(): fallible make-outputs parsing
jwinterm Jun 3, 2026
b7b7a6d
Merge upstream staging into contracts
jwinterm Jun 3, 2026
4fcb605
Make contract slatepack encryption optional
jwinterm Jun 4, 2026
8c7c0d0
Contracts: derive output keys under the contract's account
jwinterm Jun 4, 2026
382cf86
Contracts: parse amounts exactly, not via f64
jwinterm Jun 4, 2026
571b1f9
Contracts: only create a context on a genuine miss
jwinterm Jun 4, 2026
15cbbc9
Contracts: validate net_change instead of unwrapping
jwinterm Jun 4, 2026
62ede41
Contracts: emit the lowest slatepack version needed
jwinterm Jun 5, 2026
502d2ae
Contracts: revoke under the inputs' account, not the active one
jwinterm Jun 5, 2026
d4d5f97
Contracts: validate net_change in the foreign sign path
jwinterm Jun 7, 2026
5cc1683
Contracts: validate num_participants before fee math
jwinterm Jun 7, 2026
b3f75ee
Contracts: use checked conversions for amount -> i64
jwinterm Jun 7, 2026
62fc942
Contracts: use Error::Fee for the fee-overshoot error
jwinterm Jun 7, 2026
9bf11fb
Contracts: derive the proof address under the contract's account
jwinterm Jun 7, 2026
7982f17
Contracts: reject a slate that already has all participants
jwinterm Jun 7, 2026
5569d38
Contracts: test selection-args consistency and fee splitting
jwinterm Jun 7, 2026
756664e
Contracts: remove the unused target_slate_version field
jwinterm Jun 7, 2026
bcea98b
Contracts: remove the commented-out contract_setup
jwinterm Jun 7, 2026
1d89ec2
Contracts: report agreed_net_change in contract view
jwinterm Jun 7, 2026
1b3d773
Contracts: delete the canceled context on revoke
jwinterm Jun 7, 2026
18167be
Contracts: tidy review TODOs, document the owner API, simplify get_ne…
jwinterm Jun 7, 2026
db52b2e
Contracts: resolve remaining review TODOs
jwinterm Jun 8, 2026
3fba131
Merge upstream staging (#755 multi-LMDB backend) into contracts
jwinterm Jun 10, 2026
f13ea7f
Contracts: make_outputs takes nanogrin amounts (Vec<u64>), not a string
jwinterm Jun 10, 2026
1489874
Contracts: replace reachable panics with errors
jwinterm Jun 10, 2026
25a5434
Slate: length-check ed25519/uuid fields in the JSON serde path
jwinterm Jun 10, 2026
a134158
Contracts: store the signed tx after the wallet-state commit
jwinterm Jun 10, 2026
c7acc8e
Contracts: make revoke idempotent and resumable
jwinterm Jun 10, 2026
55a0d43
Contracts: deterministic self-spend id so an interrupted revoke resumes
jwinterm Jun 10, 2026
a9cf8ef
Contracts: validate the slate in contract view
jwinterm Jun 10, 2026
2106c08
Slate: document that the proof-downgrade placeholder key is inert
jwinterm Jun 10, 2026
178deac
Contracts: remove the stale contract_setup RPC stubs and tidy the README
jwinterm Jun 10, 2026
894023a
Merge upstream staging into contracts
jwinterm Jul 26, 2026
fb10280
Contracts: apply rustfmt to the contract module
jwinterm Jul 26, 2026
6c70266
Contracts: clear the warnings introduced by this PR
jwinterm Jul 26, 2026
1f035e3
Contracts: replace the deprecated chrono calls
jwinterm Jul 26, 2026
5397cef
Slate: validate the declared version when deserializing
jwinterm Jul 26, 2026
80e1c29
Contracts: emit the lowest slate version that fits the payment proof
jwinterm Jul 26, 2026
f594bb0
Slate: match a participant on both keys and validate the count
jwinterm Jul 27, 2026
43d14eb
Contracts: sign and store the same payment proof timestamp
jwinterm Jul 27, 2026
78aa41c
Contracts: return errors for the remaining reachable panics
jwinterm Jul 27, 2026
949066e
Contracts: reject an inconsistent participant list and slate state
jwinterm Jul 27, 2026
9539d34
Contracts: cancel every tx log entry for a slate in one batch
jwinterm Jul 27, 2026
cf82e2c
Contracts: propagate slatepack output and stdin errors
jwinterm Jul 28, 2026
6d6e198
Contracts: wire up the contract view command
jwinterm Jul 28, 2026
f420e39
Contracts: remove the unused contract test module
jwinterm Jul 28, 2026
370cd4f
Contracts: make the invoice proof reader fully fallible
jwinterm Jul 28, 2026
51583ac
Contracts: document the stored tx window and record the tx location
jwinterm Jul 28, 2026
7f03f95
Contracts: bring the actions README in line with the code
jwinterm Jul 28, 2026
4883c91
Merge upstream staging into contracts
jwinterm Jul 28, 2026
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: 4 additions & 0 deletions .cargo/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[target.x86_64-pc-windows-msvc]
rustflags = ["-Ctarget-feature=+crt-static"]
[target.i686-pc-windows-msvc]
rustflags = ["-Ctarget-feature=+crt-static"]
73 changes: 66 additions & 7 deletions Cargo.lock

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

40 changes: 39 additions & 1 deletion api/src/foreign.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,17 @@
use crate::keychain::Keychain;
use crate::libwallet::api_impl::foreign;
use crate::libwallet::api_impl::types::update_tx_slate_state;
use crate::libwallet::contract::proofs::InvoiceProof;
use crate::libwallet::contract::types::{ContractNewArgsAPI, ContractSetupArgsAPI};
use crate::libwallet::{
BlockFees, CbData, Error, NodeClient, NodeVersionInfo, Slate, VersionInfo, WalletInst,
WalletLCProvider,
};
use crate::try_slatepack_sync_workflow;
use crate::util::secp::key::SecretKey;
use crate::util::Mutex;
use ed25519_dalek::VerifyingKey as DalekPublicKey;
use libwallet::SlatepackAddress;

use std::sync::Arc;

/// ForeignAPI Middleware Check callback
Expand Down Expand Up @@ -457,6 +459,42 @@ where
};
foreign::finalize_tx(w, (&self.keychain_mask).as_ref(), slate, post_automatically)
}

// Below is a foreign wrapper around owner calls to 'new' and 'sign' which are only executed
// if this is a receiving contract. This preserves the ability to receive on a foreign interface.
/// TODO
pub fn contract_new(
&self,
keychain_mask: Option<&SecretKey>,
args: &ContractNewArgsAPI,
) -> Result<Slate, Error> {
let mut w_lock = self.wallet_inst.lock();
let w = w_lock.lc_provider()?.wallet_inst()?;
foreign::contract_new(w, keychain_mask, args)
}

/// TODO
pub fn contract_sign(
&self,
keychain_mask: Option<&SecretKey>,
slate: &Slate,
args: &ContractSetupArgsAPI,
) -> Result<Slate, Error> {
let mut w_lock = self.wallet_inst.lock();
let w = w_lock.lc_provider()?.wallet_inst()?;
foreign::contract_sign(w, keychain_mask, args, slate)
}

/// TODO
pub fn verify_payment_proof_invoice(
&self,
recipient_address: &DalekPublicKey,
proof: &InvoiceProof,
) -> Result<(), Error> {
let mut w_lock = self.wallet_inst.lock();
let w = w_lock.lc_provider()?.wallet_inst()?;
foreign::verify_payment_proof_invoice(w, recipient_address, proof)
}
}

#[doc(hidden)]
Expand Down
5 changes: 3 additions & 2 deletions api/src/foreign_rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ pub trait ForeignRpc {
"Ok": {
"foreign_api_version": 2,
"supported_slate_versions": [
"V5",
"V4"
]
}
Expand Down Expand Up @@ -208,7 +209,7 @@ pub trait ForeignRpc {
"method": "finalize_tx",
"id": 1,
"params": [{
"ver": "4:2",
"ver": "5:2",
"id": "0436430c-2b02-624c-2032-570501212b00",
"sta": "I2",
"off": "383bc9df0dd332629520a0a72f8dd7f0e97d579dccb4dbdc8592aa3d424c846c",
Expand Down Expand Up @@ -278,7 +279,7 @@ pub trait ForeignRpc {
}
],
"sta": "I3",
"ver": "4:2"
"ver": "5:2"
}
}
}
Expand Down
87 changes: 87 additions & 0 deletions api/src/owner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ use crate::keychain::{Identifier, Keychain};
use crate::libwallet::api_impl::owner_updater::{start_updater_log_thread, StatusMessage};
use crate::libwallet::api_impl::types::update_tx_slate_state;
use crate::libwallet::api_impl::{owner, owner_updater};
use crate::libwallet::contract::proofs::InvoiceProof;
use crate::libwallet::contract::types::{
ContractNewArgsAPI, ContractRevokeArgsAPI, ContractSetupArgsAPI, ContractView,
};
use crate::libwallet::{
AcctPathMapping, BuiltOutput, Error, InitTxArgs, IssueInvoiceTxArgs, NodeClient,
NodeHeightResult, OutputCommitMapping, PaymentProof, Slate, Slatepack, SlatepackAddress,
Expand Down Expand Up @@ -807,6 +811,62 @@ where
owner::issue_invoice_tx(w, keychain_mask, args, self.doctest_mode)
}

/// Initiate a new contract. Also performs the initial setup on the slate.
pub fn contract_new(
&self,
keychain_mask: Option<&SecretKey>,
args: &ContractNewArgsAPI,
) -> Result<Slate, Error> {
let mut w_lock = self.wallet_inst.lock();
let w = w_lock.lc_provider()?.wallet_inst()?;
owner::contract_new(w, keychain_mask, args)
}

/// Summarise a contract slate, including its participants, signatures and net change.
pub fn contract_view(
&self,
keychain_mask: Option<&SecretKey>,
slate: &Slate,
) -> Result<ContractView, Error> {
let mut w_lock = self.wallet_inst.lock();
let w = w_lock.lc_provider()?.wallet_inst()?;
owner::contract_view(w, keychain_mask, slate)
}

/// Sign a contract, running setup first if it has not been done yet.
pub fn contract_sign(
&self,
keychain_mask: Option<&SecretKey>,
slate: &Slate,
args: &ContractSetupArgsAPI,
) -> Result<Slate, Error> {
let mut w_lock = self.wallet_inst.lock();
let w = w_lock.lc_provider()?.wallet_inst()?;
owner::contract_sign(w, keychain_mask, args, slate)
}

/// Return the participant index in the slate that matches this wallet's context.
pub fn get_slate_index_matching_my_context(
&self,
keychain_mask: Option<&SecretKey>,
slate: &Slate,
) -> Result<usize, Error> {
let mut w_lock = self.wallet_inst.lock();
let w = w_lock.lc_provider()?.wallet_inst()?;
owner::get_slate_index_matching_my_context(w, keychain_mask, slate)
}

/// Revoke a contract by double-spending one of its locked inputs.
pub fn contract_revoke(
&self,
keychain_mask: Option<&SecretKey>,
args: &ContractRevokeArgsAPI,
) -> Result<Option<Slate>, Error> {
let mut w_lock = self.wallet_inst.lock();
let w = w_lock.lc_provider()?.wallet_inst()?;
owner::contract_revoke(w, keychain_mask, args)
}

/// Processes an invoice transaction created by another party, essentially
/// a `request for payment`. The incoming slate should contain a requested
/// amount, an output created by the invoicer converting the amount, and
Expand Down Expand Up @@ -2439,6 +2499,33 @@ where
)
}

/// Retrieve the invoice payment proof for a stored transaction.
/// FUTURE: likely merge with retrieve_payment_proof above.
pub fn retrieve_payment_proof_invoice(
&self,
keychain_mask: Option<&SecretKey>,
refresh_from_node: bool,
tx_id: Option<u32>,
tx_slate_id: Option<Uuid>,
) -> Result<InvoiceProof, Error> {
let tx = {
let t = self.status_tx.lock();
t.clone()
};
let refresh_from_node = match self.updater_running.load(Ordering::Relaxed) {
true => false,
false => refresh_from_node,
};
owner::retrieve_payment_proof_invoice(
self.wallet_inst.clone(),
keychain_mask,
&tx,
refresh_from_node,
tx_id,
tx_slate_id,
)
}

/// Verifies a [PaymentProof](../grin_wallet_libwallet/api_impl/types/struct.PaymentProof.html)
/// This process entails:
///
Expand Down
Loading