Merge pull request #129 from antiochp/kernel_features_compat

rework kernel features support
This commit is contained in:
Antioch Peverell 2019-08-20 01:22:45 +01:00 committed by GitHub
commit 3efe36eb7d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
12 changed files with 171 additions and 157 deletions

74
Cargo.lock generated
View file

@ -581,17 +581,16 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "grin_api"
version = "2.0.1-beta.1"
source = "git+https://github.com/mimblewimble/grin#705fcbb1a62a1cfddb1e8b4fc9c30bab4a388818"
dependencies = [
"failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
"failure_derive 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
"futures 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)",
"grin_chain 2.0.1-beta.1 (git+https://github.com/mimblewimble/grin)",
"grin_core 2.0.1-beta.1 (git+https://github.com/mimblewimble/grin)",
"grin_p2p 2.0.1-beta.1 (git+https://github.com/mimblewimble/grin)",
"grin_pool 2.0.1-beta.1 (git+https://github.com/mimblewimble/grin)",
"grin_store 2.0.1-beta.1 (git+https://github.com/mimblewimble/grin)",
"grin_util 2.0.1-beta.1 (git+https://github.com/mimblewimble/grin)",
"grin_chain 2.0.1-beta.1",
"grin_core 2.0.1-beta.1",
"grin_p2p 2.0.1-beta.1",
"grin_pool 2.0.1-beta.1",
"grin_store 2.0.1-beta.1",
"grin_util 2.0.1-beta.1",
"http 0.1.18 (registry+https://github.com/rust-lang/crates.io-index)",
"hyper 0.12.19 (registry+https://github.com/rust-lang/crates.io-index)",
"hyper-rustls 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)",
@ -613,7 +612,6 @@ dependencies = [
[[package]]
name = "grin_chain"
version = "2.0.1-beta.1"
source = "git+https://github.com/mimblewimble/grin#705fcbb1a62a1cfddb1e8b4fc9c30bab4a388818"
dependencies = [
"bitflags 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)",
@ -621,10 +619,10 @@ dependencies = [
"croaring 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)",
"failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
"failure_derive 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
"grin_core 2.0.1-beta.1 (git+https://github.com/mimblewimble/grin)",
"grin_keychain 2.0.1-beta.1 (git+https://github.com/mimblewimble/grin)",
"grin_store 2.0.1-beta.1 (git+https://github.com/mimblewimble/grin)",
"grin_util 2.0.1-beta.1 (git+https://github.com/mimblewimble/grin)",
"grin_core 2.0.1-beta.1",
"grin_keychain 2.0.1-beta.1",
"grin_store 2.0.1-beta.1",
"grin_util 2.0.1-beta.1",
"lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)",
"lru-cache 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
@ -636,7 +634,6 @@ dependencies = [
[[package]]
name = "grin_core"
version = "2.0.1-beta.1"
source = "git+https://github.com/mimblewimble/grin#705fcbb1a62a1cfddb1e8b4fc9c30bab4a388818"
dependencies = [
"blake2-rfc 0.2.18 (registry+https://github.com/rust-lang/crates.io-index)",
"byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)",
@ -645,8 +642,8 @@ dependencies = [
"enum_primitive 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
"failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
"failure_derive 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
"grin_keychain 2.0.1-beta.1 (git+https://github.com/mimblewimble/grin)",
"grin_util 2.0.1-beta.1 (git+https://github.com/mimblewimble/grin)",
"grin_keychain 2.0.1-beta.1",
"grin_util 2.0.1-beta.1",
"lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)",
"lru-cache 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
@ -663,12 +660,11 @@ dependencies = [
[[package]]
name = "grin_keychain"
version = "2.0.1-beta.1"
source = "git+https://github.com/mimblewimble/grin#705fcbb1a62a1cfddb1e8b4fc9c30bab4a388818"
dependencies = [
"blake2-rfc 0.2.18 (registry+https://github.com/rust-lang/crates.io-index)",
"byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)",
"digest 0.7.6 (registry+https://github.com/rust-lang/crates.io-index)",
"grin_util 2.0.1-beta.1 (git+https://github.com/mimblewimble/grin)",
"grin_util 2.0.1-beta.1",
"hmac 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)",
"lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)",
@ -686,16 +682,15 @@ dependencies = [
[[package]]
name = "grin_p2p"
version = "2.0.1-beta.1"
source = "git+https://github.com/mimblewimble/grin#705fcbb1a62a1cfddb1e8b4fc9c30bab4a388818"
dependencies = [
"bitflags 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)",
"chrono 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)",
"enum_primitive 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
"grin_chain 2.0.1-beta.1 (git+https://github.com/mimblewimble/grin)",
"grin_core 2.0.1-beta.1 (git+https://github.com/mimblewimble/grin)",
"grin_store 2.0.1-beta.1 (git+https://github.com/mimblewimble/grin)",
"grin_util 2.0.1-beta.1 (git+https://github.com/mimblewimble/grin)",
"grin_chain 2.0.1-beta.1",
"grin_core 2.0.1-beta.1",
"grin_store 2.0.1-beta.1",
"grin_util 2.0.1-beta.1",
"log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)",
"net2 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)",
"num 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)",
@ -708,16 +703,15 @@ dependencies = [
[[package]]
name = "grin_pool"
version = "2.0.1-beta.1"
source = "git+https://github.com/mimblewimble/grin#705fcbb1a62a1cfddb1e8b4fc9c30bab4a388818"
dependencies = [
"blake2-rfc 0.2.18 (registry+https://github.com/rust-lang/crates.io-index)",
"chrono 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)",
"failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
"failure_derive 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
"grin_core 2.0.1-beta.1 (git+https://github.com/mimblewimble/grin)",
"grin_keychain 2.0.1-beta.1 (git+https://github.com/mimblewimble/grin)",
"grin_store 2.0.1-beta.1 (git+https://github.com/mimblewimble/grin)",
"grin_util 2.0.1-beta.1 (git+https://github.com/mimblewimble/grin)",
"grin_core 2.0.1-beta.1",
"grin_keychain 2.0.1-beta.1",
"grin_store 2.0.1-beta.1",
"grin_util 2.0.1-beta.1",
"log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)",
"rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)",
"serde 1.0.98 (registry+https://github.com/rust-lang/crates.io-index)",
@ -742,15 +736,14 @@ dependencies = [
[[package]]
name = "grin_store"
version = "2.0.1-beta.1"
source = "git+https://github.com/mimblewimble/grin#705fcbb1a62a1cfddb1e8b4fc9c30bab4a388818"
dependencies = [
"byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)",
"croaring 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)",
"env_logger 0.5.13 (registry+https://github.com/rust-lang/crates.io-index)",
"failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
"failure_derive 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
"grin_core 2.0.1-beta.1 (git+https://github.com/mimblewimble/grin)",
"grin_util 2.0.1-beta.1 (git+https://github.com/mimblewimble/grin)",
"grin_core 2.0.1-beta.1",
"grin_util 2.0.1-beta.1",
"libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)",
"lmdb-zero 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)",
@ -763,7 +756,6 @@ dependencies = [
[[package]]
name = "grin_util"
version = "2.0.1-beta.1"
source = "git+https://github.com/mimblewimble/grin#705fcbb1a62a1cfddb1e8b4fc9c30bab4a388818"
dependencies = [
"backtrace 0.3.34 (registry+https://github.com/rust-lang/crates.io-index)",
"base64 0.9.3 (registry+https://github.com/rust-lang/crates.io-index)",
@ -926,12 +918,12 @@ name = "grin_wallet_util"
version = "2.1.0-beta.1"
dependencies = [
"dirs 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)",
"grin_api 2.0.1-beta.1 (git+https://github.com/mimblewimble/grin)",
"grin_chain 2.0.1-beta.1 (git+https://github.com/mimblewimble/grin)",
"grin_core 2.0.1-beta.1 (git+https://github.com/mimblewimble/grin)",
"grin_keychain 2.0.1-beta.1 (git+https://github.com/mimblewimble/grin)",
"grin_store 2.0.1-beta.1 (git+https://github.com/mimblewimble/grin)",
"grin_util 2.0.1-beta.1 (git+https://github.com/mimblewimble/grin)",
"grin_api 2.0.1-beta.1",
"grin_chain 2.0.1-beta.1",
"grin_core 2.0.1-beta.1",
"grin_keychain 2.0.1-beta.1",
"grin_store 2.0.1-beta.1",
"grin_util 2.0.1-beta.1",
"pretty_assertions 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
"rand 0.5.6 (registry+https://github.com/rust-lang/crates.io-index)",
"serde 1.0.98 (registry+https://github.com/rust-lang/crates.io-index)",
@ -2886,15 +2878,7 @@ dependencies = [
"checksum getrandom 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)" = "cd8e190892c840661957ba9f32dacfb3eb405e657f9f9f60485605f0bb37d6f8"
"checksum git2 0.9.2 (registry+https://github.com/rust-lang/crates.io-index)" = "8cb400360e8a4d61b10e648285bbfa919bbf9519d0d5d5720354456f44349226"
"checksum glob 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "8be18de09a56b60ed0edf84bc9df007e30040691af7acd1c41874faac5895bfb"
"checksum grin_api 2.0.1-beta.1 (git+https://github.com/mimblewimble/grin)" = "<none>"
"checksum grin_chain 2.0.1-beta.1 (git+https://github.com/mimblewimble/grin)" = "<none>"
"checksum grin_core 2.0.1-beta.1 (git+https://github.com/mimblewimble/grin)" = "<none>"
"checksum grin_keychain 2.0.1-beta.1 (git+https://github.com/mimblewimble/grin)" = "<none>"
"checksum grin_p2p 2.0.1-beta.1 (git+https://github.com/mimblewimble/grin)" = "<none>"
"checksum grin_pool 2.0.1-beta.1 (git+https://github.com/mimblewimble/grin)" = "<none>"
"checksum grin_secp256k1zkp 0.7.7 (registry+https://github.com/rust-lang/crates.io-index)" = "23027a7673df2c2b20fb9589d742ff400a10a9c3e4c769a77e9fa3bd19586822"
"checksum grin_store 2.0.1-beta.1 (git+https://github.com/mimblewimble/grin)" = "<none>"
"checksum grin_util 2.0.1-beta.1 (git+https://github.com/mimblewimble/grin)" = "<none>"
"checksum h2 0.1.26 (registry+https://github.com/rust-lang/crates.io-index)" = "a5b34c246847f938a410a03c5458c7fee2274436675e76d8b903c08efc29c462"
"checksum heck 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "20564e78d53d2bb135c343b3f47714a56af2061f1c928fdb541dc7b9fdd94205"
"checksum hmac 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)" = "733e1b3ac906631ca01ebb577e9bb0f5e37a454032b9036b5eaea4013ed6f99a"

View file

@ -94,9 +94,7 @@ pub trait ForeignRpc {
"kernel": {
"excess": "08dfe86d732f2dd24bac36aa7502685221369514197c26d33fac03041d47e4b490",
"excess_sig": "8f07ddd5e9f5179cff19486034181ed76505baaad53e5d994064127b56c5841be02fa098c54c9bf638e0ee1ad5eb896caa11565f632be7b9cd65643ba371044f",
"features": "Coinbase",
"fee": "0",
"lock_height": "0"
"features": "Coinbase"
},
"key_id": "0300000000000000000000000400000000",
"output": {
@ -192,7 +190,7 @@ pub trait ForeignRpc {
# ,false, 1 ,false, false);
```
*/
fn verify_slate_messages(&self, slate: &Slate) -> Result<(), ErrorKind>;
fn verify_slate_messages(&self, slate: VersionedSlate) -> Result<(), ErrorKind>;
/**
Networked version of [Foreign::receive_tx](struct.Foreign.html#method.receive_tx).
@ -513,7 +511,7 @@ pub trait ForeignRpc {
# ,false, 5, false, true);
```
*/
fn finalize_invoice_tx(&self, slate: &Slate) -> Result<Slate, ErrorKind>;
fn finalize_invoice_tx(&self, slate: VersionedSlate) -> Result<VersionedSlate, ErrorKind>;
}
impl<'a, L, C, K> ForeignRpc for Foreign<'a, L, C, K>
@ -530,31 +528,32 @@ where
Foreign::build_coinbase(self, block_fees).map_err(|e| e.kind())
}
fn verify_slate_messages(&self, slate: &Slate) -> Result<(), ErrorKind> {
Foreign::verify_slate_messages(self, slate).map_err(|e| e.kind())
fn verify_slate_messages(&self, slate: VersionedSlate) -> Result<(), ErrorKind> {
Foreign::verify_slate_messages(self, &Slate::from(slate)).map_err(|e| e.kind())
}
fn receive_tx(
&self,
slate: VersionedSlate,
in_slate: VersionedSlate,
dest_acct_name: Option<String>,
message: Option<String>,
) -> Result<VersionedSlate, ErrorKind> {
let version = slate.version();
let slate: Slate = slate.into();
let slate = Foreign::receive_tx(
let version = in_slate.version();
let out_slate = Foreign::receive_tx(
self,
&slate,
&Slate::from(in_slate),
dest_acct_name.as_ref().map(String::as_str),
message,
)
.map_err(|e| e.kind())?;
Ok(VersionedSlate::into_version(slate, version))
Ok(VersionedSlate::into_version(out_slate, version))
}
fn finalize_invoice_tx(&self, slate: &Slate) -> Result<Slate, ErrorKind> {
Foreign::finalize_invoice_tx(self, slate).map_err(|e| e.kind())
fn finalize_invoice_tx(&self, in_slate: VersionedSlate) -> Result<VersionedSlate, ErrorKind> {
let version = in_slate.version();
let out_slate =
Foreign::finalize_invoice_tx(self, &Slate::from(in_slate)).map_err(|e| e.kind())?;
Ok(VersionedSlate::into_version(out_slate, version))
}
}

View file

@ -17,6 +17,7 @@ use uuid::Uuid;
use crate::core::core::Transaction;
use crate::keychain::{Identifier, Keychain};
use crate::libwallet::slate_versions::v2::TransactionV2;
use crate::libwallet::{
AcctPathMapping, ErrorKind, InitTxArgs, IssueInvoiceTxArgs, NodeClient, NodeHeightResult,
OutputCommitMapping, Slate, SlateVersion, TxLogEntry, VersionedSlate, WalletInfo,
@ -949,7 +950,7 @@ pub trait OwnerRpc: Sync + Send {
```
*/
fn post_tx(&self, tx: &Transaction, fluff: bool) -> Result<(), ErrorKind>;
fn post_tx(&self, tx: TransactionV2, fluff: bool) -> Result<(), ErrorKind>;
/**
Networked version of [Owner::cancel_tx](struct.Owner.html#method.cancel_tx).
@ -1073,7 +1074,7 @@ pub trait OwnerRpc: Sync + Send {
# , false, 5, true, true, false);
```
*/
fn get_stored_tx(&self, tx: &TxLogEntry) -> Result<Option<Transaction>, ErrorKind>;
fn get_stored_tx(&self, tx: &TxLogEntry) -> Result<Option<TransactionV2>, ErrorKind>;
/**
Networked version of [Owner::verify_slate_messages](struct.Owner.html#method.verify_slate_messages).
@ -1304,19 +1305,18 @@ where
fn process_invoice_tx(
&self,
slate: VersionedSlate,
in_slate: VersionedSlate,
args: InitTxArgs,
) -> Result<VersionedSlate, ErrorKind> {
let in_slate = Slate::from(slate);
let out_slate =
Owner::process_invoice_tx(self, None, &in_slate, args).map_err(|e| e.kind())?;
let out_slate = Owner::process_invoice_tx(self, None, &Slate::from(in_slate), args)
.map_err(|e| e.kind())?;
let version = SlateVersion::V2;
Ok(VersionedSlate::into_version(out_slate, version))
}
fn finalize_tx(&self, slate: VersionedSlate) -> Result<VersionedSlate, ErrorKind> {
let in_slate = Slate::from(slate);
let out_slate = Owner::finalize_tx(self, None, &in_slate).map_err(|e| e.kind())?;
fn finalize_tx(&self, in_slate: VersionedSlate) -> Result<VersionedSlate, ErrorKind> {
let out_slate =
Owner::finalize_tx(self, None, &Slate::from(in_slate)).map_err(|e| e.kind())?;
let version = SlateVersion::V2;
Ok(VersionedSlate::into_version(out_slate, version))
}
@ -1326,25 +1326,26 @@ where
slate: VersionedSlate,
participant_id: usize,
) -> Result<(), ErrorKind> {
let in_slate = Slate::from(slate);
Owner::tx_lock_outputs(self, None, &in_slate, participant_id).map_err(|e| e.kind())
Owner::tx_lock_outputs(self, None, &Slate::from(slate), participant_id)
.map_err(|e| e.kind())
}
fn cancel_tx(&self, tx_id: Option<u32>, tx_slate_id: Option<Uuid>) -> Result<(), ErrorKind> {
Owner::cancel_tx(self, None, tx_id, tx_slate_id).map_err(|e| e.kind())
}
fn get_stored_tx(&self, tx: &TxLogEntry) -> Result<Option<Transaction>, ErrorKind> {
Owner::get_stored_tx(self, None, tx).map_err(|e| e.kind())
fn get_stored_tx(&self, tx: &TxLogEntry) -> Result<Option<TransactionV2>, ErrorKind> {
Owner::get_stored_tx(self, None, tx)
.map(|x| x.map(|y| TransactionV2::from(y)))
.map_err(|e| e.kind())
}
fn post_tx(&self, tx: &Transaction, fluff: bool) -> Result<(), ErrorKind> {
Owner::post_tx(self, None, tx, fluff).map_err(|e| e.kind())
fn post_tx(&self, tx: TransactionV2, fluff: bool) -> Result<(), ErrorKind> {
Owner::post_tx(self, None, &Transaction::from(tx), fluff).map_err(|e| e.kind())
}
fn verify_slate_messages(&self, slate: VersionedSlate) -> Result<(), ErrorKind> {
let in_slate = Slate::from(slate);
Owner::verify_slate_messages(self, None, &in_slate).map_err(|e| e.kind())
Owner::verify_slate_messages(self, None, &Slate::from(slate)).map_err(|e| e.kind())
}
fn restore(&self) -> Result<(), ErrorKind> {

View file

@ -17,6 +17,7 @@ use uuid::Uuid;
use crate::core::core::Transaction;
use crate::keychain::{Identifier, Keychain};
use crate::libwallet::slate_versions::v2::TransactionV2;
use crate::libwallet::{
AcctPathMapping, ErrorKind, InitTxArgs, IssueInvoiceTxArgs, NodeClient, NodeHeightResult,
OutputCommitMapping, Slate, SlateVersion, TxLogEntry, VersionedSlate, WalletInfo,
@ -987,7 +988,7 @@ pub trait OwnerRpcS {
```
*/
fn post_tx(&self, token: Token, tx: &Transaction, fluff: bool) -> Result<(), ErrorKind>;
fn post_tx(&self, token: Token, tx: TransactionV2, fluff: bool) -> Result<(), ErrorKind>;
/**
Networked version of [Owner::cancel_tx](struct.Owner.html#method.cancel_tx).
@ -1125,7 +1126,7 @@ pub trait OwnerRpcS {
&self,
token: Token,
tx: &TxLogEntry,
) -> Result<Option<Transaction>, ErrorKind>;
) -> Result<Option<TransactionV2>, ErrorKind>;
/**
Networked version of [Owner::verify_slate_messages](struct.Owner.html#method.verify_slate_messages).
@ -1402,13 +1403,16 @@ where
fn process_invoice_tx(
&self,
token: Token,
slate: VersionedSlate,
in_slate: VersionedSlate,
args: InitTxArgs,
) -> Result<VersionedSlate, ErrorKind> {
let in_slate = Slate::from(slate);
let out_slate =
Owner::process_invoice_tx(self, (&token.keychain_mask).as_ref(), &in_slate, args)
.map_err(|e| e.kind())?;
let out_slate = Owner::process_invoice_tx(
self,
(&token.keychain_mask).as_ref(),
&Slate::from(in_slate),
args,
)
.map_err(|e| e.kind())?;
let version = SlateVersion::V2;
Ok(VersionedSlate::into_version(out_slate, version))
}
@ -1416,11 +1420,14 @@ where
fn finalize_tx(
&self,
token: Token,
slate: VersionedSlate,
in_slate: VersionedSlate,
) -> Result<VersionedSlate, ErrorKind> {
let in_slate = Slate::from(slate);
let out_slate = Owner::finalize_tx(self, (&token.keychain_mask).as_ref(), &in_slate)
.map_err(|e| e.kind())?;
let out_slate = Owner::finalize_tx(
self,
(&token.keychain_mask).as_ref(),
&Slate::from(in_slate),
)
.map_err(|e| e.kind())?;
let version = SlateVersion::V2;
Ok(VersionedSlate::into_version(out_slate, version))
}
@ -1428,14 +1435,13 @@ where
fn tx_lock_outputs(
&self,
token: Token,
slate: VersionedSlate,
in_slate: VersionedSlate,
participant_id: usize,
) -> Result<(), ErrorKind> {
let in_slate = Slate::from(slate);
Owner::tx_lock_outputs(
self,
(&token.keychain_mask).as_ref(),
&in_slate,
&Slate::from(in_slate),
participant_id,
)
.map_err(|e| e.kind())
@ -1455,17 +1461,24 @@ where
&self,
token: Token,
tx: &TxLogEntry,
) -> Result<Option<Transaction>, ErrorKind> {
Owner::get_stored_tx(self, (&token.keychain_mask).as_ref(), tx).map_err(|e| e.kind())
) -> Result<Option<TransactionV2>, ErrorKind> {
Owner::get_stored_tx(self, (&token.keychain_mask).as_ref(), tx)
.map(|x| x.map(|y| TransactionV2::from(y)))
.map_err(|e| e.kind())
}
fn post_tx(&self, token: Token, tx: &Transaction, fluff: bool) -> Result<(), ErrorKind> {
Owner::post_tx(self, (&token.keychain_mask).as_ref(), tx, fluff).map_err(|e| e.kind())
fn post_tx(&self, token: Token, tx: TransactionV2, fluff: bool) -> Result<(), ErrorKind> {
Owner::post_tx(
self,
(&token.keychain_mask).as_ref(),
&Transaction::from(tx),
fluff,
)
.map_err(|e| e.kind())
}
fn verify_slate_messages(&self, token: Token, slate: VersionedSlate) -> Result<(), ErrorKind> {
let in_slate = Slate::from(slate);
Owner::verify_slate_messages(self, (&token.keychain_mask).as_ref(), &in_slate)
Owner::verify_slate_messages(self, (&token.keychain_mask).as_ref(), &Slate::from(slate))
.map_err(|e| e.kind())
}

View file

@ -137,13 +137,16 @@ fn accounts_test_impl(test_dir: &'static str) -> Result<(), libwallet::Error> {
assert_eq!(txs.len(), 5);
Ok(())
})?;
// now check second account
{
let mut w_lock = wallet1.lock();
let lc = w_lock.lc_provider()?;
let w = lc.wallet_inst()?;
// let mut w_lock = wallet1.lock();
// let lc = w_lock.lc_provider()?;
// let w = lc.wallet_inst()?;
wallet_inst!(wallet1, w);
w.set_parent_key_id_by_name("account1")?;
}
wallet::controller::owner_single_use(wallet1.clone(), mask1, |api, m| {
// check last confirmed height on this account is different from above (should be 0)
let (_, wallet1_info) = api.retrieve_summary_info(m, false, 1)?;
@ -183,7 +186,6 @@ fn accounts_test_impl(test_dir: &'static str) -> Result<(), libwallet::Error> {
wallet_inst!(wallet1, w);
w.set_parent_key_id_by_name("account1")?;
}
wallet::controller::owner_single_use(wallet1.clone(), mask1, |api, m| {
let args = InitTxArgs {
src_acct_name: None,

View file

@ -119,13 +119,9 @@ fn basic_transaction_api(test_dir: &'static str) -> Result<(), libwallet::Error>
// Check we have a single kernel and that it is a Plain kernel (no lock_height).
assert_eq!(slate.tx.kernels().len(), 1);
assert_eq!(
slate.tx.kernels().first().map(|k| k.lock_height).unwrap(),
0
);
assert_eq!(
slate.tx.kernels().first().map(|k| k.features).unwrap(),
transaction::KernelFeatures::Plain
transaction::KernelFeatures::Plain { fee: 2000000 }
);
Ok(())

View file

@ -26,6 +26,7 @@ use crate::core::{pow, ser};
use crate::keychain::Keychain;
use crate::libwallet;
use crate::libwallet::api_impl::foreign;
use crate::libwallet::slate_versions::v2::SlateV2;
use crate::libwallet::{
NodeClient, NodeVersionInfo, Slate, TxWrapper, WalletInst, WalletLCProvider,
};
@ -214,23 +215,30 @@ where
Some(w) => w,
};
let mut slate = serde_json::from_str(&m.body).context(
let slate: SlateV2 = serde_json::from_str(&m.body).context(
libwallet::ErrorKind::ClientCallback("Error parsing TxWrapper".to_owned()),
)?;
;
{
let slate: Slate = {
let mut w_lock = wallet.1.lock();
let w = w_lock.lc_provider()?.wallet_inst()?;
let mask = wallet.2.clone();
// receive tx
slate = foreign::receive_tx(&mut **w, (&mask).as_ref(), &slate, None, None, false)?;
}
foreign::receive_tx(
&mut **w,
(&mask).as_ref(),
&Slate::from(slate),
None,
None,
false,
)?
};
Ok(WalletProxyMessage {
sender_id: m.dest,
dest: m.sender_id,
method: m.method,
body: serde_json::to_string(&slate).unwrap(),
body: serde_json::to_string(&SlateV2::from(slate)).unwrap(),
})
}
@ -332,7 +340,7 @@ impl LocalWalletClient {
sender_id: self.id.clone(),
dest: dest.to_owned(),
method: "send_tx_slate".to_owned(),
body: serde_json::to_string(slate).unwrap(),
body: serde_json::to_string(&SlateV2::from(slate)).unwrap(),
};
{
let p = self.proxy_tx.lock();
@ -343,11 +351,10 @@ impl LocalWalletClient {
let r = self.rx.lock();
let m = r.recv().unwrap();
trace!("Received send_tx_slate response: {:?}", m.clone());
Ok(
serde_json::from_str(&m.body).context(libwallet::ErrorKind::ClientCallback(
"Parsing send_tx_slate response".to_owned(),
))?,
)
let slate: SlateV2 = serde_json::from_str(&m.body).context(
libwallet::ErrorKind::ClientCallback("Parsing send_tx_slate response".to_owned()),
)?;
Ok(Slate::from(slate))
}
}

View file

@ -286,9 +286,10 @@ where
let (mut parts, change_amounts_derivations) =
inputs_and_change(&coins, wallet, keychain_mask, amount, fee, change_outputs)?;
// This is more proof of concept than anything but here we set lock_height
// on tx being sent (based on current chain height via api).
parts.push(build::with_lock_height(lock_height));
// Build a "Plain" kernel unless lock_height>0 explicitly specified.
if lock_height > 0 {
parts.push(build::with_lock_height(lock_height));
}
Ok((parts, coins, change_amounts_derivations, fee))
}

View file

@ -20,8 +20,7 @@ use crate::error::{Error, ErrorKind};
use crate::grin_core::core::amount_to_hr_string;
use crate::grin_core::core::committed::Committed;
use crate::grin_core::core::transaction::{
kernel_features, kernel_sig_msg, Input, Output, Transaction, TransactionBody, TxKernel,
Weighting,
Input, KernelFeatures, Output, Transaction, TransactionBody, TxKernel, Weighting,
};
use crate::grin_core::core::verifier_cache::LruVerifierCache;
use crate::grin_core::libtx::{aggsig, build, proof::ProofBuild, secp_ser, tx_fee};
@ -290,11 +289,16 @@ impl Slate {
}
// This is the msg that we will sign as part of the tx kernel.
// Currently includes the fee and the lock_height.
// If lock_height is 0 then build a plain kernel, otherwise build a height locked kernel.
fn msg_to_sign(&self) -> Result<secp::Message, Error> {
// Currently we only support interactively creating a tx with a "default" kernel.
let features = kernel_features(self.lock_height);
let msg = kernel_sig_msg(self.fee, self.lock_height, features)?;
let features = match self.lock_height {
0 => KernelFeatures::Plain { fee: self.fee },
_ => KernelFeatures::HeightLocked {
fee: self.fee,
lock_height: self.lock_height,
},
};
let msg = features.kernel_sig_msg()?;
Ok(msg)
}
@ -881,19 +885,19 @@ impl From<&Output> for OutputV2 {
impl From<&TxKernel> for TxKernelV2 {
fn from(kernel: &TxKernel) -> TxKernelV2 {
let TxKernel {
features,
fee,
lock_height,
excess,
excess_sig,
} = *kernel;
let (features, fee, lock_height) = match kernel.features {
KernelFeatures::Plain { fee } => (CompatKernelFeatures::Plain, fee, 0),
KernelFeatures::Coinbase => (CompatKernelFeatures::Coinbase, 0, 0),
KernelFeatures::HeightLocked { fee, lock_height } => {
(CompatKernelFeatures::HeightLocked, fee, lock_height)
}
};
TxKernelV2 {
features,
fee,
lock_height,
excess,
excess_sig,
excess: kernel.excess,
excess_sig: kernel.excess_sig,
}
}
}
@ -1025,19 +1029,23 @@ impl From<&OutputV2> for Output {
impl From<&TxKernelV2> for TxKernel {
fn from(kernel: &TxKernelV2) -> TxKernel {
let TxKernelV2 {
features,
fee,
lock_height,
excess,
excess_sig,
} = *kernel;
let (fee, lock_height) = (kernel.fee, kernel.lock_height);
let features = match kernel.features {
CompatKernelFeatures::Plain => KernelFeatures::Plain { fee },
CompatKernelFeatures::Coinbase => KernelFeatures::Coinbase,
CompatKernelFeatures::HeightLocked => KernelFeatures::HeightLocked { fee, lock_height },
};
TxKernel {
features,
fee,
lock_height,
excess,
excess_sig,
excess: kernel.excess,
excess_sig: kernel.excess_sig,
}
}
}
#[derive(Clone, Copy, Debug, Serialize, Deserialize)]
pub enum CompatKernelFeatures {
Plain,
Coinbase,
HeightLocked,
}

View file

@ -35,13 +35,14 @@
//! orig_version: u16,
//! block_header_version: u16,
use crate::grin_core::core::transaction::{KernelFeatures, OutputFeatures};
use crate::grin_core::core::transaction::OutputFeatures;
use crate::grin_core::libtx::secp_ser;
use crate::grin_keychain::BlindingFactor;
use crate::grin_util::secp;
use crate::grin_util::secp::key::PublicKey;
use crate::grin_util::secp::pedersen::{Commitment, RangeProof};
use crate::grin_util::secp::Signature;
use crate::slate::CompatKernelFeatures;
use uuid::Uuid;
#[derive(Serialize, Deserialize, Debug, Clone)]
@ -162,7 +163,7 @@ pub struct OutputV2 {
#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct TxKernelV2 {
/// Options for a kernel's structure or use
pub features: KernelFeatures,
pub features: CompatKernelFeatures,
/// Fee originally included in the transaction this proof is for.
#[serde(with = "secp_ser::string_or_u64")]
pub fee: u64,

View file

@ -23,7 +23,9 @@ use grin_wallet_util::grin_util::secp::key::{PublicKey, SecretKey};
use rand::thread_rng;
fn kernel_sig_msg() -> secp::Message {
transaction::kernel_sig_msg(0, 0, transaction::KernelFeatures::Plain).unwrap()
transaction::KernelFeatures::Plain { fee: 0 }
.kernel_sig_msg()
.unwrap()
}
#[test]

View file

@ -25,12 +25,12 @@ dirs = "1.0.3"
# grin_store = "2.0.0"
# For beta release
# grin_core = { git = "https://github.com/mimblewimble/grin", tag = "2.0.0-beta.2" }
# grin_keychain = { git = "https://github.com/mimblewimble/grin", tag = "2.0.0-beta.2" }
# grin_chain = { git = "https://github.com/mimblewimble/grin", tag = "2.0.0-beta.2" }
# grin_util = { git = "https://github.com/mimblewimble/grin", tag = "2.0.0-beta.2" }
# grin_api = { git = "https://github.com/mimblewimble/grin", tag = "2.0.0-beta.2" }
# grin_store = { git = "https://github.com/mimblewimble/grin", tag = "2.0.0-beta.2" }
# grin_core = { git = "https://github.com/mimblewimble/grin", tag = "2.0.1-beta.1" }
# grin_keychain = { git = "https://github.com/mimblewimble/grin", tag = "2.0.1-beta.1" }
# grin_chain = { git = "https://github.com/mimblewimble/grin", tag = "2.0.1-beta.1" }
# grin_util = { git = "https://github.com/mimblewimble/grin", tag = "2.0.1-beta.1" }
# grin_api = { git = "https://github.com/mimblewimble/grin", tag = "2.0.1-beta.1" }
# grin_store = { git = "https://github.com/mimblewimble/grin", tag = "2.0.1-beta.1" }
# For bleeding edge
grin_core = { git = "https://github.com/mimblewimble/grin", branch = "master" }