merge staging

This commit is contained in:
wiesche
2026-09-15 22:30:41 +02:00
12 changed files with 146 additions and 40 deletions
+3
View File
@@ -72,6 +72,9 @@ where
K: Keychain,
{
let mut ret_slate = slate.clone();
if ret_slate.state != SlateState::Standard1 {
return Err(Error::SlateState);
}
check_ttl(w, &ret_slate)?;
let parent_key_id = match dest_acct_name {
Some(d) => {
+10 -8
View File
@@ -21,6 +21,7 @@ use crate::contract::types::ContractSetupArgsAPI;
use crate::error::Error;
use crate::grin_keychain::Keychain;
use crate::grin_util::secp::key::SecretKey;
use crate::internal::tx;
use crate::slate::Slate;
use crate::types::{Context, NodeClient};
use uuid::Uuid;
@@ -65,11 +66,15 @@ where
let net_change = setup_args.required_net_change()?;
debug!("contract::new => net_change passed: {}", net_change);
// Initialize a new contract (if net_change is positive, I'm the receiver meaning this is invoice flow)
let num_participants = setup_args.num_participants;
let mut slate = Slate::blank(num_participants, net_change > 0);
// Contracts start with V4 and move to V5 when their proof data requires it
slate.version_info.version = 4;
// invoice flow if net_change is positive
let mut slate = tx::new_tx_slate(
w,
net_change.unsigned_abs(),
net_change > 0,
setup_args.num_participants,
false,
None,
)?;
// Use a caller-supplied id when given, so a retried creation reuses the same context.
let mut existing_context = None;
if let Some(id) = slate_id {
@@ -96,9 +101,6 @@ where
})?;
}
}
// We set slate.amount to contain the _positive_ net_change for the other party so they can derive expectations.
// unsigned_abs avoids the i64::MIN overflow panic of abs().
slate.amount = net_change.unsigned_abs();
debug!("contract::new => slate amount: {}", slate.amount);
// Perform setup for the slate
+2 -13
View File
@@ -18,8 +18,7 @@ use byteorder::{BigEndian, ReadBytesExt, WriteBytesExt};
use std::io::Cursor;
use uuid::Uuid;
use crate::grin_core::consensus::valid_header_version;
use crate::grin_core::core::HeaderVersion;
use crate::grin_core::consensus::header_version;
use crate::grin_keychain::{Identifier, Keychain};
use crate::grin_util::secp::key::SecretKey;
use crate::grin_util::secp::pedersen;
@@ -72,17 +71,7 @@ where
}
slate.amount = amount;
if valid_header_version(current_height, HeaderVersion(1)) {
slate.version_info.block_header_version = 1;
}
if valid_header_version(current_height, HeaderVersion(2)) {
slate.version_info.block_header_version = 2;
}
if valid_header_version(current_height, HeaderVersion(3)) {
slate.version_info.block_header_version = 3;
}
slate.version_info.block_header_version = header_version(current_height).0;
// Set the features explicitly to 0 here.
// This will generate a Plain kernel (rather than a HeightLocked kernel).
+2 -2
View File
@@ -41,8 +41,8 @@ pub mod v5_bin;
/// The most recent version of the slate
pub const CURRENT_SLATE_VERSION: u16 = 5;
/// The grin block header this slate is intended to be compatible with
pub const GRIN_BLOCK_HEADER_VERSION: u16 = 3;
/// The latest grin block header version this wallet supports
pub const GRIN_BLOCK_HEADER_VERSION: u16 = 5;
const HEIGHT_LOCKED_FEATURE: u8 = 2;
const NRD_FEATURE: u8 = 3;