2019-03-14 15:06:03 +03:00
// Copyright 2019 The Grin Developers
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
2019-03-14 18:05:13 +03:00
//! JSON-RPC Stub generation for the Owner API
2019-03-14 15:06:03 +03:00
use uuid ::Uuid ;
2020-03-04 16:38:40 +03:00
use crate ::config ::{ TorConfig , WalletConfig } ;
use crate ::core ::global ;
2019-03-14 15:06:03 +03:00
use crate ::keychain ::{ Identifier , Keychain } ;
2019-04-24 11:27:14 +03:00
use crate ::libwallet ::{
2019-05-01 22:12:23 +03:00
AcctPathMapping , ErrorKind , InitTxArgs , IssueInvoiceTxArgs , NodeClient , NodeHeightResult ,
2020-05-28 10:17:51 +03:00
OutputCommitMapping , PaymentProof , Slate , SlateVersion , Slatepack , SlatepackAddress ,
StatusMessage , TxLogEntry , VersionedSlate , WalletInfo , WalletLCProvider ,
2019-03-14 15:06:03 +03:00
} ;
2020-03-04 16:38:40 +03:00
use crate ::util ::logger ::LoggingConfig ;
use crate ::util ::secp ::key ::{ PublicKey , SecretKey } ;
use crate ::util ::{ static_secp_instance , Mutex , ZeroingString } ;
2020-05-28 10:17:51 +03:00
use crate ::{ ECDHPubkey , Ed25519SecretKey , Owner , Token } ;
2019-08-19 15:05:21 +03:00
use easy_jsonrpc_mw ;
2020-01-24 16:02:09 +03:00
use grin_wallet_util ::OnionV3Address ;
2020-03-04 16:38:40 +03:00
use rand ::thread_rng ;
2020-01-24 16:02:09 +03:00
use std ::convert ::TryFrom ;
Merge milestone/2.1.0 into master (#199)
* version bump for next potential release
* Merge master into milestone/2.1.0 (#182)
* Derive --version output dynamically from cargo package version (#174)
* add --txid to the `wallet txs` command (#176)
* add --txid to the `wallet txs` command
* add test for `wallet txs` command with `--txid` parameter
* Refactor - Split WalletCommAdapter into multiple traits (#180)
* Derive --version output dynamically from cargo package version (#174)
* add server auth argument to http client
* Revert "add server auth argument to http client"
This reverts commit f52a8d2c7cdfb8583af5716ad621eb560811d6ee.
* modify WalletCommAdapter, moving dest argument into fields on implementors,
visiting havok on automated tests, at least one of which is now out of date and failing
* Split WalletCommAdapter into four traits, one for each of its intended behaviors.
* Remove two vestigals
1. args, a stringly typed argument to put_tx
2. NullAdapter, which is no longer used
* Remove unused "params" argument from listen method.
* Re-add previously existing TODO comment
* Fix non-test build
* completely Fix non-test build
* Full Lifecycle API Support (#184)
* refactoring wallet lib traits
* rustfmt
* rustfmt
* add new files
* explicit lifetime specifiers on all wallet traits
* rustfmt
* modify apis to use new walletinst
* rustfmt
* converting controller crate
* rustfmt
* controller crate compiling
* rustfmt
* compilation
* rustfmt
* Remove config from wallet, implement open_wallet, close_wallet in lifecycle provider, remove password + open_with_credentials from WalletBackend + impl
* rustfmt
* full compilation, changing recovery + init to new model
* rustfmt
* wallet initialisation working, init command output and flow identical to v2.0.0 wallet
* rustfmt
* fix listener and owner api startup
* rustfmt
* rustfmt
* move encryption test
* rustfmt
* fix api doctests
* rustfmt
* fix for most tests in controller crate
* rustfmt
* fix for check tests in controller crate
* fix main wallet tests
* rustfmt
* add explicit functions to handle mnemonic recovery, fix CLI recovery workflow
* rustfmt
* update keybase adapter to use new wallet format
* rustfmt
* test fix
* remove debug output
2019-07-29 15:25:03 +03:00
use std ::sync ::Arc ;
2020-03-04 16:38:40 +03:00
use std ::time ::Duration ;
2019-03-14 15:06:03 +03:00
2019-04-01 13:16:49 +03:00
/// Public definition used to generate Owner jsonrpc api.
2020-03-04 16:38:40 +03:00
/// Secure version containing wallet lifecycle functions. All calls to this API must be encrypted.
/// See [`init_secure_api`](#tymethod.init_secure_api) for details of secret derivation
/// and encryption.
2019-08-19 15:05:21 +03:00
#[ easy_jsonrpc_mw::rpc ]
2020-03-04 16:38:40 +03:00
pub trait OwnerRpc {
2019-03-14 15:06:03 +03:00
/**
Networked version of [ Owner ::accounts ] ( struct . Owner . html #method . accounts ) .
# Json rpc example
` ` `
# grin_wallet_api ::doctest_helper_json_rpc_owner_assert_response! (
2019-03-22 15:03:25 +03:00
# r #"
2019-03-14 15:06:03 +03:00
{
" jsonrpc " : " 2.0 " ,
" method " : " accounts " ,
2020-03-04 16:38:40 +03:00
" params " : {
" token " : " d202964900000000d302964900000000d402964900000000d502964900000000 "
} ,
2019-03-14 15:06:03 +03:00
" id " : 1
2019-03-22 15:03:25 +03:00
}
# " #
# ,
# r #"
2019-03-14 15:06:03 +03:00
{
" jsonrpc " : " 2.0 " ,
" result " : {
" Ok " : [
{
" label " : " default " ,
" path " : " 0200000000000000000000000000000000 "
}
]
} ,
" id " : 1
}
2019-03-22 15:03:25 +03:00
# " #
2020-03-04 16:38:40 +03:00
# , 4 , false , false , false , false ) ;
2019-03-14 15:06:03 +03:00
` ` `
* /
2020-03-04 16:38:40 +03:00
fn accounts ( & self , token : Token ) -> Result < Vec < AcctPathMapping > , ErrorKind > ;
2019-03-14 15:06:03 +03:00
/**
Networked version of [ Owner ::create_account_path ] ( struct . Owner . html #method . create_account_path ) .
# Json rpc example
` ` `
# grin_wallet_api ::doctest_helper_json_rpc_owner_assert_response! (
2019-03-22 15:03:25 +03:00
# r #"
2019-03-14 15:06:03 +03:00
{
" jsonrpc " : " 2.0 " ,
" method " : " create_account_path " ,
2020-03-04 16:38:40 +03:00
" params " : {
" token " : " d202964900000000d302964900000000d402964900000000d502964900000000 " ,
" label " : " account1 "
} ,
2019-03-14 15:06:03 +03:00
" id " : 1
2019-03-22 15:03:25 +03:00
}
# " #
# ,
# r #"
2019-03-14 15:06:03 +03:00
{
" jsonrpc " : " 2.0 " ,
" result " : {
" Ok " : " 0200000001000000000000000000000000 "
} ,
" id " : 1
}
2019-03-22 15:03:25 +03:00
# " #
2020-03-04 16:38:40 +03:00
# , 4 , false , false , false , false ) ;
2019-03-14 15:06:03 +03:00
` ` `
* /
2020-03-04 16:38:40 +03:00
fn create_account_path ( & self , token : Token , label : & String ) -> Result < Identifier , ErrorKind > ;
2019-03-14 15:06:03 +03:00
/**
Networked version of [ Owner ::set_active_account ] ( struct . Owner . html #method . set_active_account ) .
# Json rpc example
` ` `
# grin_wallet_api ::doctest_helper_json_rpc_owner_assert_response! (
2019-03-22 15:03:25 +03:00
# r #"
2019-03-14 15:06:03 +03:00
{
" jsonrpc " : " 2.0 " ,
" method " : " set_active_account " ,
2020-03-04 16:38:40 +03:00
" params " : {
" token " : " d202964900000000d302964900000000d402964900000000d502964900000000 " ,
" label " : " default "
} ,
2019-03-14 15:06:03 +03:00
" id " : 1
2019-03-22 15:03:25 +03:00
}
# " #
# ,
# r #"
2019-03-14 15:06:03 +03:00
{
" jsonrpc " : " 2.0 " ,
" result " : {
" Ok " : null
} ,
" id " : 1
}
2019-03-22 15:03:25 +03:00
# " #
2020-03-04 16:38:40 +03:00
# , 4 , false , false , false , false ) ;
2019-03-14 15:06:03 +03:00
` ` `
* /
2020-03-04 16:38:40 +03:00
fn set_active_account ( & self , token : Token , label : & String ) -> Result < ( ) , ErrorKind > ;
2019-03-14 15:06:03 +03:00
/**
Networked version of [ Owner ::retrieve_outputs ] ( struct . Owner . html #method . retrieve_outputs ) .
2019-03-22 15:03:25 +03:00
# Json rpc example
2019-03-14 15:06:03 +03:00
` ` `
# grin_wallet_api ::doctest_helper_json_rpc_owner_assert_response! (
2019-03-22 15:03:25 +03:00
# r #"
2019-03-14 15:06:03 +03:00
{
" jsonrpc " : " 2.0 " ,
" method " : " retrieve_outputs " ,
2020-03-04 16:38:40 +03:00
" params " : {
" token " : " d202964900000000d302964900000000d402964900000000d502964900000000 " ,
" include_spent " : false ,
" refresh_from_node " : true ,
" tx_id " : null
} ,
2019-03-14 15:06:03 +03:00
" id " : 1
2019-03-22 15:03:25 +03:00
}
# " #
# ,
# r #"
2019-03-14 15:06:03 +03:00
{
2019-03-22 15:03:25 +03:00
" id " : 1 ,
2019-03-14 15:06:03 +03:00
" jsonrpc " : " 2.0 " ,
" result " : {
2019-03-22 15:03:25 +03:00
" Ok " : [
true ,
[
{
" commit " : " 08e1da9e6dc4d6e808a718b2f110a991dd775d65ce5ae408a4e1f002a4961aa9e7 " ,
" output " : {
" commit " : " 08e1da9e6dc4d6e808a718b2f110a991dd775d65ce5ae408a4e1f002a4961aa9e7 " ,
" height " : " 1 " ,
" is_coinbase " : true ,
" key_id " : " 0300000000000000000000000000000000 " ,
" lock_height " : " 4 " ,
" mmr_index " : null ,
" n_child " : 0 ,
" root_key_id " : " 0200000000000000000000000000000000 " ,
" status " : " Unspent " ,
" tx_log_entry " : 0 ,
" value " : " 60000000000 "
}
} ,
{
" commit " : " 087df32304c5d4ae8b2af0bc31e700019d722910ef87dd4eec3197b80b207e3045 " ,
" output " : {
" commit " : " 087df32304c5d4ae8b2af0bc31e700019d722910ef87dd4eec3197b80b207e3045 " ,
" height " : " 2 " ,
" is_coinbase " : true ,
" key_id " : " 0300000000000000000000000100000000 " ,
" lock_height " : " 5 " ,
" mmr_index " : null ,
" n_child " : 1 ,
" root_key_id " : " 0200000000000000000000000000000000 " ,
" status " : " Unspent " ,
" tx_log_entry " : 1 ,
" value " : " 60000000000 "
}
}
]
]
}
2019-03-14 15:06:03 +03:00
}
2019-03-22 15:03:25 +03:00
# " #
2020-03-04 16:38:40 +03:00
# , 2 , false , false , false , false ) ;
2019-03-14 15:06:03 +03:00
` ` `
2019-03-22 15:03:25 +03:00
* /
2019-03-14 15:06:03 +03:00
fn retrieve_outputs (
& self ,
2020-03-04 16:38:40 +03:00
token : Token ,
2019-03-14 15:06:03 +03:00
include_spent : bool ,
refresh_from_node : bool ,
tx_id : Option < u32 > ,
2019-03-22 15:03:25 +03:00
) -> Result < ( bool , Vec < OutputCommitMapping > ) , ErrorKind > ;
2019-03-14 15:06:03 +03:00
/**
Networked version of [ Owner ::retrieve_txs ] ( struct . Owner . html #method . retrieve_txs ) .
2019-03-22 15:03:25 +03:00
# Json rpc example
2019-03-14 15:06:03 +03:00
` ` `
2019-03-22 15:03:25 +03:00
# grin_wallet_api ::doctest_helper_json_rpc_owner_assert_response! (
# r #"
{
" jsonrpc " : " 2.0 " ,
" method " : " retrieve_txs " ,
2020-03-04 16:38:40 +03:00
" params " : {
" token " : " d202964900000000d302964900000000d402964900000000d502964900000000 " ,
" refresh_from_node " : true ,
" tx_id " : null ,
" tx_slate_id " : null
} ,
2019-03-22 15:03:25 +03:00
" id " : 1
}
# " #
# ,
# r #"
{
" id " : 1 ,
2019-03-14 15:06:03 +03:00
" jsonrpc " : " 2.0 " ,
2019-03-22 15:03:25 +03:00
" result " : {
" Ok " : [
true ,
[
{
" amount_credited " : " 60000000000 " ,
" amount_debited " : " 0 " ,
" confirmation_ts " : " 2019-01-15T16:01:26Z " ,
" confirmed " : true ,
" creation_ts " : " 2019-01-15T16:01:26Z " ,
" fee " : null ,
" id " : 0 ,
2019-10-03 17:15:25 +03:00
" kernel_excess " : " 0838e19c490038b10f051c9c190a9b1f96d59bbd242f5d3143f50630deb74342ed " ,
" kernel_lookup_min_height " : 1 ,
2019-03-22 15:03:25 +03:00
" num_inputs " : 0 ,
" num_outputs " : 1 ,
" parent_key_id " : " 0200000000000000000000000000000000 " ,
" stored_tx " : null ,
2019-12-02 16:54:57 +03:00
" ttl_cutoff_height " : null ,
2019-03-22 15:03:25 +03:00
" tx_slate_id " : null ,
2019-11-28 17:34:27 +03:00
" payment_proof " : null ,
2020-03-10 18:49:17 +03:00
" reverted_after " : null ,
2019-03-22 15:03:25 +03:00
" tx_type " : " ConfirmedCoinbase "
} ,
{
" amount_credited " : " 60000000000 " ,
" amount_debited " : " 0 " ,
" confirmation_ts " : " 2019-01-15T16:01:26Z " ,
" confirmed " : true ,
" creation_ts " : " 2019-01-15T16:01:26Z " ,
" fee " : null ,
" id " : 1 ,
2019-10-03 17:15:25 +03:00
" kernel_excess " : " 08cd9d890c0b6a004f700aa5939a1ce0488fe2a11fa33cf096b50732ceab0be1df " ,
" kernel_lookup_min_height " : 2 ,
2019-03-22 15:03:25 +03:00
" num_inputs " : 0 ,
" num_outputs " : 1 ,
" parent_key_id " : " 0200000000000000000000000000000000 " ,
" stored_tx " : null ,
2019-12-02 16:54:57 +03:00
" ttl_cutoff_height " : null ,
2019-11-28 17:34:27 +03:00
" payment_proof " : null ,
2020-03-10 18:49:17 +03:00
" reverted_after " : null ,
2020-03-04 16:38:40 +03:00
" tx_slate_id " : null ,
2019-03-22 15:03:25 +03:00
" tx_type " : " ConfirmedCoinbase "
2019-03-14 15:06:03 +03:00
}
2019-03-22 15:03:25 +03:00
]
]
}
2019-03-14 15:06:03 +03:00
}
2019-03-22 15:03:25 +03:00
# " #
2020-03-04 16:38:40 +03:00
# , 2 , false , false , false , false ) ;
2019-03-14 15:06:03 +03:00
` ` `
2019-03-22 15:03:25 +03:00
* /
2019-03-14 15:06:03 +03:00
fn retrieve_txs (
& self ,
2020-03-04 16:38:40 +03:00
token : Token ,
2019-03-14 15:06:03 +03:00
refresh_from_node : bool ,
tx_id : Option < u32 > ,
tx_slate_id : Option < Uuid > ,
) -> Result < ( bool , Vec < TxLogEntry > ) , ErrorKind > ;
/**
Networked version of [ Owner ::retrieve_summary_info ] ( struct . Owner . html #method . retrieve_summary_info ) .
` ` `
# grin_wallet_api ::doctest_helper_json_rpc_owner_assert_response! (
2019-03-22 15:03:25 +03:00
# r #"
2019-03-14 15:06:03 +03:00
{
" jsonrpc " : " 2.0 " ,
" method " : " retrieve_summary_info " ,
2020-03-04 16:38:40 +03:00
" params " : {
" token " : " d202964900000000d302964900000000d402964900000000d502964900000000 " ,
" refresh_from_node " : true ,
" minimum_confirmations " : 1
} ,
2019-03-14 15:06:03 +03:00
" id " : 1
2019-03-22 15:03:25 +03:00
}
# " #
# ,
# r #"
2019-03-14 15:06:03 +03:00
{
2019-03-22 15:03:25 +03:00
" id " : 1 ,
2019-03-14 15:06:03 +03:00
" jsonrpc " : " 2.0 " ,
" result " : {
2019-03-22 15:03:25 +03:00
" Ok " : [
true ,
{
" amount_awaiting_confirmation " : " 0 " ,
" amount_awaiting_finalization " : " 0 " ,
" amount_currently_spendable " : " 60000000000 " ,
" amount_immature " : " 180000000000 " ,
" amount_locked " : " 0 " ,
2020-03-10 18:49:17 +03:00
" amount_reverted " : " 0 " ,
2019-03-22 15:03:25 +03:00
" last_confirmed_height " : " 4 " ,
" minimum_confirmations " : " 1 " ,
" total " : " 240000000000 "
}
]
}
2019-03-14 15:06:03 +03:00
}
2019-03-22 15:03:25 +03:00
# " #
2020-03-04 16:38:40 +03:00
# , 4 , false , false , false , false ) ;
2019-03-14 15:06:03 +03:00
` ` `
* /
2019-03-22 15:03:25 +03:00
2019-03-14 15:06:03 +03:00
fn retrieve_summary_info (
& self ,
2020-03-04 16:38:40 +03:00
token : Token ,
2019-03-14 15:06:03 +03:00
refresh_from_node : bool ,
minimum_confirmations : u64 ,
) -> Result < ( bool , WalletInfo ) , ErrorKind > ;
2019-03-14 18:05:13 +03:00
/**
2019-05-01 22:12:23 +03:00
Networked version of [ Owner ::init_send_tx ] ( struct . Owner . html #method . init_send_tx ) .
2019-03-14 18:05:13 +03:00
` ` `
2019-03-22 15:03:25 +03:00
# grin_wallet_api ::doctest_helper_json_rpc_owner_assert_response! (
# r #"
{
" jsonrpc " : " 2.0 " ,
2019-05-01 22:12:23 +03:00
" method " : " init_send_tx " ,
2019-03-29 19:00:02 +03:00
" params " : {
2020-03-04 16:38:40 +03:00
" token " : " d202964900000000d302964900000000d402964900000000d502964900000000 " ,
2019-03-29 19:00:02 +03:00
" args " : {
" src_acct_name " : null ,
" amount " : " 6000000000 " ,
" minimum_confirmations " : 2 ,
" max_outputs " : 500 ,
" num_change_outputs " : 1 ,
" selection_strategy_is_use_all " : true ,
" target_slate_version " : null ,
2020-06-12 12:40:07 +03:00
" payment_proof_recipient_address " : " tgrin1xtxavwfgs48ckf3gk8wwgcndmn0nt4tvkl8a7ltyejjcy2mc6nfs9gm2lp " ,
2019-12-02 16:54:57 +03:00
" ttl_blocks " : null ,
2019-03-29 19:00:02 +03:00
" send_args " : null
}
} ,
2019-03-22 15:03:25 +03:00
" id " : 1
}
# " #
# ,
# r #"
{
2020-05-19 13:19:03 +03:00
" id " : 1 ,
" jsonrpc " : " 2.0 " ,
" result " : {
" Ok " : {
" amt " : " 6000000000 " ,
" fee " : " 8000000 " ,
" id " : " 0436430c-2b02-624c-2032-570501212b00 " ,
2020-06-26 14:37:54 +03:00
" off " : " d202964900000000d302964900000000d402964900000000d502964900000000 " ,
2020-05-19 13:19:03 +03:00
" proof " : {
2020-06-26 14:37:54 +03:00
" raddr " : " 32cdd63928854f8b2628b1dce4626ddcdf35d56cb7cfdf7d64cca5822b78d4d3 " ,
" saddr " : " 32cdd63928854f8b2628b1dce4626ddcdf35d56cb7cfdf7d64cca5822b78d4d3 "
2020-05-19 13:19:03 +03:00
} ,
" sigs " : [
{
2020-06-26 14:37:54 +03:00
" nonce " : " 031b84c5567b126440995d3ed5aaba0565d71e1834604819ff9c17f5e9d5dd078f " ,
" xs " : " 023878ce845727f3a4ec76ca3f3db4b38a2d05d636b8c3632108b857fed63c96de "
2020-05-19 13:19:03 +03:00
}
] ,
" sta " : " S1 " ,
" ver " : " 4:2 "
2019-03-22 15:03:25 +03:00
}
2020-05-19 13:19:03 +03:00
}
2019-03-22 15:03:25 +03:00
}
# " #
2020-03-04 16:38:40 +03:00
# , 4 , false , false , false , false ) ;
2019-03-14 18:05:13 +03:00
` ` `
2019-03-22 15:03:25 +03:00
* /
2019-03-14 18:05:13 +03:00
2020-03-04 16:38:40 +03:00
fn init_send_tx ( & self , token : Token , args : InitTxArgs ) -> Result < VersionedSlate , ErrorKind > ;
2019-05-01 22:12:23 +03:00
/**
Networked version of [ Owner ::issue_invoice_tx ] ( struct . Owner . html #method . issue_invoice_tx ) .
` ` `
# grin_wallet_api ::doctest_helper_json_rpc_owner_assert_response! (
# r #"
{
" jsonrpc " : " 2.0 " ,
" method " : " issue_invoice_tx " ,
" params " : {
2020-03-04 16:38:40 +03:00
" token " : " d202964900000000d302964900000000d402964900000000d502964900000000 " ,
2019-05-01 22:12:23 +03:00
" args " : {
" amount " : " 6000000000 " ,
" dest_acct_name " : null ,
" target_slate_version " : null
}
} ,
" id " : 1
}
# " #
# ,
# r #"
{
" id " : 1 ,
" jsonrpc " : " 2.0 " ,
" result " : {
" Ok " : {
2020-05-19 13:19:03 +03:00
" amt " : " 6000000000 " ,
2019-05-01 22:12:23 +03:00
" id " : " 0436430c-2b02-624c-2032-570501212b00 " ,
2020-06-26 14:37:54 +03:00
" off " : " d202964900000000d302964900000000d402964900000000d502964900000000 " ,
2020-05-19 13:19:03 +03:00
" sigs " : [
2019-05-01 22:12:23 +03:00
{
2020-06-26 14:37:54 +03:00
" nonce " : " 031b84c5567b126440995d3ed5aaba0565d71e1834604819ff9c17f5e9d5dd078f " ,
" xs " : " 028e95921cc0d5be5922362265d352c9bdabe51a9e1502a3f0d4a10387f1893f40 "
2019-05-01 22:12:23 +03:00
}
] ,
2020-05-19 13:19:03 +03:00
" sta " : " I1 " ,
" ver " : " 4:2 "
2019-05-01 22:12:23 +03:00
}
}
}
# " #
2020-03-04 16:38:40 +03:00
# , 4 , false , false , false , false ) ;
2019-05-01 22:12:23 +03:00
` ` `
* /
2020-03-04 16:38:40 +03:00
fn issue_invoice_tx (
& self ,
token : Token ,
args : IssueInvoiceTxArgs ,
) -> Result < VersionedSlate , ErrorKind > ;
2019-05-01 22:12:23 +03:00
/**
Networked version of [ Owner ::process_invoice_tx ] ( struct . Owner . html #method . process_invoice_tx ) .
` ` `
# grin_wallet_api ::doctest_helper_json_rpc_owner_assert_response! (
# r #"
{
" jsonrpc " : " 2.0 " ,
" method " : " process_invoice_tx " ,
2020-03-04 16:38:40 +03:00
" params " : {
" token " : " d202964900000000d302964900000000d402964900000000d502964900000000 " ,
" slate " : {
2020-05-19 13:19:03 +03:00
" amt " : " 6000000000 " ,
2019-05-01 22:12:23 +03:00
" id " : " 0436430c-2b02-624c-2032-570501212b00 " ,
2020-06-26 14:37:54 +03:00
" off " : " d202964900000000d302964900000000d402964900000000d502964900000000 " ,
2020-05-19 13:19:03 +03:00
" sigs " : [
2019-05-01 22:12:23 +03:00
{
2020-06-26 14:37:54 +03:00
" nonce " : " 031b84c5567b126440995d3ed5aaba0565d71e1834604819ff9c17f5e9d5dd078f " ,
" xs " : " 028e95921cc0d5be5922362265d352c9bdabe51a9e1502a3f0d4a10387f1893f40 "
2019-05-01 22:12:23 +03:00
}
] ,
2020-05-19 13:19:03 +03:00
" sta " : " I1 " ,
" ver " : " 4:2 "
2019-05-01 22:12:23 +03:00
} ,
2020-03-04 16:38:40 +03:00
" args " : {
2019-05-01 22:12:23 +03:00
" src_acct_name " : null ,
" amount " : " 0 " ,
" minimum_confirmations " : 2 ,
" max_outputs " : 500 ,
" num_change_outputs " : 1 ,
" selection_strategy_is_use_all " : true ,
" target_slate_version " : null ,
2019-11-28 17:34:27 +03:00
" payment_proof_recipient_address " : null ,
2019-12-02 16:54:57 +03:00
" ttl_blocks " : null ,
2019-05-01 22:12:23 +03:00
" send_args " : null
}
2020-03-04 16:38:40 +03:00
} ,
2019-05-01 22:12:23 +03:00
" id " : 1
}
# " #
# ,
# r #"
{
" id " : 1 ,
" jsonrpc " : " 2.0 " ,
" result " : {
" Ok " : {
2020-05-19 13:19:03 +03:00
" coms " : [
2019-05-01 22:12:23 +03:00
{
2020-06-26 14:37:54 +03:00
" c " : " 08e1da9e6dc4d6e808a718b2f110a991dd775d65ce5ae408a4e1f002a4961aa9e7 " ,
2020-05-19 13:19:03 +03:00
" f " : 1
2019-05-01 22:12:23 +03:00
} ,
{
2020-06-26 14:37:54 +03:00
" c " : " 094be57c91787fc2033d5d97fae099f1a6ddb37ea48370f1a138f09524c767fdd3 " ,
" p " : " 1319630b26d02363861ebdb15514086dc8b0772b4bb63ef9b828704e0ac348efada6747dd7a29848138d630c7b403e573c9cde04be5d25f2d344db4b010d6b890dd6c54cc0911c0cadc7a8a225b2ec3f2dcac88189a17aa62257e969eef9de9172009d8e864e413f1953998b28531e580d3ea495a512d320e8d4ff50e7495a6c283c6e544d16364d34272805893526f1e3b6fd176ef4adc5671b165cf28efcfb8d25c0dfcd018a2c5e65beeb9201f3983194e5a521c0844d05c700654dfaed1b9b39dae08cc9afab9cb891256bc0237ad2ce78da8b44586580f52dd346dcafde5e471917f16e4c4b51e966e1946f13e31771503c85bb0f1b41d1c7fcc953e70af55400638a35e7f5610f9f4c5b881a35060a693deaf46e1839c54a8f7d2c626b05acd3450b72ae8f2e0f8721bcbbd8562141d3fef851c6ac3c8069fa6389389bc4fcba5e4fb49709a3b63a59ba96a82827dfbd6f16de849ef95f3114593d207aff6e030152929fa220b0c3b54ca419cfcbffb7a0106dd3154e858878c7d8f38cadcc376c502bdc50292b494484936d0846fc3fac10910962bca4ddcca5c80b458fd7df15e9a6c2f39b516425a2190a97c9d0e2e2f105ee29905f36e3a648a135ebf387d0bb2a6b61d95b215319d6dc9ee8b4b2798810fb6e01c007041b288c2b39e805c9af86c88dd4a380b6a346b4a0e67bba6aaac5acc70088ac3297486b90cfe371d9464552747a2f7680f42d5629fb09bed835382d842234712c0574c5b4f256c226e77602429983e4def71541cff80ccf4cd3b761685c91463c8e1c7bf828699c688509282b85e752424df3da670b3cfacdea2f66cfb804fecdf8b7eb056e8917fdae78d83c011964e3d5a0748873f817d0abf4b04c20452733eac35c318b96e100a5ace0f54085bd24f968b8fc5b276e0d7b134f01db50b3d2771cdcf1423d44 "
2019-05-01 22:12:23 +03:00
}
] ,
2020-05-19 13:19:03 +03:00
" fee " : " 8000000 " ,
" id " : " 0436430c-2b02-624c-2032-570501212b00 " ,
2020-06-26 14:37:54 +03:00
" off " : " 9b6e26e78b49c7136ce70334dd83acb89c78f6c54cfab64ba62e598837241d36 " ,
2020-05-19 13:19:03 +03:00
" sigs " : [
{
2020-06-26 14:37:54 +03:00
" nonce " : " 031b84c5567b126440995d3ed5aaba0565d71e1834604819ff9c17f5e9d5dd078f " ,
" part " : " 8f07ddd5e9f5179cff19486034181ed76505baaad53e5d994064127b56c5841bf1804f6fe8e55f5556bbd807fefbcd72b30d90cf708f8c56447acc63228274e6 " ,
" xs " : " 023878ce845727f3a4ec76ca3f3db4b38a2d05d636b8c3632108b857fed63c96de "
2020-05-19 13:19:03 +03:00
}
] ,
" sta " : " I2 " ,
" ver " : " 4:2 "
2019-05-01 22:12:23 +03:00
}
}
}
# " #
2020-03-04 16:38:40 +03:00
# , 4 , false , false , false , false ) ;
2019-05-01 22:12:23 +03:00
` ` `
* /
2019-08-06 13:34:59 +03:00
fn process_invoice_tx (
& self ,
2020-03-04 16:38:40 +03:00
token : Token ,
2019-08-06 13:34:59 +03:00
slate : VersionedSlate ,
args : InitTxArgs ,
) -> Result < VersionedSlate , ErrorKind > ;
2019-03-14 15:06:03 +03:00
2019-03-14 18:05:13 +03:00
/**
Networked version of [ Owner ::tx_lock_outputs ] ( struct . Owner . html #method . tx_lock_outputs ) .
` ` `
# grin_wallet_api ::doctest_helper_json_rpc_owner_assert_response! (
2019-03-22 15:03:25 +03:00
# r #"
2019-03-14 18:05:13 +03:00
{
" jsonrpc " : " 2.0 " ,
" method " : " tx_lock_outputs " ,
2019-03-22 15:03:25 +03:00
" id " : 1 ,
2020-03-04 16:38:40 +03:00
" params " : {
" token " : " d202964900000000d302964900000000d402964900000000d502964900000000 " ,
" slate " : {
2020-05-19 13:19:03 +03:00
" ver " : " 4:2 " ,
2019-03-22 15:03:25 +03:00
" id " : " 0436430c-2b02-624c-2032-570501212b00 " ,
2020-05-19 13:19:03 +03:00
" sta " : " S1 " ,
2020-06-26 14:37:54 +03:00
" off " : " d202964900000000d302964900000000d402964900000000d502964900000000 " ,
2020-05-19 13:19:03 +03:00
" amt " : " 60000000000 " ,
" fee " : " 7000000 " ,
" sigs " : [
{
2020-06-26 14:37:54 +03:00
" xs " : " 030152d2d72e2dba7c6086ad49a219d9ff0dfe0fd993dcaea22e058c210033ce93 " ,
" nonce " : " 031b84c5567b126440995d3ed5aaba0565d71e1834604819ff9c17f5e9d5dd078f "
2020-05-19 13:19:03 +03:00
}
]
}
2020-03-04 16:38:40 +03:00
}
2019-03-22 15:03:25 +03:00
}
# " #
# ,
# r #"
2019-03-14 18:05:13 +03:00
{
" jsonrpc " : " 2.0 " ,
2019-03-22 15:03:25 +03:00
" id " : 1 ,
2019-03-14 18:05:13 +03:00
" result " : {
2019-03-22 15:03:25 +03:00
" Ok " : null
}
2019-03-14 18:05:13 +03:00
}
2019-03-22 15:03:25 +03:00
# " #
2020-03-04 16:38:40 +03:00
# , 5 , true , false , false , false ) ;
2019-03-22 15:03:25 +03:00
2019-03-14 18:05:13 +03:00
` ` `
* /
2020-05-19 13:19:03 +03:00
fn tx_lock_outputs ( & self , token : Token , slate : VersionedSlate ) -> Result < ( ) , ErrorKind > ;
2019-03-14 18:05:13 +03:00
2019-03-14 15:06:03 +03:00
/**
Networked version of [ Owner ::finalize_tx ] ( struct . Owner . html #method . finalize_tx ) .
` ` `
# grin_wallet_api ::doctest_helper_json_rpc_owner_assert_response! (
2019-03-22 15:03:25 +03:00
# r #"
2019-03-14 15:06:03 +03:00
{
" jsonrpc " : " 2.0 " ,
" method " : " finalize_tx " ,
2019-03-22 15:03:25 +03:00
" id " : 1 ,
2020-03-04 16:38:40 +03:00
" params " : {
" token " : " d202964900000000d302964900000000d402964900000000d502964900000000 " ,
2020-05-19 13:19:03 +03:00
" slate " :
{
" ver " : " 4:2 " ,
2020-03-04 16:38:40 +03:00
" id " : " 0436430c-2b02-624c-2032-570501212b00 " ,
2020-05-19 13:19:03 +03:00
" sta " : " S2 " ,
2020-06-26 14:37:54 +03:00
" off " : " a4052c9200000001a6052c9200000002ed564fab50b75fc5ea32ce052fc9bebf " ,
2020-05-19 13:19:03 +03:00
" sigs " : [
2020-03-04 16:38:40 +03:00
{
2020-06-26 14:37:54 +03:00
" xs " : " 033bbe2a419ea2e9d6810a8d66552e709d1783ca50759a44dbaf63fc79c0164c4c " ,
" nonce " : " 031b84c5567b126440995d3ed5aaba0565d71e1834604819ff9c17f5e9d5dd078f " ,
" part " : " 8f07ddd5e9f5179cff19486034181ed76505baaad53e5d994064127b56c5841b35fdfe55271f2ae73d75f58c70d1efb69b3384c7bc507d57e99e56de77e20874 "
2020-05-19 13:19:03 +03:00
}
] ,
" coms " : [
2020-06-26 14:37:54 +03:00
{
" c " : " 099b48cfb1f80a2347dc89818449e68e76a3c6817a532a8e9ef2b4a5ccf4363850 " ,
" p " : " 29701ceae262cac77b79b868c883a292e61e6de8192b868edcd1300b0973d91396b156ace6bd673402a303de10ddd8a5e6b7f17ba6557a574a672bd04cc273ab04ed8e2ca80bac483345c0ec843f521814ce1301ec9adc38956a12b4d948acce71295a4f52bcdeb8a1c9f2d6b2da5d731262a5e9c0276ef904df9ef8d48001420cd59f75a2f1ae5c7a1c7c6b9f140e7613e52ef9e249f29f9340b7efb80699e460164324616f98fd4cde3db52497c919e95222fffeacb7e65deca7e368a80ce713c19de7da5369726228ee336f5bd494538c12ccbffeb1b9bfd5fc8906d1c64245b516f103fa96d9c56975837652c1e0fa5803d7ccf1147d8f927e36da717f7ad79471dbe192f5f50f87a79fc3fe030dba569b634b92d2cf307993cce545633af263897cd7e6ebf4dcafb176d07358bdc38d03e45a49dfa9c8c6517cd68d167ffbf6c3b4de0e2dd21909cbad4c467b84e5700be473a39ac59c669d7c155c4bcab9b8026eea3431c779cd277e4922d2b9742e1f6678cbe869ec3b5b7ef4132ddb6cdd06cf27dbeb28be72b949fa897610e48e3a0d789fd2eea75abc97b3dc7e00e5c8b3d24e40c6f24112adb72352b89a2bef0599345338e9e76202a3c46efa6370952b2aca41aadbae0ea32531acafcdab6dd066d769ebf50cf4f3c0a59d2d5fa79600a207b9417c623f76ad05e8cccfcd4038f9448bc40f127ca7c0d372e46074e334fe49f5a956ec0056f4da601e6af80eb1a6c4951054869e665b296d8c14f344ca2dc5fdd5df4a3652536365a1615ad9b422165c77bf8fe65a835c8e0c41e070014eb66ef8c525204e990b3a3d663c1e42221b496895c37a2f0c1bf05e91235409c3fe3d89a9a79d6c78609ab18a463311911f71fa37bb73b15fcd38143d1404fd2ce81004dc7ff89cf1115dcc0c35ce1c1bf9941586fb959770f2618ccb7118a7 "
2020-03-04 16:38:40 +03:00
}
]
}
2019-03-22 15:03:25 +03:00
}
}
# " #
# ,
# r #"
2019-03-14 15:06:03 +03:00
{
" jsonrpc " : " 2.0 " ,
2019-03-22 15:03:25 +03:00
" id " : 1 ,
2019-03-14 15:06:03 +03:00
" result " : {
2020-05-19 13:19:03 +03:00
" Ok " : {
" coms " : [
{
2020-06-26 14:37:54 +03:00
" c " : " 087df32304c5d4ae8b2af0bc31e700019d722910ef87dd4eec3197b80b207e3045 " ,
2020-05-19 13:19:03 +03:00
" f " : 1
} ,
{
2020-06-26 14:37:54 +03:00
" c " : " 08e1da9e6dc4d6e808a718b2f110a991dd775d65ce5ae408a4e1f002a4961aa9e7 " ,
2020-05-19 13:19:03 +03:00
" f " : 1
} ,
{
2020-06-26 14:37:54 +03:00
" c " : " 099b48cfb1f80a2347dc89818449e68e76a3c6817a532a8e9ef2b4a5ccf4363850 " ,
" p " : " 29701ceae262cac77b79b868c883a292e61e6de8192b868edcd1300b0973d91396b156ace6bd673402a303de10ddd8a5e6b7f17ba6557a574a672bd04cc273ab04ed8e2ca80bac483345c0ec843f521814ce1301ec9adc38956a12b4d948acce71295a4f52bcdeb8a1c9f2d6b2da5d731262a5e9c0276ef904df9ef8d48001420cd59f75a2f1ae5c7a1c7c6b9f140e7613e52ef9e249f29f9340b7efb80699e460164324616f98fd4cde3db52497c919e95222fffeacb7e65deca7e368a80ce713c19de7da5369726228ee336f5bd494538c12ccbffeb1b9bfd5fc8906d1c64245b516f103fa96d9c56975837652c1e0fa5803d7ccf1147d8f927e36da717f7ad79471dbe192f5f50f87a79fc3fe030dba569b634b92d2cf307993cce545633af263897cd7e6ebf4dcafb176d07358bdc38d03e45a49dfa9c8c6517cd68d167ffbf6c3b4de0e2dd21909cbad4c467b84e5700be473a39ac59c669d7c155c4bcab9b8026eea3431c779cd277e4922d2b9742e1f6678cbe869ec3b5b7ef4132ddb6cdd06cf27dbeb28be72b949fa897610e48e3a0d789fd2eea75abc97b3dc7e00e5c8b3d24e40c6f24112adb72352b89a2bef0599345338e9e76202a3c46efa6370952b2aca41aadbae0ea32531acafcdab6dd066d769ebf50cf4f3c0a59d2d5fa79600a207b9417c623f76ad05e8cccfcd4038f9448bc40f127ca7c0d372e46074e334fe49f5a956ec0056f4da601e6af80eb1a6c4951054869e665b296d8c14f344ca2dc5fdd5df4a3652536365a1615ad9b422165c77bf8fe65a835c8e0c41e070014eb66ef8c525204e990b3a3d663c1e42221b496895c37a2f0c1bf05e91235409c3fe3d89a9a79d6c78609ab18a463311911f71fa37bb73b15fcd38143d1404fd2ce81004dc7ff89cf1115dcc0c35ce1c1bf9941586fb959770f2618ccb7118a7 "
2020-05-19 13:19:03 +03:00
} ,
{
2020-06-26 14:37:54 +03:00
" c " : " 0812276cc788e6870612296d926cba9f0e7b9810670710b5a6e6f1ba006d395774 " ,
" p " : " 284b9f9199411c6bbf7227eae15cc9fa7ed30534af3ecff85b0d016da329cae1f1edf79f01426434cb90afcc2f0a1fb296e5c51a91b5e57a1f0230fda4f8c5950e7986fa379b99d64b6039a86cc7e35e040ba192b781043959851268ca9874a918805ea958c84f7fee8d3ab4262f032f5a3f840ebcdd273b29be810114e6e86a959d8e4c080572e3ef249edd6ad68503ec3bc4486548520ea2775a41aea67aac99945fce9e7a7769d71f893ad7f0d0108692f6b6852312cae6f9857063055bda59dce521927c70040b8026a41b6517cae0a1c947ca244984a5c0adf7c6483b0939346c48f61cac37d501f46a1c5878b67cee0d0723f4eeadc9f5d71ed5e9f33b4294b58d3ebeefeaa13f20357599be549ce18e6e2eb1d50e1235ccc40ec9184c68a623741a7238ce69aa3a1d25156b3b7eb38fdd6fbe5473979feee3317df279c60d48a289826aa4c76dbce24d526890d4e6e2f83e80f674a1248fc1dc037d982009012ae1133f5e158ae6cdadb18c8d53e4a8ae5595c758782c67aa0c20f146d52085cf45a35794cec45702830f8952a69744718fbe6fe0d3da66e348dd3473a0aced7080fbf5494c3e7e141916f3b135b33277f998fcd9acfbca8709814866e9838a5dcda4c29422cf157293e6fc2ccc2d25423517843bd8e21c61ced72312c0b48814c312021b0d31598d2389b0b329baa1169922a4c34173dd5f540545be5066a0f291f1a870e1aaff94c19f0a855254882a17984baeda08e8ead53d1563e9ee4bc36742789cef4f3ab158054d7ddfe2a2b37b5a8a30be84ff7df9a7d758a9b76751a3622057721a3ec5b873582d0c91cd1febbc153662739854ea15c9903023c193c6b5768b55484108f897cdc47d13a9088b32558e57f12f5807668649c99a17b51905127340e8b49c42775f1b3cab072dfad33d33cc1e4ba5964d728ed0a905 "
2020-05-19 13:19:03 +03:00
}
] ,
2019-03-22 15:03:25 +03:00
" fee " : " 7000000 " ,
" id " : " 0436430c-2b02-624c-2032-570501212b00 " ,
2020-06-26 14:37:54 +03:00
" off " : " 750dbf4fd43b7f4cfd68d2698a522f3ff6e6a00ad9895b33f1ec46493b837b49 " ,
2020-05-19 13:19:03 +03:00
" sigs " : [
2019-03-22 15:03:25 +03:00
{
2020-06-26 14:37:54 +03:00
" nonce " : " 031b84c5567b126440995d3ed5aaba0565d71e1834604819ff9c17f5e9d5dd078f " ,
" part " : " 8f07ddd5e9f5179cff19486034181ed76505baaad53e5d994064127b56c5841b35fdfe55271f2ae73d75f58c70d1efb69b3384c7bc507d57e99e56de77e20874 " ,
" xs " : " 033bbe2a419ea2e9d6810a8d66552e709d1783ca50759a44dbaf63fc79c0164c4c "
2019-03-22 15:03:25 +03:00
} ,
{
2020-06-26 14:37:54 +03:00
" nonce " : " 031b84c5567b126440995d3ed5aaba0565d71e1834604819ff9c17f5e9d5dd078f " ,
" part " : " 8f07ddd5e9f5179cff19486034181ed76505baaad53e5d994064127b56c5841bdad934daa17db7e477c4eed90afed40d1117896df8c4f5861b6309a949878074 " ,
" xs " : " 030152d2d72e2dba7c6086ad49a219d9ff0dfe0fd993dcaea22e058c210033ce93 "
2019-03-22 15:03:25 +03:00
}
] ,
2020-05-19 13:19:03 +03:00
" sta " : " S3 " ,
" ver " : " 4:2 "
2019-03-14 15:06:03 +03:00
}
2019-03-22 15:03:25 +03:00
}
2019-03-14 15:06:03 +03:00
}
2019-03-22 15:03:25 +03:00
# " #
2020-03-04 16:38:40 +03:00
# , 5 , true , true , false , false ) ;
2019-03-14 15:06:03 +03:00
` ` `
* /
2020-03-04 16:38:40 +03:00
fn finalize_tx ( & self , token : Token , slate : VersionedSlate )
-> Result < VersionedSlate , ErrorKind > ;
2019-03-14 15:06:03 +03:00
/**
2019-03-22 15:03:25 +03:00
Networked version of [ Owner ::post_tx ] ( struct . Owner . html #method . post_tx ) .
2019-03-14 15:06:03 +03:00
` ` `
# grin_wallet_api ::doctest_helper_json_rpc_owner_assert_response! (
2019-03-22 15:03:25 +03:00
# r #"
2019-03-14 15:06:03 +03:00
{
" jsonrpc " : " 2.0 " ,
2019-03-22 15:03:25 +03:00
" id " : 1 ,
" method " : " post_tx " ,
2020-03-04 16:38:40 +03:00
" params " : {
" token " : " d202964900000000d302964900000000d402964900000000d502964900000000 " ,
2020-05-19 13:19:03 +03:00
" slate " : {
" ver " : " 4:2 " ,
" id " : " 0436430c-2b02-624c-2032-570501212b00 " ,
" sta " : " S3 " ,
2020-06-26 14:37:54 +03:00
" off " : " 750dbf4fd43b7f4cfd68d2698a522f3ff6e6a00ad9895b33f1ec46493b837b49 " ,
2020-05-19 13:19:03 +03:00
" fee " : " 7000000 " ,
2020-06-26 14:37:54 +03:00
" sigs " : [
{
" xs " : " 033bbe2a419ea2e9d6810a8d66552e709d1783ca50759a44dbaf63fc79c0164c4c " ,
" nonce " : " 031b84c5567b126440995d3ed5aaba0565d71e1834604819ff9c17f5e9d5dd078f " ,
" part " : " 8f07ddd5e9f5179cff19486034181ed76505baaad53e5d994064127b56c5841b35fdfe55271f2ae73d75f58c70d1efb69b3384c7bc507d57e99e56de77e20874 "
} ,
{
" xs " : " 030152d2d72e2dba7c6086ad49a219d9ff0dfe0fd993dcaea22e058c210033ce93 " ,
" nonce " : " 031b84c5567b126440995d3ed5aaba0565d71e1834604819ff9c17f5e9d5dd078f " ,
" part " : " 8f07ddd5e9f5179cff19486034181ed76505baaad53e5d994064127b56c5841bdad934daa17db7e477c4eed90afed40d1117896df8c4f5861b6309a949878074 "
}
] ,
" coms " : [
2019-03-22 15:03:25 +03:00
{
2020-05-19 13:19:03 +03:00
" f " : 1 ,
2020-06-26 14:37:54 +03:00
" c " : " 087df32304c5d4ae8b2af0bc31e700019d722910ef87dd4eec3197b80b207e3045 "
2019-03-22 15:03:25 +03:00
} ,
{
2020-05-19 13:19:03 +03:00
" f " : 1 ,
2020-06-26 14:37:54 +03:00
" c " : " 08e1da9e6dc4d6e808a718b2f110a991dd775d65ce5ae408a4e1f002a4961aa9e7 "
2019-03-22 15:03:25 +03:00
} ,
{
2020-06-26 14:37:54 +03:00
" c " : " 099b48cfb1f80a2347dc89818449e68e76a3c6817a532a8e9ef2b4a5ccf4363850 " ,
" p " : " 29701ceae262cac77b79b868c883a292e61e6de8192b868edcd1300b0973d91396b156ace6bd673402a303de10ddd8a5e6b7f17ba6557a574a672bd04cc273ab04ed8e2ca80bac483345c0ec843f521814ce1301ec9adc38956a12b4d948acce71295a4f52bcdeb8a1c9f2d6b2da5d731262a5e9c0276ef904df9ef8d48001420cd59f75a2f1ae5c7a1c7c6b9f140e7613e52ef9e249f29f9340b7efb80699e460164324616f98fd4cde3db52497c919e95222fffeacb7e65deca7e368a80ce713c19de7da5369726228ee336f5bd494538c12ccbffeb1b9bfd5fc8906d1c64245b516f103fa96d9c56975837652c1e0fa5803d7ccf1147d8f927e36da717f7ad79471dbe192f5f50f87a79fc3fe030dba569b634b92d2cf307993cce545633af263897cd7e6ebf4dcafb176d07358bdc38d03e45a49dfa9c8c6517cd68d167ffbf6c3b4de0e2dd21909cbad4c467b84e5700be473a39ac59c669d7c155c4bcab9b8026eea3431c779cd277e4922d2b9742e1f6678cbe869ec3b5b7ef4132ddb6cdd06cf27dbeb28be72b949fa897610e48e3a0d789fd2eea75abc97b3dc7e00e5c8b3d24e40c6f24112adb72352b89a2bef0599345338e9e76202a3c46efa6370952b2aca41aadbae0ea32531acafcdab6dd066d769ebf50cf4f3c0a59d2d5fa79600a207b9417c623f76ad05e8cccfcd4038f9448bc40f127ca7c0d372e46074e334fe49f5a956ec0056f4da601e6af80eb1a6c4951054869e665b296d8c14f344ca2dc5fdd5df4a3652536365a1615ad9b422165c77bf8fe65a835c8e0c41e070014eb66ef8c525204e990b3a3d663c1e42221b496895c37a2f0c1bf05e91235409c3fe3d89a9a79d6c78609ab18a463311911f71fa37bb73b15fcd38143d1404fd2ce81004dc7ff89cf1115dcc0c35ce1c1bf9941586fb959770f2618ccb7118a7 "
2020-05-19 13:19:03 +03:00
} ,
2019-05-31 10:33:23 +03:00
{
2020-06-26 14:37:54 +03:00
" c " : " 0812276cc788e6870612296d926cba9f0e7b9810670710b5a6e6f1ba006d395774 " ,
" p " : " 284b9f9199411c6bbf7227eae15cc9fa7ed30534af3ecff85b0d016da329cae1f1edf79f01426434cb90afcc2f0a1fb296e5c51a91b5e57a1f0230fda4f8c5950e7986fa379b99d64b6039a86cc7e35e040ba192b781043959851268ca9874a918805ea958c84f7fee8d3ab4262f032f5a3f840ebcdd273b29be810114e6e86a959d8e4c080572e3ef249edd6ad68503ec3bc4486548520ea2775a41aea67aac99945fce9e7a7769d71f893ad7f0d0108692f6b6852312cae6f9857063055bda59dce521927c70040b8026a41b6517cae0a1c947ca244984a5c0adf7c6483b0939346c48f61cac37d501f46a1c5878b67cee0d0723f4eeadc9f5d71ed5e9f33b4294b58d3ebeefeaa13f20357599be549ce18e6e2eb1d50e1235ccc40ec9184c68a623741a7238ce69aa3a1d25156b3b7eb38fdd6fbe5473979feee3317df279c60d48a289826aa4c76dbce24d526890d4e6e2f83e80f674a1248fc1dc037d982009012ae1133f5e158ae6cdadb18c8d53e4a8ae5595c758782c67aa0c20f146d52085cf45a35794cec45702830f8952a69744718fbe6fe0d3da66e348dd3473a0aced7080fbf5494c3e7e141916f3b135b33277f998fcd9acfbca8709814866e9838a5dcda4c29422cf157293e6fc2ccc2d25423517843bd8e21c61ced72312c0b48814c312021b0d31598d2389b0b329baa1169922a4c34173dd5f540545be5066a0f291f1a870e1aaff94c19f0a855254882a17984baeda08e8ead53d1563e9ee4bc36742789cef4f3ab158054d7ddfe2a2b37b5a8a30be84ff7df9a7d758a9b76751a3622057721a3ec5b873582d0c91cd1febbc153662739854ea15c9903023c193c6b5768b55484108f897cdc47d13a9088b32558e57f12f5807668649c99a17b51905127340e8b49c42775f1b3cab072dfad33d33cc1e4ba5964d728ed0a905 "
2019-05-31 10:33:23 +03:00
}
2019-03-22 15:03:25 +03:00
]
2020-05-19 13:19:03 +03:00
} ,
2020-03-04 16:38:40 +03:00
" fluff " : false
}
2019-03-22 15:03:25 +03:00
}
# " #
# ,
# r #"
2019-03-14 15:06:03 +03:00
{
2019-03-22 15:03:25 +03:00
" id " : 1 ,
2019-03-14 15:06:03 +03:00
" jsonrpc " : " 2.0 " ,
" result " : {
2019-03-22 15:03:25 +03:00
" Ok " : null
}
2019-03-14 15:06:03 +03:00
}
2019-03-22 15:03:25 +03:00
# " #
2020-03-04 16:38:40 +03:00
# , 5 , true , true , true , false ) ;
2019-03-14 15:06:03 +03:00
` ` `
* /
2019-03-22 15:03:25 +03:00
2020-05-19 13:19:03 +03:00
fn post_tx ( & self , token : Token , slate : VersionedSlate , fluff : bool ) -> Result < ( ) , ErrorKind > ;
2019-03-14 15:06:03 +03:00
/**
2019-03-22 15:03:25 +03:00
Networked version of [ Owner ::cancel_tx ] ( struct . Owner . html #method . cancel_tx ) .
2019-03-14 15:06:03 +03:00
` ` `
# grin_wallet_api ::doctest_helper_json_rpc_owner_assert_response! (
2019-03-22 15:03:25 +03:00
# r #"
2019-03-14 15:06:03 +03:00
{
" jsonrpc " : " 2.0 " ,
2019-03-22 15:03:25 +03:00
" method " : " cancel_tx " ,
2020-03-04 16:38:40 +03:00
" params " : {
" token " : " d202964900000000d302964900000000d402964900000000d502964900000000 " ,
" tx_id " : null ,
" tx_slate_id " : " 0436430c-2b02-624c-2032-570501212b00 "
} ,
2019-03-14 15:06:03 +03:00
" id " : 1
2019-03-22 15:03:25 +03:00
}
# " #
# ,
# r #"
2019-03-14 15:06:03 +03:00
{
2019-03-22 15:03:25 +03:00
" id " : 1 ,
2019-03-14 15:06:03 +03:00
" jsonrpc " : " 2.0 " ,
" result " : {
" Ok " : null
2019-03-22 15:03:25 +03:00
}
2019-03-14 15:06:03 +03:00
}
2019-03-22 15:03:25 +03:00
# " #
2020-03-04 16:38:40 +03:00
# , 5 , true , true , false , false ) ;
2019-03-14 15:06:03 +03:00
` ` `
* /
2020-03-04 16:38:40 +03:00
fn cancel_tx (
& self ,
token : Token ,
tx_id : Option < u32 > ,
tx_slate_id : Option < Uuid > ,
) -> Result < ( ) , ErrorKind > ;
2019-03-14 15:06:03 +03:00
/**
2019-03-22 15:03:25 +03:00
Networked version of [ Owner ::get_stored_tx ] ( struct . Owner . html #method . get_stored_tx ) .
2019-03-14 15:06:03 +03:00
2019-03-22 15:03:25 +03:00
` ` `
2019-03-14 15:06:03 +03:00
# grin_wallet_api ::doctest_helper_json_rpc_owner_assert_response! (
2019-03-22 15:03:25 +03:00
# r #"
2019-03-14 15:06:03 +03:00
{
" jsonrpc " : " 2.0 " ,
2019-03-22 15:03:25 +03:00
" method " : " get_stored_tx " ,
" id " : 1 ,
2020-03-04 16:38:40 +03:00
" params " : {
" token " : " d202964900000000d302964900000000d402964900000000d502964900000000 " ,
2020-06-25 12:06:04 +03:00
" id " : null ,
" slate_id " : " 0436430c-2b02-624c-2032-570501212b00 "
2020-03-04 16:38:40 +03:00
}
2019-03-22 15:03:25 +03:00
}
# " #
# ,
# r #"
2019-03-14 15:06:03 +03:00
{
" jsonrpc " : " 2.0 " ,
2019-03-22 15:03:25 +03:00
" id " : 1 ,
2019-03-14 15:06:03 +03:00
" result " : {
2019-03-22 15:03:25 +03:00
" Ok " : {
2020-06-25 12:06:04 +03:00
" coms " : [
{
2020-06-26 14:37:54 +03:00
" c " : " 099b48cfb1f80a2347dc89818449e68e76a3c6817a532a8e9ef2b4a5ccf4363850 " ,
" p " : " 29701ceae262cac77b79b868c883a292e61e6de8192b868edcd1300b0973d91396b156ace6bd673402a303de10ddd8a5e6b7f17ba6557a574a672bd04cc273ab04ed8e2ca80bac483345c0ec843f521814ce1301ec9adc38956a12b4d948acce71295a4f52bcdeb8a1c9f2d6b2da5d731262a5e9c0276ef904df9ef8d48001420cd59f75a2f1ae5c7a1c7c6b9f140e7613e52ef9e249f29f9340b7efb80699e460164324616f98fd4cde3db52497c919e95222fffeacb7e65deca7e368a80ce713c19de7da5369726228ee336f5bd494538c12ccbffeb1b9bfd5fc8906d1c64245b516f103fa96d9c56975837652c1e0fa5803d7ccf1147d8f927e36da717f7ad79471dbe192f5f50f87a79fc3fe030dba569b634b92d2cf307993cce545633af263897cd7e6ebf4dcafb176d07358bdc38d03e45a49dfa9c8c6517cd68d167ffbf6c3b4de0e2dd21909cbad4c467b84e5700be473a39ac59c669d7c155c4bcab9b8026eea3431c779cd277e4922d2b9742e1f6678cbe869ec3b5b7ef4132ddb6cdd06cf27dbeb28be72b949fa897610e48e3a0d789fd2eea75abc97b3dc7e00e5c8b3d24e40c6f24112adb72352b89a2bef0599345338e9e76202a3c46efa6370952b2aca41aadbae0ea32531acafcdab6dd066d769ebf50cf4f3c0a59d2d5fa79600a207b9417c623f76ad05e8cccfcd4038f9448bc40f127ca7c0d372e46074e334fe49f5a956ec0056f4da601e6af80eb1a6c4951054869e665b296d8c14f344ca2dc5fdd5df4a3652536365a1615ad9b422165c77bf8fe65a835c8e0c41e070014eb66ef8c525204e990b3a3d663c1e42221b496895c37a2f0c1bf05e91235409c3fe3d89a9a79d6c78609ab18a463311911f71fa37bb73b15fcd38143d1404fd2ce81004dc7ff89cf1115dcc0c35ce1c1bf9941586fb959770f2618ccb7118a7 "
2020-06-25 12:06:04 +03:00
}
] ,
" fee " : " 7000000 " ,
" id " : " 0436430c-2b02-624c-2032-570501212b00 " ,
" sigs " : [ ] ,
" sta " : " S3 " ,
" ver " : " 4:3 "
2019-03-14 15:06:03 +03:00
}
2019-03-22 15:03:25 +03:00
}
2019-03-14 15:06:03 +03:00
}
2019-03-22 15:03:25 +03:00
# " #
2020-03-04 16:38:40 +03:00
# , 5 , true , true , false , false ) ;
2019-03-14 15:06:03 +03:00
` ` `
* /
2020-06-25 12:06:04 +03:00
fn get_stored_tx (
& self ,
token : Token ,
id : Option < u32 > ,
slate_id : Option < Uuid > ,
) -> Result < Option < VersionedSlate > , ErrorKind > ;
2019-03-14 15:06:03 +03:00
/**
2019-11-06 13:04:42 +03:00
Networked version of [ Owner ::scan ] ( struct . Owner . html #method . scan ) .
2019-03-14 15:06:03 +03:00
` ` `
# grin_wallet_api ::doctest_helper_json_rpc_owner_assert_response! (
2019-03-22 15:03:25 +03:00
# r #"
2019-03-14 15:06:03 +03:00
{
" jsonrpc " : " 2.0 " ,
2019-11-06 13:04:42 +03:00
" method " : " scan " ,
2020-03-04 16:38:40 +03:00
" params " : {
" token " : " d202964900000000d302964900000000d402964900000000d502964900000000 " ,
" start_height " : 1 ,
" delete_unconfirmed " : false
} ,
2019-03-14 15:06:03 +03:00
" id " : 1
2019-03-22 15:03:25 +03:00
}
# " #
# ,
# r #"
2019-03-14 15:06:03 +03:00
{
2019-03-22 15:03:25 +03:00
" id " : 1 ,
2019-03-14 15:06:03 +03:00
" jsonrpc " : " 2.0 " ,
" result " : {
2019-03-22 15:03:25 +03:00
" Ok " : null
}
2019-03-14 15:06:03 +03:00
}
2019-03-22 15:03:25 +03:00
# " #
2020-03-04 16:38:40 +03:00
# , 1 , false , false , false , false ) ;
2019-03-14 15:06:03 +03:00
` ` `
* /
2020-03-04 16:38:40 +03:00
fn scan (
& self ,
token : Token ,
start_height : Option < u64 > ,
delete_unconfirmed : bool ,
) -> Result < ( ) , ErrorKind > ;
2019-03-14 15:06:03 +03:00
/**
Networked version of [ Owner ::node_height ] ( struct . Owner . html #method . node_height ) .
` ` `
# grin_wallet_api ::doctest_helper_json_rpc_owner_assert_response! (
2019-03-22 15:03:25 +03:00
# r #"
2019-03-14 15:06:03 +03:00
{
" jsonrpc " : " 2.0 " ,
" method " : " node_height " ,
2020-03-04 16:38:40 +03:00
" params " : {
" token " : " d202964900000000d302964900000000d402964900000000d502964900000000 "
} ,
2019-03-14 15:06:03 +03:00
" id " : 1
2019-03-22 15:03:25 +03:00
}
# " #
# ,
# r #"
2019-03-14 15:06:03 +03:00
{
2019-03-22 15:03:25 +03:00
" id " : 1 ,
2019-03-14 15:06:03 +03:00
" jsonrpc " : " 2.0 " ,
" result " : {
2019-03-29 19:00:02 +03:00
" Ok " : {
2019-11-05 00:10:05 +03:00
" header_hash " : " d4b3d3c40695afd8c7760f8fc423565f7d41310b7a4e1c4a4a7950a66f16240d " ,
2019-03-29 19:00:02 +03:00
" height " : " 5 " ,
" updated_from_node " : true
}
2019-03-22 15:03:25 +03:00
}
2019-03-14 15:06:03 +03:00
}
2019-03-22 15:03:25 +03:00
# " #
2020-03-04 16:38:40 +03:00
# , 5 , false , false , false , false ) ;
2019-03-14 15:06:03 +03:00
` ` `
* /
2020-03-04 16:38:40 +03:00
fn node_height ( & self , token : Token ) -> Result < NodeHeightResult , ErrorKind > ;
2019-03-14 15:06:03 +03:00
2020-03-04 16:38:40 +03:00
/**
Initializes the secure JSON - RPC API . This function must be called and a shared key
established before any other OwnerAPI JSON - RPC function can be called .
The shared key will be derived using ECDH with the provided public key on the secp256k1 curve . This
function will return its public key used in the derivation , which the caller should multiply by its
private key to derive the shared key .
Once the key is established , all further requests and responses are encrypted and decrypted with the
following parameters :
* AES - 256 in GCM mode with 128 - bit tags and 96 bit nonces
* 12 byte nonce which must be included in each request / response to use on the decrypting side
* Empty vector for additional data
* Suffix length = AES - 256 GCM mode tag length = 16 bytes
*
Fully - formed JSON - RPC requests ( as documented ) should be encrypted using these parameters , encoded
into base64 and included with the one - time nonce in a request for the ` encrypted_request_v3 ` method
as follows :
` ` `
# let s = r #"
{
" jsonrpc " : " 2.0 " ,
" method " : " encrypted_request_v3 " ,
" id " : " 1 " ,
" params " : {
" nonce " : " ef32... " ,
" body_enc " : " e0bcd... "
}
}
# " #;
` ` `
2019-03-14 15:06:03 +03:00
2020-03-04 16:38:40 +03:00
With a typical response being :
2019-03-14 15:06:03 +03:00
2020-03-04 16:38:40 +03:00
` ` `
# let s = r #" {
{
" jsonrpc " : " 2.0 " ,
" method " : " encrypted_response_v3 " ,
" id " : " 1 " ,
" Ok " : {
" nonce " : " 340b... " ,
" body_enc " : " 3f09c... "
}
}
# } " #;
` ` `
2019-03-14 15:06:03 +03:00
2020-03-04 16:38:40 +03:00
* /
2019-03-14 15:06:03 +03:00
2020-03-04 16:38:40 +03:00
fn init_secure_api ( & self , ecdh_pubkey : ECDHPubkey ) -> Result < ECDHPubkey , ErrorKind > ;
2019-03-14 15:06:03 +03:00
2020-03-04 16:38:40 +03:00
/**
Networked version of [ Owner ::get_top_level_directory ] ( struct . Owner . html #method . get_top_level_directory ) .
2019-03-14 15:06:03 +03:00
2020-03-04 16:38:40 +03:00
` ` `
# grin_wallet_api ::doctest_helper_json_rpc_owner_assert_response! (
# r #"
{
" jsonrpc " : " 2.0 " ,
" method " : " get_top_level_directory " ,
" params " : {
} ,
" id " : 1
2019-05-01 22:12:23 +03:00
}
2020-03-04 16:38:40 +03:00
# " #
# ,
# r #"
{
" id " : 1 ,
" jsonrpc " : " 2.0 " ,
" result " : {
" Ok " : " /doctest/dir "
}
2019-05-01 22:12:23 +03:00
}
2020-03-04 16:38:40 +03:00
# " #
# , 5 , false , false , false , false ) ;
` ` `
* /
2019-05-01 22:12:23 +03:00
2020-03-04 16:38:40 +03:00
fn get_top_level_directory ( & self ) -> Result < String , ErrorKind > ;
2019-03-14 15:06:03 +03:00
2020-03-04 16:38:40 +03:00
/**
Networked version of [ Owner ::set_top_level_directory ] ( struct . Owner . html #method . set_top_level_directory ) .
` ` `
# grin_wallet_api ::doctest_helper_json_rpc_owner_assert_response! (
# r #"
{
" jsonrpc " : " 2.0 " ,
" method " : " set_top_level_directory " ,
" params " : {
" dir " : " /home/wallet_user/my_wallet_dir "
} ,
" id " : 1
2019-03-14 15:06:03 +03:00
}
2020-03-04 16:38:40 +03:00
# " #
# ,
# r #"
{
" id " : 1 ,
" jsonrpc " : " 2.0 " ,
" result " : {
" Ok " : null
}
2019-03-14 18:05:13 +03:00
}
2020-03-04 16:38:40 +03:00
# " #
# , 5 , false , false , false , false ) ;
` ` `
* /
2019-03-14 18:05:13 +03:00
2020-03-04 16:38:40 +03:00
fn set_top_level_directory ( & self , dir : String ) -> Result < ( ) , ErrorKind > ;
2019-03-14 15:06:03 +03:00
2020-03-04 16:38:40 +03:00
/**
Networked version of [ Owner ::create_config ] ( struct . Owner . html #method . create_config ) .
2019-03-14 15:06:03 +03:00
2020-03-04 16:38:40 +03:00
Both the ` wallet_config ` and ` logging_config ` parameters can be ` null ` , the examples
below are for illustration . Note that the values provided for ` log_file_path ` and ` data_file_dir `
will be ignored and replaced with the actual values based on the value of ` get_top_level_directory `
` ` `
# grin_wallet_api ::doctest_helper_json_rpc_owner_assert_response! (
# r #"
{
" jsonrpc " : " 2.0 " ,
" method " : " create_config " ,
" params " : {
" chain_type " : " Mainnet " ,
" wallet_config " : {
" chain_type " : null ,
" api_listen_interface " : " 127.0.0.1 " ,
" api_listen_port " : 3415 ,
" owner_api_listen_port " : 3420 ,
" api_secret_path " : null ,
" node_api_secret_path " : null ,
" check_node_api_http_addr " : " http://127.0.0.1:3413 " ,
" owner_api_include_foreign " : false ,
" data_file_dir " : " /path/to/data/file/dir " ,
" no_commit_cache " : null ,
" tls_certificate_file " : null ,
" tls_certificate_key " : null ,
" dark_background_color_scheme " : null ,
" keybase_notify_ttl " : null
} ,
" logging_config " : {
" log_to_stdout " : false ,
" stdout_log_level " : " Info " ,
" log_to_file " : true ,
" file_log_level " : " Debug " ,
" log_file_path " : " /path/to/log/file " ,
" log_file_append " : true ,
" log_max_size " : null ,
" log_max_files " : null ,
" tui_running " : null
} ,
" tor_config " : {
" use_tor_listener " : true ,
" socks_proxy_addr " : " 127.0.0.1:9050 " ,
" send_config_dir " : " . "
}
} ,
" id " : 1
}
# " #
# ,
# r #"
{
" id " : 1 ,
" jsonrpc " : " 2.0 " ,
" result " : {
" Ok " : null
}
}
# " #
# , 5 , false , false , false , false ) ;
` ` `
* /
fn create_config (
& self ,
chain_type : global ::ChainTypes ,
wallet_config : Option < WalletConfig > ,
logging_config : Option < LoggingConfig > ,
tor_config : Option < TorConfig > ,
) -> Result < ( ) , ErrorKind > ;
/**
Networked version of [ Owner ::create_wallet ] ( struct . Owner . html #method . create_wallet ) .
` ` `
# grin_wallet_api ::doctest_helper_json_rpc_owner_assert_response! (
# r #"
{
" jsonrpc " : " 2.0 " ,
" method " : " create_wallet " ,
" params " : {
" name " : null ,
" mnemonic " : null ,
" mnemonic_length " : 32 ,
" password " : " my_secret_password "
} ,
" id " : 1
}
# " #
# ,
# r #"
{
" id " : 1 ,
" jsonrpc " : " 2.0 " ,
" result " : {
" Ok " : null
}
}
# " #
# , 0 , false , false , false , false ) ;
` ` `
* /
fn create_wallet (
& self ,
name : Option < String > ,
mnemonic : Option < String > ,
mnemonic_length : u32 ,
password : String ,
) -> Result < ( ) , ErrorKind > ;
/**
Networked version of [ Owner ::open_wallet ] ( struct . Owner . html #method . open_wallet ) .
` ` `
# grin_wallet_api ::doctest_helper_json_rpc_owner_assert_response! (
# r #"
{
" jsonrpc " : " 2.0 " ,
" method " : " open_wallet " ,
" params " : {
" name " : null ,
" password " : " my_secret_password "
} ,
" id " : 1
}
# " #
# ,
# r #"
{
" id " : 1 ,
" jsonrpc " : " 2.0 " ,
" result " : {
" Ok " : " d096b3cb75986b3b13f80b8f5243a9edf0af4c74ac37578c5a12cfb5b59b1868 "
}
}
# " #
# , 0 , false , false , false , false ) ;
` ` `
* /
fn open_wallet ( & self , name : Option < String > , password : String ) -> Result < Token , ErrorKind > ;
/**
Networked version of [ Owner ::close_wallet ] ( struct . Owner . html #method . close_wallet ) .
` ` `
# grin_wallet_api ::doctest_helper_json_rpc_owner_assert_response! (
# r #"
{
" jsonrpc " : " 2.0 " ,
" method " : " close_wallet " ,
" params " : {
" name " : null
} ,
" id " : 1
}
# " #
# ,
# r #"
{
" id " : 1 ,
" jsonrpc " : " 2.0 " ,
" result " : {
" Ok " : null
}
}
# " #
# , 0 , false , false , false , false ) ;
` ` `
* /
fn close_wallet ( & self , name : Option < String > ) -> Result < ( ) , ErrorKind > ;
/**
Networked version of [ Owner ::get_mnemonic ] ( struct . Owner . html #method . get_mnemonic ) .
` ` `
# grin_wallet_api ::doctest_helper_json_rpc_owner_assert_response! (
# r #"
{
" jsonrpc " : " 2.0 " ,
" method " : " get_mnemonic " ,
" params " : {
" name " : null ,
" password " : " "
} ,
" id " : 1
}
# " #
# ,
# r #"
{
" id " : 1 ,
" jsonrpc " : " 2.0 " ,
" result " : {
" Ok " : " fat twenty mean degree forget shell check candy immense awful flame next during february bulb bike sun wink theory day kiwi embrace peace lunch "
}
}
# " #
# , 0 , false , false , false , false ) ;
` ` `
* /
fn get_mnemonic ( & self , name : Option < String > , password : String ) -> Result < String , ErrorKind > ;
/**
Networked version of [ Owner ::change_password ] ( struct . Owner . html #method . change_password ) .
` ` `
# grin_wallet_api ::doctest_helper_json_rpc_owner_assert_response! (
# r #"
{
" jsonrpc " : " 2.0 " ,
" method " : " change_password " ,
" params " : {
" name " : null ,
" old " : " " ,
" new " : " new_password "
} ,
" id " : 1
}
# " #
# ,
# r #"
{
" id " : 1 ,
" jsonrpc " : " 2.0 " ,
" result " : {
" Ok " : null
}
}
# " #
# , 0 , false , false , false , false ) ;
` ` `
* /
fn change_password (
& self ,
name : Option < String > ,
old : String ,
new : String ,
) -> Result < ( ) , ErrorKind > ;
/**
Networked version of [ Owner ::delete_wallet ] ( struct . Owner . html #method . delete_wallet ) .
` ` `
# grin_wallet_api ::doctest_helper_json_rpc_owner_assert_response! (
# r #"
{
" jsonrpc " : " 2.0 " ,
" method " : " delete_wallet " ,
" params " : {
" name " : null
} ,
" id " : 1
}
# " #
# ,
# r #"
{
" id " : 1 ,
" jsonrpc " : " 2.0 " ,
" result " : {
" Ok " : null
}
}
# " #
# , 0 , false , false , false , false ) ;
` ` `
* /
fn delete_wallet ( & self , name : Option < String > ) -> Result < ( ) , ErrorKind > ;
/**
Networked version of [ Owner ::start_updated ] ( struct . Owner . html #method . start_updater ) .
` ` `
# grin_wallet_api ::doctest_helper_json_rpc_owner_assert_response! (
# r #"
{
" jsonrpc " : " 2.0 " ,
" method " : " start_updater " ,
" params " : {
" token " : " d202964900000000d302964900000000d402964900000000d502964900000000 " ,
" frequency " : 30000
} ,
" id " : 1
}
# " #
# ,
# r #"
{
" id " : 1 ,
" jsonrpc " : " 2.0 " ,
" result " : {
" Ok " : null
}
}
# " #
# , 0 , false , false , false , false ) ;
` ` `
* /
fn start_updater ( & self , token : Token , frequency : u32 ) -> Result < ( ) , ErrorKind > ;
/**
Networked version of [ Owner ::stop_updater ] ( struct . Owner . html #method . stop_updater ) .
` ` `
# grin_wallet_api ::doctest_helper_json_rpc_owner_assert_response! (
# r #"
{
" jsonrpc " : " 2.0 " ,
" method " : " stop_updater " ,
" params " : null ,
" id " : 1
}
# " #
# ,
# r #"
{
" id " : 1 ,
" jsonrpc " : " 2.0 " ,
" result " : {
" Ok " : null
}
}
# " #
# , 0 , false , false , false , false ) ;
` ` `
* /
fn stop_updater ( & self ) -> Result < ( ) , ErrorKind > ;
/**
Networked version of [ Owner ::get_updater_messages ] ( struct . Owner . html #method . get_updater_messages ) .
` ` `
# grin_wallet_api ::doctest_helper_json_rpc_owner_assert_response! (
# r #"
{
" jsonrpc " : " 2.0 " ,
" method " : " get_updater_messages " ,
" params " : {
" count " : 1
} ,
" id " : 1
}
# " #
# ,
# r #"
{
" id " : 1 ,
" jsonrpc " : " 2.0 " ,
" result " : {
" Ok " : [ ]
}
}
# " #
# , 0 , false , false , false , false ) ;
` ` `
* /
fn get_updater_messages ( & self , count : u32 ) -> Result < Vec < StatusMessage > , ErrorKind > ;
/**
2020-05-28 10:17:51 +03:00
Networked version of [ Owner ::get_slatepack_address ] ( struct . Owner . html #method . get_slatepack_address ) .
2020-03-04 16:38:40 +03:00
` ` `
# grin_wallet_api ::doctest_helper_json_rpc_owner_assert_response! (
# r #"
{
" jsonrpc " : " 2.0 " ,
2020-05-28 10:17:51 +03:00
" method " : " get_slatepack_address " ,
2020-03-04 16:38:40 +03:00
" params " : {
" token " : " d202964900000000d302964900000000d402964900000000d502964900000000 " ,
" derivation_index " : 0
} ,
" id " : 1
}
# " #
# ,
# r #"
{
" id " : 1 ,
" jsonrpc " : " 2.0 " ,
" result " : {
2020-06-12 12:40:07 +03:00
" Ok " : " tgrin1xtxavwfgs48ckf3gk8wwgcndmn0nt4tvkl8a7ltyejjcy2mc6nfs9gm2lp "
2020-03-04 16:38:40 +03:00
}
}
# " #
# , 0 , false , false , false , false ) ;
` ` `
* /
2020-05-28 10:17:51 +03:00
fn get_slatepack_address (
2020-03-04 16:38:40 +03:00
& self ,
token : Token ,
derivation_index : u32 ,
2020-05-28 10:17:51 +03:00
) -> Result < SlatepackAddress , ErrorKind > ;
2020-03-04 16:38:40 +03:00
/**
2020-05-28 10:17:51 +03:00
Networked version of [ Owner ::get_slatepack_secret_key ] ( struct . Owner . html #method . get_slatepack_secret_key ) .
2020-03-04 16:38:40 +03:00
` ` `
# grin_wallet_api ::doctest_helper_json_rpc_owner_assert_response! (
# r #"
{
" jsonrpc " : " 2.0 " ,
2020-05-28 10:17:51 +03:00
" method " : " get_slatepack_secret_key " ,
2020-03-04 16:38:40 +03:00
" params " : {
2020-05-28 10:17:51 +03:00
" token " : " d202964900000000d302964900000000d402964900000000d502964900000000 " ,
" derivation_index " : 0
} ,
" id " : 1
}
# " #
# ,
# r #"
{
" id " : 1 ,
" jsonrpc " : " 2.0 " ,
" result " : {
" Ok " : " 86cca2aedea7989dfcca62e54477301d098bac260656d11373e314c099f0b26f "
}
}
# " #
# , 0 , false , false , false , false ) ;
` ` `
* /
fn get_slatepack_secret_key (
& self ,
token : Token ,
derivation_index : u32 ,
) -> Result < Ed25519SecretKey , ErrorKind > ;
/**
Networked version of [ Owner ::create_slatepack_message ] ( struct . Owner . html #method . create_slatepack_message ) .
` ` `
# grin_wallet_api ::doctest_helper_json_rpc_owner_assert_response! (
# r #"
{
" jsonrpc " : " 2.0 " ,
" method " : " create_slatepack_message " ,
" params " : {
" token " : " d202964900000000d302964900000000d402964900000000d502964900000000 " ,
" sender_index " : 0 ,
" recipients " : [ ] ,
" slate " : {
2020-06-26 14:37:54 +03:00
" ver " : " 4:2 " ,
2020-05-28 10:17:51 +03:00
" id " : " 0436430c-2b02-624c-2032-570501212b00 " ,
2020-06-26 14:37:54 +03:00
" sta " : " S1 " ,
" off " : " d202964900000000d302964900000000d402964900000000d502964900000000 " ,
" amt " : " 60000000000 " ,
" fee " : " 7000000 " ,
2020-05-28 10:17:51 +03:00
" sigs " : [
{
2020-06-26 14:37:54 +03:00
" xs " : " 030152d2d72e2dba7c6086ad49a219d9ff0dfe0fd993dcaea22e058c210033ce93 " ,
" nonce " : " 031b84c5567b126440995d3ed5aaba0565d71e1834604819ff9c17f5e9d5dd078f "
2020-05-28 10:17:51 +03:00
}
2020-06-26 14:37:54 +03:00
]
2020-05-28 10:17:51 +03:00
}
} ,
" id " : 1
}
# " #
# ,
# r #"
{
" id " : 1 ,
" jsonrpc " : " 2.0 " ,
" result " : {
2020-06-26 14:37:54 +03:00
" Ok " : " BEGINSLATEPACK. xyfzdULuUuM5r3R kS68aywyCuYssPs Jf1JbvnBcK6NDDo ajiGAgh2SPx4t49 xtKuJE3BZCcSEue ksecMmbSoV2DQbX gGcmJniP9UadcmR N1KSc5FBhwAaUjy LXeYDP7EV7Cmsj4 pLaJdZTJTQbccUH 2zG8QTgoEiEWP5V T6rKst1TibmDAFm RRVHYDtskdYJb5G krqfpgN7RjvPfpm Z5ZFyz6ipAt5q9T 2HCjrTxkHdVi9js 22tr2Lx6iXT5vm8 JL6HhjwyFrSaEmN AjsBE8jgiaAABA6 GGZKwcXeXToMfRt nL9DeX1. ENDSLATEPACK. "
2020-05-28 10:17:51 +03:00
}
}
# " #
# , 0 , false , false , false , false ) ;
` ` `
* /
fn create_slatepack_message (
& self ,
token : Token ,
slate : VersionedSlate ,
sender_index : Option < u32 > ,
recipients : Vec < SlatepackAddress > ,
) -> Result < String , ErrorKind > ;
/**
Networked version of [ Owner ::slate_from_slatepack_message ] ( struct . Owner . html #method . slate_from_slatepack_message ) .
` ` `
# grin_wallet_api ::doctest_helper_json_rpc_owner_assert_response! (
# r #"
{
" jsonrpc " : " 2.0 " ,
" method " : " slate_from_slatepack_message " ,
" params " : {
" token " : " d202964900000000d302964900000000d402964900000000d502964900000000 " ,
" secret_indices " : [ 0 ] ,
2020-06-15 12:26:59 +03:00
" message " : " BEGINSLATEPACK. 8GQrdcwdLKJD28F 3a9siP7ZhZgAh7w BR2EiZHza5WMWmZ Cc8zBUemrrYRjhq j3VBwA8vYnvXXKU BDmQBN2yKgmR8mX UzvXHezfznA61d7 qFZYChhz94vd8Ew NEPLz7jmcVN2C3w wrfHbeiLubYozP2 uhLouFiYRrbe3fQ 4uhWGfT3sQYXScT dAeo29EaZJpfauh j8VL5jsxST2SPHq nzXFC2w9yYVjt7D ju7GSgHEp5aHz9R xstGbHjbsb4JQod kYLuELta1ohUwDD pvjhyJmsbLcsPei k5AQhZsJ8RJGBtY bou6cU7tZeFJvor 4LB9CBfFB3pmVWD vSLd5RPS75dcnHP nbXD8mSDZ8hJS2Q A9wgvppWzuWztJ2 dLUU8f9tLJgsRBw YZAs71HiVeg7. ENDSLATEPACK. "
2020-05-28 10:17:51 +03:00
} ,
" id " : 1
}
# " #
# ,
# r #"
{
" id " : 1 ,
" jsonrpc " : " 2.0 " ,
" result " : {
" Ok " : {
" amt " : " 6000000000 " ,
" fee " : " 8000000 " ,
" id " : " 0436430c-2b02-624c-2032-570501212b00 " ,
2020-06-26 14:37:54 +03:00
" off " : " d202964900000000d302964900000000d402964900000000d502964900000000 " ,
2020-05-28 10:17:51 +03:00
" proof " : {
2020-06-26 14:37:54 +03:00
" raddr " : " 783f6528669742a990e0faf0a5fca5d5b3330e37bbb9cd5c628696d03ce4e810 " ,
" saddr " : " 32cdd63928854f8b2628b1dce4626ddcdf35d56cb7cfdf7d64cca5822b78d4d3 "
2020-05-28 10:17:51 +03:00
} ,
" sigs " : [
{
2020-06-26 14:37:54 +03:00
" nonce " : " 031b84c5567b126440995d3ed5aaba0565d71e1834604819ff9c17f5e9d5dd078f " ,
" xs " : " 023878ce845727f3a4ec76ca3f3db4b38a2d05d636b8c3632108b857fed63c96de "
2020-05-28 10:17:51 +03:00
}
] ,
" sta " : " S1 " ,
" ver " : " 4:2 "
}
}
}
# " #
# , 0 , false , false , false , false ) ;
` ` `
* /
fn slate_from_slatepack_message (
& self ,
token : Token ,
message : String ,
secret_indices : Vec < u32 > ,
) -> Result < VersionedSlate , ErrorKind > ;
/**
Networked version of [ Owner ::decode_slatepack_message ] ( struct . Owner . html #method . decode_slatepack_message ) .
` ` `
# grin_wallet_api ::doctest_helper_json_rpc_owner_assert_response! (
# r #"
{
" jsonrpc " : " 2.0 " ,
" method " : " decode_slatepack_message " ,
" params " : {
2020-06-15 16:39:52 +03:00
" token " : " d202964900000000d302964900000000d402964900000000d502964900000000 " ,
" secret_indices " : [ 0 ] ,
" message " : " BEGINSLATEPACK. t9EcGgrKr1GFCQB SK2jPCxME6Hgpqx bntpQm3zKFycoPY nW4UeoL4KQ7ExNK At6EQsvpz6MjUs8 6WG8KHEbMfqufJQ ZJTw2gkcdJmJjiJ f29oGgYqqXDZox4 ujPSjrtoxCN4h3e i1sZ8dYsm3dPeXL 7VQLsYNjAefciqj ZJXPm4Pqd7VDdd4 okGBGBu3YJvYzT6 arAxeCEx66us31h AJLcDweFwyWBkW5 J1DLiYAjt5ftFTo CjpfW9KjiLq2LM5 jepXWEHJPSDAYVK 4macDZUhRbJiG6E hrQcPrJBVC716mb Hw5E1PFrE6on5wq oEmrS4j9vaB5nw8 Z9ZyXvPc2LN7tER yt6pSHZeY9EpYdY zv4bthzfRfF8ePT TMeMpV2gpgyRXQa CPD2TR. ENDSLATEPACK. \n "
2020-03-04 16:38:40 +03:00
} ,
" id " : 1
}
# " #
# ,
# r #"
{
" id " : 1 ,
" jsonrpc " : " 2.0 " ,
" result " : {
2020-05-28 10:17:51 +03:00
" Ok " : {
" mode " : 0 ,
" payload " : " AAQAAgQ2QwwrAmJMIDJXBQEhKwAB0gKWSQAAAADTApZJAAAAANQClkkAAAAA1QKWSQAAAAAGAAAAAWWgvAAAAAAAAHoSAAEAAjh4zoRXJ/Ok7HbKPz20s4otBdY2uMNjIQi4V/7WPJbeAxuExVZ7EmRAmV0+1aq6BWXXHhg0YEgZ/5wX9enV3QePAjLN1jkohU+LJiix3ORibdzfNdVst8/ffWTMpYIreNTTeD9lKGaXQqmQ4Prwpfyl1bMzDje7uc1cYoaW0Dzk6BAA " ,
2020-06-12 12:40:07 +03:00
" sender " : " tgrin1xtxavwfgs48ckf3gk8wwgcndmn0nt4tvkl8a7ltyejjcy2mc6nfs9gm2lp " ,
2020-05-28 10:17:51 +03:00
" slatepack " : " 1.0 "
}
2020-03-04 16:38:40 +03:00
}
}
# " #
# , 0 , false , false , false , false ) ;
` ` `
* /
2020-06-11 10:34:00 +03:00
fn decode_slatepack_message (
& self ,
2020-06-15 16:39:52 +03:00
token : Token ,
2020-06-11 10:34:00 +03:00
message : String ,
2020-06-15 16:39:52 +03:00
secret_indices : Vec < u32 > ,
2020-06-11 10:34:00 +03:00
) -> Result < Slatepack , ErrorKind > ;
2020-03-04 16:38:40 +03:00
/**
Networked version of [ Owner ::retrieve_payment_proof ] ( struct . Owner . html #method . retrieve_payment_proof ) .
` ` `
# grin_wallet_api ::doctest_helper_json_rpc_owner_assert_response! (
# r #"
{
" jsonrpc " : " 2.0 " ,
" method " : " retrieve_payment_proof " ,
" params " : {
" token " : " d202964900000000d302964900000000d402964900000000d502964900000000 " ,
" refresh_from_node " : true ,
" tx_id " : null ,
" tx_slate_id " : " 0436430c-2b02-624c-2032-570501212b00 "
} ,
" id " : 1
}
# " #
# ,
# r #"
{
" id " : 1 ,
" jsonrpc " : " 2.0 " ,
" result " : {
" Ok " : {
" amount " : " 60000000000 " ,
2020-05-19 13:19:03 +03:00
" excess " : " 091f151170bfac881479bfb56c7012c52cd4ce4198ad661586374dd499925922fb " ,
2020-06-12 12:40:07 +03:00
" recipient_address " : " tgrin10qlk22rxjap2ny8qltc2tl996kenxr3hhwuu6hrzs6tdq08yaqgqq6t83r " ,
2020-05-19 13:19:03 +03:00
" recipient_sig " : " b9b1885a3f33297df32e1aa4db23220bd305da8ed92ff6873faf3ab2c116fea25e9d0e34bd4f567f022b88a37400821ffbcaec71c9a8c3a327c4626611886d0d " ,
2020-06-12 12:40:07 +03:00
" sender_address " : " tgrin1xtxavwfgs48ckf3gk8wwgcndmn0nt4tvkl8a7ltyejjcy2mc6nfs9gm2lp " ,
2020-05-19 13:19:03 +03:00
" sender_sig " : " 611b92331e395c3d29871ac35b1fce78ec595e28ccbe8cc55452da40775e8e46d35a2e84eaffd986935da3275e34d46a8d777d02dabcf4339704c2a621da9700 "
2020-03-04 16:38:40 +03:00
}
}
}
# " #
# , 5 , true , true , true , true ) ;
` ` `
* /
fn retrieve_payment_proof (
& self ,
token : Token ,
refresh_from_node : bool ,
tx_id : Option < u32 > ,
tx_slate_id : Option < Uuid > ,
) -> Result < PaymentProof , ErrorKind > ;
/**
Networked version of [ Owner ::verify_payment_proof ] ( struct . Owner . html #method . verify_payment_proof ) .
` ` `
# grin_wallet_api ::doctest_helper_json_rpc_owner_assert_response! (
# r #"
{
" jsonrpc " : " 2.0 " ,
" method " : " verify_payment_proof " ,
" params " : {
" token " : " d202964900000000d302964900000000d402964900000000d502964900000000 " ,
" proof " : {
" amount " : " 60000000000 " ,
2020-05-19 13:19:03 +03:00
" excess " : " 091f151170bfac881479bfb56c7012c52cd4ce4198ad661586374dd499925922fb " ,
2020-05-28 10:17:51 +03:00
" recipient_address " : " slatepack10qlk22rxjap2ny8qltc2tl996kenxr3hhwuu6hrzs6tdq08yaqgqnlumr7 " ,
2020-05-19 13:19:03 +03:00
" recipient_sig " : " b9b1885a3f33297df32e1aa4db23220bd305da8ed92ff6873faf3ab2c116fea25e9d0e34bd4f567f022b88a37400821ffbcaec71c9a8c3a327c4626611886d0d " ,
2020-05-28 10:17:51 +03:00
" sender_address " : " slatepack1xtxavwfgs48ckf3gk8wwgcndmn0nt4tvkl8a7ltyejjcy2mc6nfskdvkdu " ,
2020-05-19 13:19:03 +03:00
" sender_sig " : " 611b92331e395c3d29871ac35b1fce78ec595e28ccbe8cc55452da40775e8e46d35a2e84eaffd986935da3275e34d46a8d777d02dabcf4339704c2a621da9700 "
2020-03-04 16:38:40 +03:00
}
} ,
" id " : 1
}
# " #
# ,
# r #"
{
" id " : 1 ,
" jsonrpc " : " 2.0 " ,
" result " : {
" Ok " : [
true ,
false
]
}
}
# " #
# , 5 , true , true , true , true ) ;
` ` `
* /
fn verify_payment_proof (
& self ,
token : Token ,
proof : PaymentProof ,
) -> Result < ( bool , bool ) , ErrorKind > ;
/**
Networked version of [ Owner ::set_tor_config ] ( struct . Owner . html #method . set_tor_config ) .
` ` `
# grin_wallet_api ::doctest_helper_json_rpc_owner_assert_response! (
# r #"
{
" jsonrpc " : " 2.0 " ,
" method " : " set_tor_config " ,
" params " : {
" tor_config " : {
" use_tor_listener " : true ,
" socks_proxy_addr " : " 127.0.0.1:59050 " ,
" send_config_dir " : " . "
}
} ,
" id " : 1
}
# " #
# ,
# r #"
{
" id " : 1 ,
" jsonrpc " : " 2.0 " ,
" result " : {
" Ok " : null
}
}
# " #
# , 0 , false , false , false , false ) ;
` ` `
* /
fn set_tor_config ( & self , tor_config : Option < TorConfig > ) -> Result < ( ) , ErrorKind > ;
}
impl < L , C , K > OwnerRpc for Owner < L , C , K >
where
L : WalletLCProvider < 'static , C , K > ,
C : NodeClient + 'static ,
K : Keychain + 'static ,
{
fn accounts ( & self , token : Token ) -> Result < Vec < AcctPathMapping > , ErrorKind > {
Owner ::accounts ( self , ( & token . keychain_mask ) . as_ref ( ) ) . map_err ( | e | e . kind ( ) )
}
fn create_account_path ( & self , token : Token , label : & String ) -> Result < Identifier , ErrorKind > {
Owner ::create_account_path ( self , ( & token . keychain_mask ) . as_ref ( ) , label )
. map_err ( | e | e . kind ( ) )
}
fn set_active_account ( & self , token : Token , label : & String ) -> Result < ( ) , ErrorKind > {
Owner ::set_active_account ( self , ( & token . keychain_mask ) . as_ref ( ) , label )
. map_err ( | e | e . kind ( ) )
}
fn retrieve_outputs (
& self ,
token : Token ,
include_spent : bool ,
refresh_from_node : bool ,
tx_id : Option < u32 > ,
) -> Result < ( bool , Vec < OutputCommitMapping > ) , ErrorKind > {
Owner ::retrieve_outputs (
self ,
( & token . keychain_mask ) . as_ref ( ) ,
include_spent ,
refresh_from_node ,
tx_id ,
)
. map_err ( | e | e . kind ( ) )
}
fn retrieve_txs (
& self ,
token : Token ,
refresh_from_node : bool ,
tx_id : Option < u32 > ,
tx_slate_id : Option < Uuid > ,
) -> Result < ( bool , Vec < TxLogEntry > ) , ErrorKind > {
Owner ::retrieve_txs (
self ,
( & token . keychain_mask ) . as_ref ( ) ,
refresh_from_node ,
tx_id ,
tx_slate_id ,
)
. map_err ( | e | e . kind ( ) )
}
fn retrieve_summary_info (
& self ,
token : Token ,
refresh_from_node : bool ,
minimum_confirmations : u64 ,
) -> Result < ( bool , WalletInfo ) , ErrorKind > {
Owner ::retrieve_summary_info (
self ,
( & token . keychain_mask ) . as_ref ( ) ,
refresh_from_node ,
minimum_confirmations ,
)
. map_err ( | e | e . kind ( ) )
}
fn init_send_tx ( & self , token : Token , args : InitTxArgs ) -> Result < VersionedSlate , ErrorKind > {
let slate = Owner ::init_send_tx ( self , ( & token . keychain_mask ) . as_ref ( ) , args )
. map_err ( | e | e . kind ( ) ) ? ;
2020-03-06 12:33:47 +03:00
let version = SlateVersion ::V4 ;
2020-03-10 21:19:27 +03:00
Ok ( VersionedSlate ::into_version ( slate , version ) . map_err ( | e | e . kind ( ) ) ? )
2020-03-04 16:38:40 +03:00
}
fn issue_invoice_tx (
& self ,
token : Token ,
args : IssueInvoiceTxArgs ,
) -> Result < VersionedSlate , ErrorKind > {
let slate = Owner ::issue_invoice_tx ( self , ( & token . keychain_mask ) . as_ref ( ) , args )
. map_err ( | e | e . kind ( ) ) ? ;
2020-03-06 12:33:47 +03:00
let version = SlateVersion ::V4 ;
2020-03-10 21:19:27 +03:00
Ok ( VersionedSlate ::into_version ( slate , version ) . map_err ( | e | e . kind ( ) ) ? )
2020-03-04 16:38:40 +03:00
}
fn process_invoice_tx (
& self ,
token : Token ,
in_slate : VersionedSlate ,
args : InitTxArgs ,
) -> Result < VersionedSlate , ErrorKind > {
let out_slate = Owner ::process_invoice_tx (
self ,
( & token . keychain_mask ) . as_ref ( ) ,
& Slate ::from ( in_slate ) ,
args ,
)
. map_err ( | e | e . kind ( ) ) ? ;
2020-03-06 12:33:47 +03:00
let version = SlateVersion ::V4 ;
2020-03-10 21:19:27 +03:00
Ok ( VersionedSlate ::into_version ( out_slate , version ) . map_err ( | e | e . kind ( ) ) ? )
2020-03-04 16:38:40 +03:00
}
fn finalize_tx (
& self ,
token : Token ,
in_slate : VersionedSlate ,
) -> Result < VersionedSlate , ErrorKind > {
let out_slate = Owner ::finalize_tx (
self ,
( & token . keychain_mask ) . as_ref ( ) ,
& Slate ::from ( in_slate ) ,
)
. map_err ( | e | e . kind ( ) ) ? ;
2020-03-06 12:33:47 +03:00
let version = SlateVersion ::V4 ;
2020-03-10 21:19:27 +03:00
Ok ( VersionedSlate ::into_version ( out_slate , version ) . map_err ( | e | e . kind ( ) ) ? )
2020-03-04 16:38:40 +03:00
}
2020-05-19 13:19:03 +03:00
fn tx_lock_outputs ( & self , token : Token , in_slate : VersionedSlate ) -> Result < ( ) , ErrorKind > {
2020-03-04 16:38:40 +03:00
Owner ::tx_lock_outputs (
self ,
( & token . keychain_mask ) . as_ref ( ) ,
& Slate ::from ( in_slate ) ,
)
. map_err ( | e | e . kind ( ) )
}
fn cancel_tx (
& self ,
token : Token ,
tx_id : Option < u32 > ,
tx_slate_id : Option < Uuid > ,
) -> Result < ( ) , ErrorKind > {
Owner ::cancel_tx ( self , ( & token . keychain_mask ) . as_ref ( ) , tx_id , tx_slate_id )
. map_err ( | e | e . kind ( ) )
}
2020-06-25 12:06:04 +03:00
fn get_stored_tx (
& self ,
token : Token ,
id : Option < u32 > ,
slate_id : Option < Uuid > ,
) -> Result < Option < VersionedSlate > , ErrorKind > {
let out_slate = Owner ::get_stored_tx (
self ,
( & token . keychain_mask ) . as_ref ( ) ,
id ,
( & slate_id ) . as_ref ( ) ,
)
. map_err ( | e | e . kind ( ) ) ? ;
match out_slate {
Some ( s ) = > {
let version = SlateVersion ::V4 ;
Ok ( Some (
VersionedSlate ::into_version ( s , version ) . map_err ( | e | e . kind ( ) ) ? ,
) )
}
None = > Ok ( None ) ,
}
2020-03-04 16:38:40 +03:00
}
2020-05-19 13:19:03 +03:00
fn post_tx ( & self , token : Token , slate : VersionedSlate , fluff : bool ) -> Result < ( ) , ErrorKind > {
2020-03-04 16:38:40 +03:00
Owner ::post_tx (
self ,
( & token . keychain_mask ) . as_ref ( ) ,
2020-05-19 13:19:03 +03:00
& Slate ::from ( slate ) ,
2020-03-04 16:38:40 +03:00
fluff ,
)
. map_err ( | e | e . kind ( ) )
}
fn scan (
& self ,
token : Token ,
start_height : Option < u64 > ,
delete_unconfirmed : bool ,
) -> Result < ( ) , ErrorKind > {
Owner ::scan (
self ,
( & token . keychain_mask ) . as_ref ( ) ,
start_height ,
delete_unconfirmed ,
)
. map_err ( | e | e . kind ( ) )
}
fn node_height ( & self , token : Token ) -> Result < NodeHeightResult , ErrorKind > {
Owner ::node_height ( self , ( & token . keychain_mask ) . as_ref ( ) ) . map_err ( | e | e . kind ( ) )
}
fn init_secure_api ( & self , ecdh_pubkey : ECDHPubkey ) -> Result < ECDHPubkey , ErrorKind > {
let secp_inst = static_secp_instance ( ) ;
let secp = secp_inst . lock ( ) ;
let sec_key = SecretKey ::new ( & secp , & mut thread_rng ( ) ) ;
let mut shared_pubkey = ecdh_pubkey . ecdh_pubkey ;
shared_pubkey
. mul_assign ( & secp , & sec_key )
. map_err ( ErrorKind ::Secp ) ? ;
let x_coord = shared_pubkey . serialize_vec ( & secp , true ) ;
let shared_key = SecretKey ::from_slice ( & secp , & x_coord [ 1 .. ] ) . map_err ( ErrorKind ::Secp ) ? ;
{
let mut s = self . shared_key . lock ( ) ;
* s = Some ( shared_key ) ;
}
let pub_key = PublicKey ::from_secret_key ( & secp , & sec_key ) . map_err ( ErrorKind ::Secp ) ? ;
Ok ( ECDHPubkey {
ecdh_pubkey : pub_key ,
} )
}
fn get_top_level_directory ( & self ) -> Result < String , ErrorKind > {
Owner ::get_top_level_directory ( self ) . map_err ( | e | e . kind ( ) )
}
fn set_top_level_directory ( & self , dir : String ) -> Result < ( ) , ErrorKind > {
Owner ::set_top_level_directory ( self , & dir ) . map_err ( | e | e . kind ( ) )
}
fn create_config (
& self ,
chain_type : global ::ChainTypes ,
wallet_config : Option < WalletConfig > ,
logging_config : Option < LoggingConfig > ,
tor_config : Option < TorConfig > ,
) -> Result < ( ) , ErrorKind > {
Owner ::create_config ( self , & chain_type , wallet_config , logging_config , tor_config )
. map_err ( | e | e . kind ( ) )
}
fn create_wallet (
& self ,
name : Option < String > ,
mnemonic : Option < String > ,
mnemonic_length : u32 ,
password : String ,
) -> Result < ( ) , ErrorKind > {
let n = name . as_ref ( ) . map ( | s | s . as_str ( ) ) ;
let m = match mnemonic {
Some ( s ) = > Some ( ZeroingString ::from ( s ) ) ,
None = > None ,
} ;
Owner ::create_wallet ( self , n , m , mnemonic_length , ZeroingString ::from ( password ) )
. map_err ( | e | e . kind ( ) )
}
fn open_wallet ( & self , name : Option < String > , password : String ) -> Result < Token , ErrorKind > {
let n = name . as_ref ( ) . map ( | s | s . as_str ( ) ) ;
let sec_key = Owner ::open_wallet ( self , n , ZeroingString ::from ( password ) , true )
. map_err ( | e | e . kind ( ) ) ? ;
Ok ( Token {
keychain_mask : sec_key ,
} )
}
2019-03-14 15:06:03 +03:00
2020-03-04 16:38:40 +03:00
fn close_wallet ( & self , name : Option < String > ) -> Result < ( ) , ErrorKind > {
let n = name . as_ref ( ) . map ( | s | s . as_str ( ) ) ;
Owner ::close_wallet ( self , n ) . map_err ( | e | e . kind ( ) )
2019-03-14 15:06:03 +03:00
}
2020-03-04 16:38:40 +03:00
fn get_mnemonic ( & self , name : Option < String > , password : String ) -> Result < String , ErrorKind > {
let n = name . as_ref ( ) . map ( | s | s . as_str ( ) ) ;
let res =
Owner ::get_mnemonic ( self , n , ZeroingString ::from ( password ) ) . map_err ( | e | e . kind ( ) ) ? ;
Ok ( ( & * res ) . to_string ( ) )
2019-03-14 15:06:03 +03:00
}
2020-03-04 16:38:40 +03:00
fn change_password (
& self ,
name : Option < String > ,
old : String ,
new : String ,
) -> Result < ( ) , ErrorKind > {
let n = name . as_ref ( ) . map ( | s | s . as_str ( ) ) ;
Owner ::change_password ( self , n , ZeroingString ::from ( old ) , ZeroingString ::from ( new ) )
. map_err ( | e | e . kind ( ) )
}
fn delete_wallet ( & self , name : Option < String > ) -> Result < ( ) , ErrorKind > {
let n = name . as_ref ( ) . map ( | s | s . as_str ( ) ) ;
Owner ::delete_wallet ( self , n ) . map_err ( | e | e . kind ( ) )
}
fn start_updater ( & self , token : Token , frequency : u32 ) -> Result < ( ) , ErrorKind > {
Owner ::start_updater (
self ,
( & token . keychain_mask ) . as_ref ( ) ,
Duration ::from_millis ( frequency as u64 ) ,
)
. map_err ( | e | e . kind ( ) )
}
fn stop_updater ( & self ) -> Result < ( ) , ErrorKind > {
Owner ::stop_updater ( self ) . map_err ( | e | e . kind ( ) )
}
fn get_updater_messages ( & self , count : u32 ) -> Result < Vec < StatusMessage > , ErrorKind > {
Owner ::get_updater_messages ( self , count as usize ) . map_err ( | e | e . kind ( ) )
}
2020-05-28 10:17:51 +03:00
fn get_slatepack_address (
2020-03-04 16:38:40 +03:00
& self ,
token : Token ,
derivation_index : u32 ,
2020-05-28 10:17:51 +03:00
) -> Result < SlatepackAddress , ErrorKind > {
Owner ::get_slatepack_address ( self , ( & token . keychain_mask ) . as_ref ( ) , derivation_index )
. map_err ( | e | e . kind ( ) )
}
fn get_slatepack_secret_key (
& self ,
token : Token ,
derivation_index : u32 ,
) -> Result < Ed25519SecretKey , ErrorKind > {
let key = Owner ::get_slatepack_secret_key (
2020-03-04 16:38:40 +03:00
self ,
( & token . keychain_mask ) . as_ref ( ) ,
derivation_index ,
)
. map_err ( | e | e . kind ( ) ) ? ;
2020-05-28 10:17:51 +03:00
Ok ( Ed25519SecretKey { key } )
}
fn create_slatepack_message (
& self ,
token : Token ,
slate : VersionedSlate ,
sender_index : Option < u32 > ,
recipients : Vec < SlatepackAddress > ,
) -> Result < String , ErrorKind > {
2020-06-15 12:26:59 +03:00
let res = Owner ::create_slatepack_message (
2020-05-28 10:17:51 +03:00
self ,
( & token . keychain_mask ) . as_ref ( ) ,
& Slate ::from ( slate ) ,
sender_index ,
recipients ,
)
2020-06-15 12:26:59 +03:00
. map_err ( | e | e . kind ( ) ) ? ;
Ok ( res . trim ( ) . into ( ) )
2020-05-28 10:17:51 +03:00
}
fn slate_from_slatepack_message (
& self ,
token : Token ,
message : String ,
secret_indices : Vec < u32 > ,
) -> Result < VersionedSlate , ErrorKind > {
let slate = Owner ::slate_from_slatepack_message (
self ,
( & token . keychain_mask ) . as_ref ( ) ,
message ,
secret_indices ,
)
. map_err ( | e | e . kind ( ) ) ? ;
let version = SlateVersion ::V4 ;
Ok ( VersionedSlate ::into_version ( slate , version ) . map_err ( | e | e . kind ( ) ) ? )
}
2020-06-11 10:34:00 +03:00
fn decode_slatepack_message (
& self ,
2020-06-15 16:39:52 +03:00
token : Token ,
2020-06-11 10:34:00 +03:00
message : String ,
2020-06-15 16:39:52 +03:00
secret_indices : Vec < u32 > ,
2020-06-11 10:34:00 +03:00
) -> Result < Slatepack , ErrorKind > {
2020-06-15 16:39:52 +03:00
Owner ::decode_slatepack_message (
self ,
( & token . keychain_mask ) . as_ref ( ) ,
message ,
secret_indices ,
)
. map_err ( | e | e . kind ( ) )
2020-03-04 16:38:40 +03:00
}
fn retrieve_payment_proof (
& self ,
token : Token ,
refresh_from_node : bool ,
tx_id : Option < u32 > ,
tx_slate_id : Option < Uuid > ,
) -> Result < PaymentProof , ErrorKind > {
Owner ::retrieve_payment_proof (
self ,
( & token . keychain_mask ) . as_ref ( ) ,
refresh_from_node ,
tx_id ,
tx_slate_id ,
)
. map_err ( | e | e . kind ( ) )
}
fn verify_payment_proof (
& self ,
token : Token ,
proof : PaymentProof ,
) -> Result < ( bool , bool ) , ErrorKind > {
Owner ::verify_payment_proof ( self , ( & token . keychain_mask ) . as_ref ( ) , & proof )
. map_err ( | e | e . kind ( ) )
}
fn set_tor_config ( & self , tor_config : Option < TorConfig > ) -> Result < ( ) , ErrorKind > {
Owner ::set_tor_config ( self , tor_config ) ;
Ok ( ( ) )
2019-03-14 15:06:03 +03:00
}
}
2019-03-22 15:03:25 +03:00
/// helper to set up a real environment to run integrated doctests
2019-03-26 19:02:31 +03:00
pub fn run_doctest_owner (
2019-03-22 15:03:25 +03:00
request : serde_json ::Value ,
test_dir : & str ,
blocks_to_mine : u64 ,
perform_tx : bool ,
lock_tx : bool ,
finalize_tx : bool ,
2020-01-22 16:16:24 +03:00
payment_proof : bool ,
2019-03-22 15:03:25 +03:00
) -> Result < Option < serde_json ::Value > , String > {
2019-08-19 15:05:21 +03:00
use easy_jsonrpc_mw ::Handler ;
2019-03-22 15:03:25 +03:00
use grin_wallet_impls ::test_framework ::{ self , LocalWalletClient , WalletProxy } ;
Merge milestone/2.1.0 into master (#199)
* version bump for next potential release
* Merge master into milestone/2.1.0 (#182)
* Derive --version output dynamically from cargo package version (#174)
* add --txid to the `wallet txs` command (#176)
* add --txid to the `wallet txs` command
* add test for `wallet txs` command with `--txid` parameter
* Refactor - Split WalletCommAdapter into multiple traits (#180)
* Derive --version output dynamically from cargo package version (#174)
* add server auth argument to http client
* Revert "add server auth argument to http client"
This reverts commit f52a8d2c7cdfb8583af5716ad621eb560811d6ee.
* modify WalletCommAdapter, moving dest argument into fields on implementors,
visiting havok on automated tests, at least one of which is now out of date and failing
* Split WalletCommAdapter into four traits, one for each of its intended behaviors.
* Remove two vestigals
1. args, a stringly typed argument to put_tx
2. NullAdapter, which is no longer used
* Remove unused "params" argument from listen method.
* Re-add previously existing TODO comment
* Fix non-test build
* completely Fix non-test build
* Full Lifecycle API Support (#184)
* refactoring wallet lib traits
* rustfmt
* rustfmt
* add new files
* explicit lifetime specifiers on all wallet traits
* rustfmt
* modify apis to use new walletinst
* rustfmt
* converting controller crate
* rustfmt
* controller crate compiling
* rustfmt
* compilation
* rustfmt
* Remove config from wallet, implement open_wallet, close_wallet in lifecycle provider, remove password + open_with_credentials from WalletBackend + impl
* rustfmt
* full compilation, changing recovery + init to new model
* rustfmt
* wallet initialisation working, init command output and flow identical to v2.0.0 wallet
* rustfmt
* fix listener and owner api startup
* rustfmt
* rustfmt
* move encryption test
* rustfmt
* fix api doctests
* rustfmt
* fix for most tests in controller crate
* rustfmt
* fix for check tests in controller crate
* fix main wallet tests
* rustfmt
* add explicit functions to handle mnemonic recovery, fix CLI recovery workflow
* rustfmt
* update keybase adapter to use new wallet format
* rustfmt
* test fix
* remove debug output
2019-07-29 15:25:03 +03:00
use grin_wallet_impls ::{ DefaultLCProvider , DefaultWalletImpl } ;
use grin_wallet_libwallet ::{ api_impl , WalletInst } ;
2019-03-26 19:02:31 +03:00
use grin_wallet_util ::grin_keychain ::ExtKeychain ;
2019-03-22 15:03:25 +03:00
use crate ::core ::global ::ChainTypes ;
2019-03-26 19:02:31 +03:00
use grin_wallet_util ::grin_util as util ;
2019-03-22 15:03:25 +03:00
2020-03-04 16:38:40 +03:00
use std ::{ fs , thread } ;
2019-03-22 15:03:25 +03:00
util ::init_test_logger ( ) ;
let _ = fs ::remove_dir_all ( test_dir ) ;
2020-05-18 15:04:09 +03:00
global ::set_local_chain_type ( ChainTypes ::AutomatedTesting ) ;
2019-03-22 15:03:25 +03:00
Merge milestone/2.1.0 into master (#199)
* version bump for next potential release
* Merge master into milestone/2.1.0 (#182)
* Derive --version output dynamically from cargo package version (#174)
* add --txid to the `wallet txs` command (#176)
* add --txid to the `wallet txs` command
* add test for `wallet txs` command with `--txid` parameter
* Refactor - Split WalletCommAdapter into multiple traits (#180)
* Derive --version output dynamically from cargo package version (#174)
* add server auth argument to http client
* Revert "add server auth argument to http client"
This reverts commit f52a8d2c7cdfb8583af5716ad621eb560811d6ee.
* modify WalletCommAdapter, moving dest argument into fields on implementors,
visiting havok on automated tests, at least one of which is now out of date and failing
* Split WalletCommAdapter into four traits, one for each of its intended behaviors.
* Remove two vestigals
1. args, a stringly typed argument to put_tx
2. NullAdapter, which is no longer used
* Remove unused "params" argument from listen method.
* Re-add previously existing TODO comment
* Fix non-test build
* completely Fix non-test build
* Full Lifecycle API Support (#184)
* refactoring wallet lib traits
* rustfmt
* rustfmt
* add new files
* explicit lifetime specifiers on all wallet traits
* rustfmt
* modify apis to use new walletinst
* rustfmt
* converting controller crate
* rustfmt
* controller crate compiling
* rustfmt
* compilation
* rustfmt
* Remove config from wallet, implement open_wallet, close_wallet in lifecycle provider, remove password + open_with_credentials from WalletBackend + impl
* rustfmt
* full compilation, changing recovery + init to new model
* rustfmt
* wallet initialisation working, init command output and flow identical to v2.0.0 wallet
* rustfmt
* fix listener and owner api startup
* rustfmt
* rustfmt
* move encryption test
* rustfmt
* fix api doctests
* rustfmt
* fix for most tests in controller crate
* rustfmt
* fix for check tests in controller crate
* fix main wallet tests
* rustfmt
* add explicit functions to handle mnemonic recovery, fix CLI recovery workflow
* rustfmt
* update keybase adapter to use new wallet format
* rustfmt
* test fix
* remove debug output
2019-07-29 15:25:03 +03:00
let mut wallet_proxy : WalletProxy <
DefaultLCProvider < LocalWalletClient , ExtKeychain > ,
LocalWalletClient ,
ExtKeychain ,
> = WalletProxy ::new ( test_dir ) ;
2019-03-22 15:03:25 +03:00
let chain = wallet_proxy . chain . clone ( ) ;
Merge milestone/2.1.0 into master (#199)
* version bump for next potential release
* Merge master into milestone/2.1.0 (#182)
* Derive --version output dynamically from cargo package version (#174)
* add --txid to the `wallet txs` command (#176)
* add --txid to the `wallet txs` command
* add test for `wallet txs` command with `--txid` parameter
* Refactor - Split WalletCommAdapter into multiple traits (#180)
* Derive --version output dynamically from cargo package version (#174)
* add server auth argument to http client
* Revert "add server auth argument to http client"
This reverts commit f52a8d2c7cdfb8583af5716ad621eb560811d6ee.
* modify WalletCommAdapter, moving dest argument into fields on implementors,
visiting havok on automated tests, at least one of which is now out of date and failing
* Split WalletCommAdapter into four traits, one for each of its intended behaviors.
* Remove two vestigals
1. args, a stringly typed argument to put_tx
2. NullAdapter, which is no longer used
* Remove unused "params" argument from listen method.
* Re-add previously existing TODO comment
* Fix non-test build
* completely Fix non-test build
* Full Lifecycle API Support (#184)
* refactoring wallet lib traits
* rustfmt
* rustfmt
* add new files
* explicit lifetime specifiers on all wallet traits
* rustfmt
* modify apis to use new walletinst
* rustfmt
* converting controller crate
* rustfmt
* controller crate compiling
* rustfmt
* compilation
* rustfmt
* Remove config from wallet, implement open_wallet, close_wallet in lifecycle provider, remove password + open_with_credentials from WalletBackend + impl
* rustfmt
* full compilation, changing recovery + init to new model
* rustfmt
* wallet initialisation working, init command output and flow identical to v2.0.0 wallet
* rustfmt
* fix listener and owner api startup
* rustfmt
* rustfmt
* move encryption test
* rustfmt
* fix api doctests
* rustfmt
* fix for most tests in controller crate
* rustfmt
* fix for check tests in controller crate
* fix main wallet tests
* rustfmt
* add explicit functions to handle mnemonic recovery, fix CLI recovery workflow
* rustfmt
* update keybase adapter to use new wallet format
* rustfmt
* test fix
* remove debug output
2019-07-29 15:25:03 +03:00
let rec_phrase_1 = util ::ZeroingString ::from (
2019-03-22 15:03:25 +03:00
" fat twenty mean degree forget shell check candy immense awful \
Merge milestone/2.1.0 into master (#199)
* version bump for next potential release
* Merge master into milestone/2.1.0 (#182)
* Derive --version output dynamically from cargo package version (#174)
* add --txid to the `wallet txs` command (#176)
* add --txid to the `wallet txs` command
* add test for `wallet txs` command with `--txid` parameter
* Refactor - Split WalletCommAdapter into multiple traits (#180)
* Derive --version output dynamically from cargo package version (#174)
* add server auth argument to http client
* Revert "add server auth argument to http client"
This reverts commit f52a8d2c7cdfb8583af5716ad621eb560811d6ee.
* modify WalletCommAdapter, moving dest argument into fields on implementors,
visiting havok on automated tests, at least one of which is now out of date and failing
* Split WalletCommAdapter into four traits, one for each of its intended behaviors.
* Remove two vestigals
1. args, a stringly typed argument to put_tx
2. NullAdapter, which is no longer used
* Remove unused "params" argument from listen method.
* Re-add previously existing TODO comment
* Fix non-test build
* completely Fix non-test build
* Full Lifecycle API Support (#184)
* refactoring wallet lib traits
* rustfmt
* rustfmt
* add new files
* explicit lifetime specifiers on all wallet traits
* rustfmt
* modify apis to use new walletinst
* rustfmt
* converting controller crate
* rustfmt
* controller crate compiling
* rustfmt
* compilation
* rustfmt
* Remove config from wallet, implement open_wallet, close_wallet in lifecycle provider, remove password + open_with_credentials from WalletBackend + impl
* rustfmt
* full compilation, changing recovery + init to new model
* rustfmt
* wallet initialisation working, init command output and flow identical to v2.0.0 wallet
* rustfmt
* fix listener and owner api startup
* rustfmt
* rustfmt
* move encryption test
* rustfmt
* fix api doctests
* rustfmt
* fix for most tests in controller crate
* rustfmt
* fix for check tests in controller crate
* fix main wallet tests
* rustfmt
* add explicit functions to handle mnemonic recovery, fix CLI recovery workflow
* rustfmt
* update keybase adapter to use new wallet format
* rustfmt
* test fix
* remove debug output
2019-07-29 15:25:03 +03:00
flame next during february bulb bike sun wink theory day kiwi embrace peace lunch " ,
2019-03-22 15:03:25 +03:00
) ;
Merge milestone/2.1.0 into master (#199)
* version bump for next potential release
* Merge master into milestone/2.1.0 (#182)
* Derive --version output dynamically from cargo package version (#174)
* add --txid to the `wallet txs` command (#176)
* add --txid to the `wallet txs` command
* add test for `wallet txs` command with `--txid` parameter
* Refactor - Split WalletCommAdapter into multiple traits (#180)
* Derive --version output dynamically from cargo package version (#174)
* add server auth argument to http client
* Revert "add server auth argument to http client"
This reverts commit f52a8d2c7cdfb8583af5716ad621eb560811d6ee.
* modify WalletCommAdapter, moving dest argument into fields on implementors,
visiting havok on automated tests, at least one of which is now out of date and failing
* Split WalletCommAdapter into four traits, one for each of its intended behaviors.
* Remove two vestigals
1. args, a stringly typed argument to put_tx
2. NullAdapter, which is no longer used
* Remove unused "params" argument from listen method.
* Re-add previously existing TODO comment
* Fix non-test build
* completely Fix non-test build
* Full Lifecycle API Support (#184)
* refactoring wallet lib traits
* rustfmt
* rustfmt
* add new files
* explicit lifetime specifiers on all wallet traits
* rustfmt
* modify apis to use new walletinst
* rustfmt
* converting controller crate
* rustfmt
* controller crate compiling
* rustfmt
* compilation
* rustfmt
* Remove config from wallet, implement open_wallet, close_wallet in lifecycle provider, remove password + open_with_credentials from WalletBackend + impl
* rustfmt
* full compilation, changing recovery + init to new model
* rustfmt
* wallet initialisation working, init command output and flow identical to v2.0.0 wallet
* rustfmt
* fix listener and owner api startup
* rustfmt
* rustfmt
* move encryption test
* rustfmt
* fix api doctests
* rustfmt
* fix for most tests in controller crate
* rustfmt
* fix for check tests in controller crate
* fix main wallet tests
* rustfmt
* add explicit functions to handle mnemonic recovery, fix CLI recovery workflow
* rustfmt
* update keybase adapter to use new wallet format
* rustfmt
* test fix
* remove debug output
2019-07-29 15:25:03 +03:00
let empty_string = util ::ZeroingString ::from ( " " ) ;
let client1 = LocalWalletClient ::new ( " wallet1 " , wallet_proxy . tx . clone ( ) ) ;
let mut wallet1 =
Box ::new ( DefaultWalletImpl ::< LocalWalletClient > ::new ( client1 . clone ( ) ) . unwrap ( ) )
as Box <
2019-08-19 15:05:21 +03:00
dyn WalletInst <
Merge milestone/2.1.0 into master (#199)
* version bump for next potential release
* Merge master into milestone/2.1.0 (#182)
* Derive --version output dynamically from cargo package version (#174)
* add --txid to the `wallet txs` command (#176)
* add --txid to the `wallet txs` command
* add test for `wallet txs` command with `--txid` parameter
* Refactor - Split WalletCommAdapter into multiple traits (#180)
* Derive --version output dynamically from cargo package version (#174)
* add server auth argument to http client
* Revert "add server auth argument to http client"
This reverts commit f52a8d2c7cdfb8583af5716ad621eb560811d6ee.
* modify WalletCommAdapter, moving dest argument into fields on implementors,
visiting havok on automated tests, at least one of which is now out of date and failing
* Split WalletCommAdapter into four traits, one for each of its intended behaviors.
* Remove two vestigals
1. args, a stringly typed argument to put_tx
2. NullAdapter, which is no longer used
* Remove unused "params" argument from listen method.
* Re-add previously existing TODO comment
* Fix non-test build
* completely Fix non-test build
* Full Lifecycle API Support (#184)
* refactoring wallet lib traits
* rustfmt
* rustfmt
* add new files
* explicit lifetime specifiers on all wallet traits
* rustfmt
* modify apis to use new walletinst
* rustfmt
* converting controller crate
* rustfmt
* controller crate compiling
* rustfmt
* compilation
* rustfmt
* Remove config from wallet, implement open_wallet, close_wallet in lifecycle provider, remove password + open_with_credentials from WalletBackend + impl
* rustfmt
* full compilation, changing recovery + init to new model
* rustfmt
* wallet initialisation working, init command output and flow identical to v2.0.0 wallet
* rustfmt
* fix listener and owner api startup
* rustfmt
* rustfmt
* move encryption test
* rustfmt
* fix api doctests
* rustfmt
* fix for most tests in controller crate
* rustfmt
* fix for check tests in controller crate
* fix main wallet tests
* rustfmt
* add explicit functions to handle mnemonic recovery, fix CLI recovery workflow
* rustfmt
* update keybase adapter to use new wallet format
* rustfmt
* test fix
* remove debug output
2019-07-29 15:25:03 +03:00
'static ,
DefaultLCProvider < LocalWalletClient , ExtKeychain > ,
LocalWalletClient ,
ExtKeychain ,
> ,
> ;
let lc = wallet1 . lc_provider ( ) . unwrap ( ) ;
2019-09-02 18:03:35 +03:00
let _ = lc . set_top_level_directory ( & format! ( " {} /wallet1 " , test_dir ) ) ;
lc . create_wallet ( None , Some ( rec_phrase_1 ) , 32 , empty_string . clone ( ) , false )
Merge milestone/2.1.0 into master (#199)
* version bump for next potential release
* Merge master into milestone/2.1.0 (#182)
* Derive --version output dynamically from cargo package version (#174)
* add --txid to the `wallet txs` command (#176)
* add --txid to the `wallet txs` command
* add test for `wallet txs` command with `--txid` parameter
* Refactor - Split WalletCommAdapter into multiple traits (#180)
* Derive --version output dynamically from cargo package version (#174)
* add server auth argument to http client
* Revert "add server auth argument to http client"
This reverts commit f52a8d2c7cdfb8583af5716ad621eb560811d6ee.
* modify WalletCommAdapter, moving dest argument into fields on implementors,
visiting havok on automated tests, at least one of which is now out of date and failing
* Split WalletCommAdapter into four traits, one for each of its intended behaviors.
* Remove two vestigals
1. args, a stringly typed argument to put_tx
2. NullAdapter, which is no longer used
* Remove unused "params" argument from listen method.
* Re-add previously existing TODO comment
* Fix non-test build
* completely Fix non-test build
* Full Lifecycle API Support (#184)
* refactoring wallet lib traits
* rustfmt
* rustfmt
* add new files
* explicit lifetime specifiers on all wallet traits
* rustfmt
* modify apis to use new walletinst
* rustfmt
* converting controller crate
* rustfmt
* controller crate compiling
* rustfmt
* compilation
* rustfmt
* Remove config from wallet, implement open_wallet, close_wallet in lifecycle provider, remove password + open_with_credentials from WalletBackend + impl
* rustfmt
* full compilation, changing recovery + init to new model
* rustfmt
* wallet initialisation working, init command output and flow identical to v2.0.0 wallet
* rustfmt
* fix listener and owner api startup
* rustfmt
* rustfmt
* move encryption test
* rustfmt
* fix api doctests
* rustfmt
* fix for most tests in controller crate
* rustfmt
* fix for check tests in controller crate
* fix main wallet tests
* rustfmt
* add explicit functions to handle mnemonic recovery, fix CLI recovery workflow
* rustfmt
* update keybase adapter to use new wallet format
* rustfmt
* test fix
* remove debug output
2019-07-29 15:25:03 +03:00
. unwrap ( ) ;
2019-08-06 14:50:41 +03:00
let mask1 = lc
2020-03-04 16:38:40 +03:00
. open_wallet ( None , empty_string . clone ( ) , true , true )
2019-08-06 14:50:41 +03:00
. unwrap ( ) ;
Merge milestone/2.1.0 into master (#199)
* version bump for next potential release
* Merge master into milestone/2.1.0 (#182)
* Derive --version output dynamically from cargo package version (#174)
* add --txid to the `wallet txs` command (#176)
* add --txid to the `wallet txs` command
* add test for `wallet txs` command with `--txid` parameter
* Refactor - Split WalletCommAdapter into multiple traits (#180)
* Derive --version output dynamically from cargo package version (#174)
* add server auth argument to http client
* Revert "add server auth argument to http client"
This reverts commit f52a8d2c7cdfb8583af5716ad621eb560811d6ee.
* modify WalletCommAdapter, moving dest argument into fields on implementors,
visiting havok on automated tests, at least one of which is now out of date and failing
* Split WalletCommAdapter into four traits, one for each of its intended behaviors.
* Remove two vestigals
1. args, a stringly typed argument to put_tx
2. NullAdapter, which is no longer used
* Remove unused "params" argument from listen method.
* Re-add previously existing TODO comment
* Fix non-test build
* completely Fix non-test build
* Full Lifecycle API Support (#184)
* refactoring wallet lib traits
* rustfmt
* rustfmt
* add new files
* explicit lifetime specifiers on all wallet traits
* rustfmt
* modify apis to use new walletinst
* rustfmt
* converting controller crate
* rustfmt
* controller crate compiling
* rustfmt
* compilation
* rustfmt
* Remove config from wallet, implement open_wallet, close_wallet in lifecycle provider, remove password + open_with_credentials from WalletBackend + impl
* rustfmt
* full compilation, changing recovery + init to new model
* rustfmt
* wallet initialisation working, init command output and flow identical to v2.0.0 wallet
* rustfmt
* fix listener and owner api startup
* rustfmt
* rustfmt
* move encryption test
* rustfmt
* fix api doctests
* rustfmt
* fix for most tests in controller crate
* rustfmt
* fix for check tests in controller crate
* fix main wallet tests
* rustfmt
* add explicit functions to handle mnemonic recovery, fix CLI recovery workflow
* rustfmt
* update keybase adapter to use new wallet format
* rustfmt
* test fix
* remove debug output
2019-07-29 15:25:03 +03:00
let wallet1 = Arc ::new ( Mutex ::new ( wallet1 ) ) ;
2019-08-06 14:50:41 +03:00
if mask1 . is_some ( ) {
println! ( " WALLET 1 MASK: {:?} " , mask1 . clone ( ) . unwrap ( ) ) ;
}
wallet_proxy . add_wallet (
" wallet1 " ,
client1 . get_send_instance ( ) ,
wallet1 . clone ( ) ,
mask1 . clone ( ) ,
) ;
2019-03-22 15:03:25 +03:00
2020-05-19 13:19:03 +03:00
let mut slate_outer = Slate ::blank ( 2 , false ) ;
2020-01-22 16:16:24 +03:00
Merge milestone/2.1.0 into master (#199)
* version bump for next potential release
* Merge master into milestone/2.1.0 (#182)
* Derive --version output dynamically from cargo package version (#174)
* add --txid to the `wallet txs` command (#176)
* add --txid to the `wallet txs` command
* add test for `wallet txs` command with `--txid` parameter
* Refactor - Split WalletCommAdapter into multiple traits (#180)
* Derive --version output dynamically from cargo package version (#174)
* add server auth argument to http client
* Revert "add server auth argument to http client"
This reverts commit f52a8d2c7cdfb8583af5716ad621eb560811d6ee.
* modify WalletCommAdapter, moving dest argument into fields on implementors,
visiting havok on automated tests, at least one of which is now out of date and failing
* Split WalletCommAdapter into four traits, one for each of its intended behaviors.
* Remove two vestigals
1. args, a stringly typed argument to put_tx
2. NullAdapter, which is no longer used
* Remove unused "params" argument from listen method.
* Re-add previously existing TODO comment
* Fix non-test build
* completely Fix non-test build
* Full Lifecycle API Support (#184)
* refactoring wallet lib traits
* rustfmt
* rustfmt
* add new files
* explicit lifetime specifiers on all wallet traits
* rustfmt
* modify apis to use new walletinst
* rustfmt
* converting controller crate
* rustfmt
* controller crate compiling
* rustfmt
* compilation
* rustfmt
* Remove config from wallet, implement open_wallet, close_wallet in lifecycle provider, remove password + open_with_credentials from WalletBackend + impl
* rustfmt
* full compilation, changing recovery + init to new model
* rustfmt
* wallet initialisation working, init command output and flow identical to v2.0.0 wallet
* rustfmt
* fix listener and owner api startup
* rustfmt
* rustfmt
* move encryption test
* rustfmt
* fix api doctests
* rustfmt
* fix for most tests in controller crate
* rustfmt
* fix for check tests in controller crate
* fix main wallet tests
* rustfmt
* add explicit functions to handle mnemonic recovery, fix CLI recovery workflow
* rustfmt
* update keybase adapter to use new wallet format
* rustfmt
* test fix
* remove debug output
2019-07-29 15:25:03 +03:00
let rec_phrase_2 = util ::ZeroingString ::from (
2019-03-22 15:03:25 +03:00
" hour kingdom ripple lunch razor inquiry coyote clay stamp mean \
Merge milestone/2.1.0 into master (#199)
* version bump for next potential release
* Merge master into milestone/2.1.0 (#182)
* Derive --version output dynamically from cargo package version (#174)
* add --txid to the `wallet txs` command (#176)
* add --txid to the `wallet txs` command
* add test for `wallet txs` command with `--txid` parameter
* Refactor - Split WalletCommAdapter into multiple traits (#180)
* Derive --version output dynamically from cargo package version (#174)
* add server auth argument to http client
* Revert "add server auth argument to http client"
This reverts commit f52a8d2c7cdfb8583af5716ad621eb560811d6ee.
* modify WalletCommAdapter, moving dest argument into fields on implementors,
visiting havok on automated tests, at least one of which is now out of date and failing
* Split WalletCommAdapter into four traits, one for each of its intended behaviors.
* Remove two vestigals
1. args, a stringly typed argument to put_tx
2. NullAdapter, which is no longer used
* Remove unused "params" argument from listen method.
* Re-add previously existing TODO comment
* Fix non-test build
* completely Fix non-test build
* Full Lifecycle API Support (#184)
* refactoring wallet lib traits
* rustfmt
* rustfmt
* add new files
* explicit lifetime specifiers on all wallet traits
* rustfmt
* modify apis to use new walletinst
* rustfmt
* converting controller crate
* rustfmt
* controller crate compiling
* rustfmt
* compilation
* rustfmt
* Remove config from wallet, implement open_wallet, close_wallet in lifecycle provider, remove password + open_with_credentials from WalletBackend + impl
* rustfmt
* full compilation, changing recovery + init to new model
* rustfmt
* wallet initialisation working, init command output and flow identical to v2.0.0 wallet
* rustfmt
* fix listener and owner api startup
* rustfmt
* rustfmt
* move encryption test
* rustfmt
* fix api doctests
* rustfmt
* fix for most tests in controller crate
* rustfmt
* fix for check tests in controller crate
* fix main wallet tests
* rustfmt
* add explicit functions to handle mnemonic recovery, fix CLI recovery workflow
* rustfmt
* update keybase adapter to use new wallet format
* rustfmt
* test fix
* remove debug output
2019-07-29 15:25:03 +03:00
sell finish magic kid tiny wage stand panther inside settle feed song hole exile " ,
2019-03-22 15:03:25 +03:00
) ;
Merge milestone/2.1.0 into master (#199)
* version bump for next potential release
* Merge master into milestone/2.1.0 (#182)
* Derive --version output dynamically from cargo package version (#174)
* add --txid to the `wallet txs` command (#176)
* add --txid to the `wallet txs` command
* add test for `wallet txs` command with `--txid` parameter
* Refactor - Split WalletCommAdapter into multiple traits (#180)
* Derive --version output dynamically from cargo package version (#174)
* add server auth argument to http client
* Revert "add server auth argument to http client"
This reverts commit f52a8d2c7cdfb8583af5716ad621eb560811d6ee.
* modify WalletCommAdapter, moving dest argument into fields on implementors,
visiting havok on automated tests, at least one of which is now out of date and failing
* Split WalletCommAdapter into four traits, one for each of its intended behaviors.
* Remove two vestigals
1. args, a stringly typed argument to put_tx
2. NullAdapter, which is no longer used
* Remove unused "params" argument from listen method.
* Re-add previously existing TODO comment
* Fix non-test build
* completely Fix non-test build
* Full Lifecycle API Support (#184)
* refactoring wallet lib traits
* rustfmt
* rustfmt
* add new files
* explicit lifetime specifiers on all wallet traits
* rustfmt
* modify apis to use new walletinst
* rustfmt
* converting controller crate
* rustfmt
* controller crate compiling
* rustfmt
* compilation
* rustfmt
* Remove config from wallet, implement open_wallet, close_wallet in lifecycle provider, remove password + open_with_credentials from WalletBackend + impl
* rustfmt
* full compilation, changing recovery + init to new model
* rustfmt
* wallet initialisation working, init command output and flow identical to v2.0.0 wallet
* rustfmt
* fix listener and owner api startup
* rustfmt
* rustfmt
* move encryption test
* rustfmt
* fix api doctests
* rustfmt
* fix for most tests in controller crate
* rustfmt
* fix for check tests in controller crate
* fix main wallet tests
* rustfmt
* add explicit functions to handle mnemonic recovery, fix CLI recovery workflow
* rustfmt
* update keybase adapter to use new wallet format
* rustfmt
* test fix
* remove debug output
2019-07-29 15:25:03 +03:00
let client2 = LocalWalletClient ::new ( " wallet2 " , wallet_proxy . tx . clone ( ) ) ;
let mut wallet2 =
Box ::new ( DefaultWalletImpl ::< LocalWalletClient > ::new ( client2 . clone ( ) ) . unwrap ( ) )
as Box <
2019-08-19 15:05:21 +03:00
dyn WalletInst <
Merge milestone/2.1.0 into master (#199)
* version bump for next potential release
* Merge master into milestone/2.1.0 (#182)
* Derive --version output dynamically from cargo package version (#174)
* add --txid to the `wallet txs` command (#176)
* add --txid to the `wallet txs` command
* add test for `wallet txs` command with `--txid` parameter
* Refactor - Split WalletCommAdapter into multiple traits (#180)
* Derive --version output dynamically from cargo package version (#174)
* add server auth argument to http client
* Revert "add server auth argument to http client"
This reverts commit f52a8d2c7cdfb8583af5716ad621eb560811d6ee.
* modify WalletCommAdapter, moving dest argument into fields on implementors,
visiting havok on automated tests, at least one of which is now out of date and failing
* Split WalletCommAdapter into four traits, one for each of its intended behaviors.
* Remove two vestigals
1. args, a stringly typed argument to put_tx
2. NullAdapter, which is no longer used
* Remove unused "params" argument from listen method.
* Re-add previously existing TODO comment
* Fix non-test build
* completely Fix non-test build
* Full Lifecycle API Support (#184)
* refactoring wallet lib traits
* rustfmt
* rustfmt
* add new files
* explicit lifetime specifiers on all wallet traits
* rustfmt
* modify apis to use new walletinst
* rustfmt
* converting controller crate
* rustfmt
* controller crate compiling
* rustfmt
* compilation
* rustfmt
* Remove config from wallet, implement open_wallet, close_wallet in lifecycle provider, remove password + open_with_credentials from WalletBackend + impl
* rustfmt
* full compilation, changing recovery + init to new model
* rustfmt
* wallet initialisation working, init command output and flow identical to v2.0.0 wallet
* rustfmt
* fix listener and owner api startup
* rustfmt
* rustfmt
* move encryption test
* rustfmt
* fix api doctests
* rustfmt
* fix for most tests in controller crate
* rustfmt
* fix for check tests in controller crate
* fix main wallet tests
* rustfmt
* add explicit functions to handle mnemonic recovery, fix CLI recovery workflow
* rustfmt
* update keybase adapter to use new wallet format
* rustfmt
* test fix
* remove debug output
2019-07-29 15:25:03 +03:00
'static ,
DefaultLCProvider < LocalWalletClient , ExtKeychain > ,
LocalWalletClient ,
ExtKeychain ,
> ,
> ;
let lc = wallet2 . lc_provider ( ) . unwrap ( ) ;
2019-09-02 18:03:35 +03:00
let _ = lc . set_top_level_directory ( & format! ( " {} /wallet2 " , test_dir ) ) ;
lc . create_wallet ( None , Some ( rec_phrase_2 ) , 32 , empty_string . clone ( ) , false )
Merge milestone/2.1.0 into master (#199)
* version bump for next potential release
* Merge master into milestone/2.1.0 (#182)
* Derive --version output dynamically from cargo package version (#174)
* add --txid to the `wallet txs` command (#176)
* add --txid to the `wallet txs` command
* add test for `wallet txs` command with `--txid` parameter
* Refactor - Split WalletCommAdapter into multiple traits (#180)
* Derive --version output dynamically from cargo package version (#174)
* add server auth argument to http client
* Revert "add server auth argument to http client"
This reverts commit f52a8d2c7cdfb8583af5716ad621eb560811d6ee.
* modify WalletCommAdapter, moving dest argument into fields on implementors,
visiting havok on automated tests, at least one of which is now out of date and failing
* Split WalletCommAdapter into four traits, one for each of its intended behaviors.
* Remove two vestigals
1. args, a stringly typed argument to put_tx
2. NullAdapter, which is no longer used
* Remove unused "params" argument from listen method.
* Re-add previously existing TODO comment
* Fix non-test build
* completely Fix non-test build
* Full Lifecycle API Support (#184)
* refactoring wallet lib traits
* rustfmt
* rustfmt
* add new files
* explicit lifetime specifiers on all wallet traits
* rustfmt
* modify apis to use new walletinst
* rustfmt
* converting controller crate
* rustfmt
* controller crate compiling
* rustfmt
* compilation
* rustfmt
* Remove config from wallet, implement open_wallet, close_wallet in lifecycle provider, remove password + open_with_credentials from WalletBackend + impl
* rustfmt
* full compilation, changing recovery + init to new model
* rustfmt
* wallet initialisation working, init command output and flow identical to v2.0.0 wallet
* rustfmt
* fix listener and owner api startup
* rustfmt
* rustfmt
* move encryption test
* rustfmt
* fix api doctests
* rustfmt
* fix for most tests in controller crate
* rustfmt
* fix for check tests in controller crate
* fix main wallet tests
* rustfmt
* add explicit functions to handle mnemonic recovery, fix CLI recovery workflow
* rustfmt
* update keybase adapter to use new wallet format
* rustfmt
* test fix
* remove debug output
2019-07-29 15:25:03 +03:00
. unwrap ( ) ;
2020-03-04 16:38:40 +03:00
let mask2 = lc . open_wallet ( None , empty_string , true , true ) . unwrap ( ) ;
Merge milestone/2.1.0 into master (#199)
* version bump for next potential release
* Merge master into milestone/2.1.0 (#182)
* Derive --version output dynamically from cargo package version (#174)
* add --txid to the `wallet txs` command (#176)
* add --txid to the `wallet txs` command
* add test for `wallet txs` command with `--txid` parameter
* Refactor - Split WalletCommAdapter into multiple traits (#180)
* Derive --version output dynamically from cargo package version (#174)
* add server auth argument to http client
* Revert "add server auth argument to http client"
This reverts commit f52a8d2c7cdfb8583af5716ad621eb560811d6ee.
* modify WalletCommAdapter, moving dest argument into fields on implementors,
visiting havok on automated tests, at least one of which is now out of date and failing
* Split WalletCommAdapter into four traits, one for each of its intended behaviors.
* Remove two vestigals
1. args, a stringly typed argument to put_tx
2. NullAdapter, which is no longer used
* Remove unused "params" argument from listen method.
* Re-add previously existing TODO comment
* Fix non-test build
* completely Fix non-test build
* Full Lifecycle API Support (#184)
* refactoring wallet lib traits
* rustfmt
* rustfmt
* add new files
* explicit lifetime specifiers on all wallet traits
* rustfmt
* modify apis to use new walletinst
* rustfmt
* converting controller crate
* rustfmt
* controller crate compiling
* rustfmt
* compilation
* rustfmt
* Remove config from wallet, implement open_wallet, close_wallet in lifecycle provider, remove password + open_with_credentials from WalletBackend + impl
* rustfmt
* full compilation, changing recovery + init to new model
* rustfmt
* wallet initialisation working, init command output and flow identical to v2.0.0 wallet
* rustfmt
* fix listener and owner api startup
* rustfmt
* rustfmt
* move encryption test
* rustfmt
* fix api doctests
* rustfmt
* fix for most tests in controller crate
* rustfmt
* fix for check tests in controller crate
* fix main wallet tests
* rustfmt
* add explicit functions to handle mnemonic recovery, fix CLI recovery workflow
* rustfmt
* update keybase adapter to use new wallet format
* rustfmt
* test fix
* remove debug output
2019-07-29 15:25:03 +03:00
let wallet2 = Arc ::new ( Mutex ::new ( wallet2 ) ) ;
2019-08-06 14:50:41 +03:00
if mask2 . is_some ( ) {
println! ( " WALLET 2 MASK: {:?} " , mask2 . clone ( ) . unwrap ( ) ) ;
}
wallet_proxy . add_wallet (
" wallet2 " ,
client2 . get_send_instance ( ) ,
wallet2 . clone ( ) ,
mask2 . clone ( ) ,
) ;
2019-03-22 15:03:25 +03:00
// Set the wallet proxy listener running
thread ::spawn ( move | | {
if let Err ( e ) = wallet_proxy . run ( ) {
error! ( " Wallet Proxy error: {} " , e ) ;
}
} ) ;
// Mine a few blocks to wallet 1 so there's something to send
for _ in 0 .. blocks_to_mine {
2019-08-06 14:50:41 +03:00
let _ = test_framework ::award_blocks_to_wallet (
& chain ,
wallet1 . clone ( ) ,
( & mask1 ) . as_ref ( ) ,
1 as usize ,
false ,
) ;
2019-03-22 15:03:25 +03:00
//update local outputs after each block, so transaction IDs stay consistent
2019-11-18 13:49:51 +03:00
let ( wallet_refreshed , _ ) = api_impl ::owner ::retrieve_summary_info (
wallet1 . clone ( ) ,
( & mask1 ) . as_ref ( ) ,
& None ,
true ,
1 ,
)
. unwrap ( ) ;
2019-03-22 15:03:25 +03:00
assert! ( wallet_refreshed ) ;
}
if perform_tx {
let amount = 60_000_000_000 ;
Merge milestone/2.1.0 into master (#199)
* version bump for next potential release
* Merge master into milestone/2.1.0 (#182)
* Derive --version output dynamically from cargo package version (#174)
* add --txid to the `wallet txs` command (#176)
* add --txid to the `wallet txs` command
* add test for `wallet txs` command with `--txid` parameter
* Refactor - Split WalletCommAdapter into multiple traits (#180)
* Derive --version output dynamically from cargo package version (#174)
* add server auth argument to http client
* Revert "add server auth argument to http client"
This reverts commit f52a8d2c7cdfb8583af5716ad621eb560811d6ee.
* modify WalletCommAdapter, moving dest argument into fields on implementors,
visiting havok on automated tests, at least one of which is now out of date and failing
* Split WalletCommAdapter into four traits, one for each of its intended behaviors.
* Remove two vestigals
1. args, a stringly typed argument to put_tx
2. NullAdapter, which is no longer used
* Remove unused "params" argument from listen method.
* Re-add previously existing TODO comment
* Fix non-test build
* completely Fix non-test build
* Full Lifecycle API Support (#184)
* refactoring wallet lib traits
* rustfmt
* rustfmt
* add new files
* explicit lifetime specifiers on all wallet traits
* rustfmt
* modify apis to use new walletinst
* rustfmt
* converting controller crate
* rustfmt
* controller crate compiling
* rustfmt
* compilation
* rustfmt
* Remove config from wallet, implement open_wallet, close_wallet in lifecycle provider, remove password + open_with_credentials from WalletBackend + impl
* rustfmt
* full compilation, changing recovery + init to new model
* rustfmt
* wallet initialisation working, init command output and flow identical to v2.0.0 wallet
* rustfmt
* fix listener and owner api startup
* rustfmt
* rustfmt
* move encryption test
* rustfmt
* fix api doctests
* rustfmt
* fix for most tests in controller crate
* rustfmt
* fix for check tests in controller crate
* fix main wallet tests
* rustfmt
* add explicit functions to handle mnemonic recovery, fix CLI recovery workflow
* rustfmt
* update keybase adapter to use new wallet format
* rustfmt
* test fix
* remove debug output
2019-07-29 15:25:03 +03:00
let mut w_lock = wallet1 . lock ( ) ;
let w = w_lock . lc_provider ( ) . unwrap ( ) . wallet_inst ( ) . unwrap ( ) ;
2020-01-22 16:16:24 +03:00
let proof_address = match payment_proof {
true = > {
2020-01-24 16:02:09 +03:00
let address = " 783f6528669742a990e0faf0a5fca5d5b3330e37bbb9cd5c628696d03ce4e810 " ;
2020-05-28 10:17:51 +03:00
let address = OnionV3Address ::try_from ( address ) . unwrap ( ) ;
Some ( SlatepackAddress ::try_from ( address ) . unwrap ( ) )
2020-01-22 16:16:24 +03:00
}
false = > None ,
} ;
2019-03-29 19:00:02 +03:00
let args = InitTxArgs {
src_acct_name : None ,
amount ,
minimum_confirmations : 2 ,
max_outputs : 500 ,
num_change_outputs : 1 ,
selection_strategy_is_use_all : true ,
2020-01-22 16:16:24 +03:00
payment_proof_recipient_address : proof_address ,
2019-03-29 19:00:02 +03:00
.. Default ::default ( )
} ;
2019-08-06 14:50:41 +03:00
let mut slate =
api_impl ::owner ::init_send_tx ( & mut * * w , ( & mask1 ) . as_ref ( ) , args , true ) . unwrap ( ) ;
2019-05-31 10:33:23 +03:00
println! ( " INITIAL SLATE " ) ;
println! ( " {} " , serde_json ::to_string_pretty ( & slate ) . unwrap ( ) ) ;
2019-03-22 15:03:25 +03:00
{
Merge milestone/2.1.0 into master (#199)
* version bump for next potential release
* Merge master into milestone/2.1.0 (#182)
* Derive --version output dynamically from cargo package version (#174)
* add --txid to the `wallet txs` command (#176)
* add --txid to the `wallet txs` command
* add test for `wallet txs` command with `--txid` parameter
* Refactor - Split WalletCommAdapter into multiple traits (#180)
* Derive --version output dynamically from cargo package version (#174)
* add server auth argument to http client
* Revert "add server auth argument to http client"
This reverts commit f52a8d2c7cdfb8583af5716ad621eb560811d6ee.
* modify WalletCommAdapter, moving dest argument into fields on implementors,
visiting havok on automated tests, at least one of which is now out of date and failing
* Split WalletCommAdapter into four traits, one for each of its intended behaviors.
* Remove two vestigals
1. args, a stringly typed argument to put_tx
2. NullAdapter, which is no longer used
* Remove unused "params" argument from listen method.
* Re-add previously existing TODO comment
* Fix non-test build
* completely Fix non-test build
* Full Lifecycle API Support (#184)
* refactoring wallet lib traits
* rustfmt
* rustfmt
* add new files
* explicit lifetime specifiers on all wallet traits
* rustfmt
* modify apis to use new walletinst
* rustfmt
* converting controller crate
* rustfmt
* controller crate compiling
* rustfmt
* compilation
* rustfmt
* Remove config from wallet, implement open_wallet, close_wallet in lifecycle provider, remove password + open_with_credentials from WalletBackend + impl
* rustfmt
* full compilation, changing recovery + init to new model
* rustfmt
* wallet initialisation working, init command output and flow identical to v2.0.0 wallet
* rustfmt
* fix listener and owner api startup
* rustfmt
* rustfmt
* move encryption test
* rustfmt
* fix api doctests
* rustfmt
* fix for most tests in controller crate
* rustfmt
* fix for check tests in controller crate
* fix main wallet tests
* rustfmt
* add explicit functions to handle mnemonic recovery, fix CLI recovery workflow
* rustfmt
* update keybase adapter to use new wallet format
* rustfmt
* test fix
* remove debug output
2019-07-29 15:25:03 +03:00
let mut w_lock = wallet2 . lock ( ) ;
let w2 = w_lock . lc_provider ( ) . unwrap ( ) . wallet_inst ( ) . unwrap ( ) ;
2020-05-19 13:19:03 +03:00
slate = api_impl ::foreign ::receive_tx ( & mut * * w2 , ( & mask2 ) . as_ref ( ) , & slate , None , true )
. unwrap ( ) ;
2019-03-22 15:03:25 +03:00
w2 . close ( ) . unwrap ( ) ;
}
// Spit out slate for input to finalize_tx
if lock_tx {
2020-05-19 13:19:03 +03:00
println! ( " LOCKING TX " ) ;
api_impl ::owner ::tx_lock_outputs ( & mut * * w , ( & mask1 ) . as_ref ( ) , & slate ) . unwrap ( ) ;
2019-03-22 15:03:25 +03:00
}
2019-05-31 10:33:23 +03:00
println! ( " RECEIPIENT SLATE " ) ;
println! ( " {} " , serde_json ::to_string_pretty ( & slate ) . unwrap ( ) ) ;
2019-03-22 15:03:25 +03:00
if finalize_tx {
2020-05-19 13:19:03 +03:00
slate = api_impl ::owner ::finalize_tx ( & mut * * w , ( & mask1 ) . as_ref ( ) , & slate ) . unwrap ( ) ;
2019-05-31 10:33:23 +03:00
error! ( " FINALIZED TX SLATE " ) ;
println! ( " {} " , serde_json ::to_string_pretty ( & slate ) . unwrap ( ) ) ;
2019-03-22 15:03:25 +03:00
}
2020-01-22 16:16:24 +03:00
slate_outer = slate ;
}
if payment_proof {
2020-03-10 21:19:27 +03:00
api_impl ::owner ::post_tx ( & client1 , slate_outer . tx_or_err ( ) . unwrap ( ) , true ) . unwrap ( ) ;
2019-03-22 15:03:25 +03:00
}
if perform_tx & & lock_tx & & finalize_tx {
// mine to move the chain on
2019-08-06 14:50:41 +03:00
let _ = test_framework ::award_blocks_to_wallet (
& chain ,
wallet1 . clone ( ) ,
( & mask1 ) . as_ref ( ) ,
3 as usize ,
false ,
) ;
2019-03-22 15:03:25 +03:00
}
2020-02-06 12:08:24 +03:00
let mut api_owner = Owner ::new ( wallet1 , None ) ;
2019-03-22 15:03:25 +03:00
api_owner . doctest_mode = true ;
2020-03-04 16:38:40 +03:00
let owner_api = & api_owner as & dyn OwnerRpc ;
let res = owner_api . handle_request ( request ) . as_option ( ) ;
2019-08-19 15:05:21 +03:00
let _ = fs ::remove_dir_all ( test_dir ) ;
Ok ( res )
2019-03-22 15:03:25 +03:00
}
2019-03-14 15:06:03 +03:00
#[ doc(hidden) ]
#[ macro_export ]
macro_rules ! doctest_helper_json_rpc_owner_assert_response {
2020-03-04 16:38:40 +03:00
( $request :expr , $expected_response :expr , $blocks_to_mine :expr , $perform_tx :expr , $lock_tx :expr , $finalize_tx :expr , $payment_proof :expr ) = > {
2019-03-14 15:06:03 +03:00
// create temporary wallet, run jsonrpc request on owner api of wallet, delete wallet, return
// json response.
// In order to prevent leaking tempdirs, This function should not panic.
2019-03-22 15:03:25 +03:00
2019-08-19 15:05:21 +03:00
// These cause LMDB to run out of disk space on CircleCI
// disable for now on windows
// TODO: Fix properly
#[ cfg(not(target_os = " windows " )) ]
{
use grin_wallet_api ::run_doctest_owner ;
use serde_json ;
use serde_json ::Value ;
use tempfile ::tempdir ;
let dir = tempdir ( ) . map_err ( | e | format! ( " {:#?} " , e ) ) . unwrap ( ) ;
let dir = dir
. path ( )
. to_str ( )
. ok_or ( " Failed to convert tmpdir path to string. " . to_owned ( ) )
. unwrap ( ) ;
let request_val : Value = serde_json ::from_str ( $request ) . unwrap ( ) ;
let expected_response : Value = serde_json ::from_str ( $expected_response ) . unwrap ( ) ;
let response = run_doctest_owner (
request_val ,
dir ,
$blocks_to_mine ,
$perform_tx ,
$lock_tx ,
$finalize_tx ,
2020-01-22 16:16:24 +03:00
$payment_proof ,
2019-08-19 15:05:21 +03:00
)
. unwrap ( )
. unwrap ( ) ;
2019-03-14 15:06:03 +03:00
2019-08-19 15:05:21 +03:00
if response ! = expected_response {
panic! (
" (left != right) \n left: {} \n right: {} " ,
serde_json ::to_string_pretty ( & response ) . unwrap ( ) ,
serde_json ::to_string_pretty ( & expected_response ) . unwrap ( )
2019-03-14 15:06:03 +03:00
) ;
2019-08-19 15:05:21 +03:00
}
2019-03-14 15:06:03 +03:00
}
} ;
}