2019-03-17 22:14:58 +03:00
|
|
|
// Copyright 2018 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.
|
|
|
|
|
|
|
|
//! Generic implementation of owner API functions
|
|
|
|
|
|
|
|
use uuid::Uuid;
|
|
|
|
|
2019-03-26 19:02:31 +03:00
|
|
|
use crate::grin_core::core::hash::Hashed;
|
|
|
|
use crate::grin_core::core::Transaction;
|
|
|
|
use crate::grin_core::ser;
|
|
|
|
use crate::grin_util;
|
2019-03-17 22:14:58 +03:00
|
|
|
|
2019-03-26 19:02:31 +03:00
|
|
|
use crate::grin_keychain::{Identifier, Keychain};
|
2019-03-17 22:14:58 +03:00
|
|
|
use crate::internal::{keys, selection, tx, updater};
|
|
|
|
use crate::slate::Slate;
|
2019-04-25 09:59:45 +03:00
|
|
|
use crate::types::{AcctPathMapping, NodeClient, TxLogEntry, TxWrapper, WalletBackend, WalletInfo};
|
2019-03-17 22:14:58 +03:00
|
|
|
use crate::{Error, ErrorKind};
|
2019-05-01 22:12:23 +03:00
|
|
|
use crate::{
|
|
|
|
InitTxArgs, IssueInvoiceTxArgs, NodeHeightResult, OutputCommitMapping, TxLogEntryType,
|
|
|
|
};
|
2019-03-17 22:14:58 +03:00
|
|
|
|
|
|
|
const USER_MESSAGE_MAX_LEN: usize = 256;
|
|
|
|
|
|
|
|
/// List of accounts
|
|
|
|
pub fn accounts<T: ?Sized, C, K>(w: &mut T) -> Result<Vec<AcctPathMapping>, Error>
|
|
|
|
where
|
|
|
|
T: WalletBackend<C, K>,
|
|
|
|
C: NodeClient,
|
|
|
|
K: Keychain,
|
|
|
|
{
|
|
|
|
keys::accounts(&mut *w)
|
|
|
|
}
|
|
|
|
|
|
|
|
/// new account path
|
|
|
|
pub fn create_account_path<T: ?Sized, C, K>(w: &mut T, label: &str) -> Result<Identifier, Error>
|
|
|
|
where
|
|
|
|
T: WalletBackend<C, K>,
|
|
|
|
C: NodeClient,
|
|
|
|
K: Keychain,
|
|
|
|
{
|
|
|
|
keys::new_acct_path(&mut *w, label)
|
|
|
|
}
|
|
|
|
|
|
|
|
/// set active account
|
|
|
|
pub fn set_active_account<T: ?Sized, C, K>(w: &mut T, label: &str) -> Result<(), Error>
|
|
|
|
where
|
|
|
|
T: WalletBackend<C, K>,
|
|
|
|
C: NodeClient,
|
|
|
|
K: Keychain,
|
|
|
|
{
|
|
|
|
w.set_parent_key_id_by_name(label)
|
|
|
|
}
|
|
|
|
|
|
|
|
/// retrieve outputs
|
|
|
|
pub fn retrieve_outputs<T: ?Sized, C, K>(
|
|
|
|
w: &mut T,
|
|
|
|
include_spent: bool,
|
|
|
|
refresh_from_node: bool,
|
|
|
|
tx_id: Option<u32>,
|
2019-03-22 15:03:25 +03:00
|
|
|
) -> Result<(bool, Vec<OutputCommitMapping>), Error>
|
2019-03-17 22:14:58 +03:00
|
|
|
where
|
|
|
|
T: WalletBackend<C, K>,
|
|
|
|
C: NodeClient,
|
|
|
|
K: Keychain,
|
|
|
|
{
|
|
|
|
let parent_key_id = w.parent_key_id();
|
|
|
|
|
|
|
|
let mut validated = false;
|
|
|
|
if refresh_from_node {
|
|
|
|
validated = update_outputs(w, false);
|
|
|
|
}
|
|
|
|
|
|
|
|
Ok((
|
|
|
|
validated,
|
2019-04-25 09:59:45 +03:00
|
|
|
updater::retrieve_outputs(&mut *w, include_spent, tx_id, Some(&parent_key_id))?,
|
2019-03-17 22:14:58 +03:00
|
|
|
))
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Retrieve txs
|
|
|
|
pub fn retrieve_txs<T: ?Sized, C, K>(
|
|
|
|
w: &mut T,
|
|
|
|
refresh_from_node: bool,
|
|
|
|
tx_id: Option<u32>,
|
|
|
|
tx_slate_id: Option<Uuid>,
|
|
|
|
) -> Result<(bool, Vec<TxLogEntry>), Error>
|
|
|
|
where
|
|
|
|
T: WalletBackend<C, K>,
|
|
|
|
C: NodeClient,
|
|
|
|
K: Keychain,
|
|
|
|
{
|
|
|
|
let parent_key_id = w.parent_key_id();
|
|
|
|
|
|
|
|
let mut validated = false;
|
|
|
|
if refresh_from_node {
|
|
|
|
validated = update_outputs(w, false);
|
|
|
|
}
|
|
|
|
|
|
|
|
Ok((
|
|
|
|
validated,
|
|
|
|
updater::retrieve_txs(&mut *w, tx_id, tx_slate_id, Some(&parent_key_id), false)?,
|
|
|
|
))
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Retrieve summary info
|
|
|
|
pub fn retrieve_summary_info<T: ?Sized, C, K>(
|
|
|
|
w: &mut T,
|
|
|
|
refresh_from_node: bool,
|
|
|
|
minimum_confirmations: u64,
|
|
|
|
) -> Result<(bool, WalletInfo), Error>
|
|
|
|
where
|
|
|
|
T: WalletBackend<C, K>,
|
|
|
|
C: NodeClient,
|
|
|
|
K: Keychain,
|
|
|
|
{
|
|
|
|
let parent_key_id = w.parent_key_id();
|
|
|
|
|
|
|
|
let mut validated = false;
|
|
|
|
if refresh_from_node {
|
|
|
|
validated = update_outputs(w, false);
|
|
|
|
}
|
|
|
|
|
|
|
|
let wallet_info = updater::retrieve_info(&mut *w, &parent_key_id, minimum_confirmations)?;
|
|
|
|
Ok((validated, wallet_info))
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Initiate tx as sender
|
2019-05-01 22:12:23 +03:00
|
|
|
pub fn init_send_tx<T: ?Sized, C, K>(
|
2019-03-17 22:14:58 +03:00
|
|
|
w: &mut T,
|
2019-03-29 19:00:02 +03:00
|
|
|
args: InitTxArgs,
|
2019-03-22 15:03:25 +03:00
|
|
|
use_test_rng: bool,
|
2019-03-17 22:14:58 +03:00
|
|
|
) -> Result<Slate, Error>
|
|
|
|
where
|
|
|
|
T: WalletBackend<C, K>,
|
|
|
|
C: NodeClient,
|
|
|
|
K: Keychain,
|
|
|
|
{
|
2019-03-29 19:00:02 +03:00
|
|
|
let parent_key_id = match args.src_acct_name {
|
2019-03-17 22:14:58 +03:00
|
|
|
Some(d) => {
|
2019-03-29 19:00:02 +03:00
|
|
|
let pm = w.get_acct_path(d)?;
|
2019-03-17 22:14:58 +03:00
|
|
|
match pm {
|
|
|
|
Some(p) => p.path,
|
|
|
|
None => w.parent_key_id(),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
None => w.parent_key_id(),
|
|
|
|
};
|
|
|
|
|
2019-03-29 19:00:02 +03:00
|
|
|
let message = match args.message {
|
2019-03-17 22:14:58 +03:00
|
|
|
Some(mut m) => {
|
|
|
|
m.truncate(USER_MESSAGE_MAX_LEN);
|
|
|
|
Some(m)
|
|
|
|
}
|
|
|
|
None => None,
|
|
|
|
};
|
|
|
|
|
2019-03-29 19:00:02 +03:00
|
|
|
let mut slate = tx::new_tx_slate(&mut *w, args.amount, 2, use_test_rng)?;
|
|
|
|
|
|
|
|
// if we just want to estimate, don't save a context, just send the results
|
|
|
|
// back
|
|
|
|
if let Some(true) = args.estimate_only {
|
|
|
|
let (total, fee) = tx::estimate_send_tx(
|
|
|
|
&mut *w,
|
|
|
|
args.amount,
|
|
|
|
args.minimum_confirmations,
|
|
|
|
args.max_outputs as usize,
|
|
|
|
args.num_change_outputs as usize,
|
|
|
|
args.selection_strategy_is_use_all,
|
|
|
|
&parent_key_id,
|
|
|
|
)?;
|
|
|
|
slate.amount = total;
|
|
|
|
slate.fee = fee;
|
|
|
|
return Ok(slate);
|
|
|
|
}
|
2019-03-17 22:14:58 +03:00
|
|
|
|
|
|
|
let context = tx::add_inputs_to_slate(
|
|
|
|
&mut *w,
|
|
|
|
&mut slate,
|
2019-03-29 19:00:02 +03:00
|
|
|
args.minimum_confirmations,
|
|
|
|
args.max_outputs as usize,
|
|
|
|
args.num_change_outputs as usize,
|
|
|
|
args.selection_strategy_is_use_all,
|
2019-03-17 22:14:58 +03:00
|
|
|
&parent_key_id,
|
|
|
|
0,
|
|
|
|
message,
|
2019-05-01 22:12:23 +03:00
|
|
|
true,
|
2019-03-22 15:03:25 +03:00
|
|
|
use_test_rng,
|
2019-03-17 22:14:58 +03:00
|
|
|
)?;
|
|
|
|
|
|
|
|
// Save the aggsig context in our DB for when we
|
|
|
|
// recieve the transaction back
|
|
|
|
{
|
|
|
|
let mut batch = w.batch()?;
|
2019-05-23 18:27:57 +03:00
|
|
|
batch.save_private_context(slate.id.as_bytes(), 0, &context)?;
|
2019-03-17 22:14:58 +03:00
|
|
|
batch.commit()?;
|
|
|
|
}
|
2019-03-29 19:00:02 +03:00
|
|
|
if let Some(v) = args.target_slate_version {
|
2019-03-17 22:14:58 +03:00
|
|
|
slate.version_info.orig_version = v;
|
|
|
|
}
|
|
|
|
Ok(slate)
|
|
|
|
}
|
|
|
|
|
2019-05-01 22:12:23 +03:00
|
|
|
/// Initiate a transaction as the recipient (invoicing)
|
|
|
|
pub fn issue_invoice_tx<T: ?Sized, C, K>(
|
|
|
|
w: &mut T,
|
|
|
|
args: IssueInvoiceTxArgs,
|
|
|
|
use_test_rng: bool,
|
|
|
|
) -> Result<Slate, Error>
|
|
|
|
where
|
|
|
|
T: WalletBackend<C, K>,
|
|
|
|
C: NodeClient,
|
|
|
|
K: Keychain,
|
|
|
|
{
|
|
|
|
let parent_key_id = match args.dest_acct_name {
|
|
|
|
Some(d) => {
|
|
|
|
let pm = w.get_acct_path(d)?;
|
|
|
|
match pm {
|
|
|
|
Some(p) => p.path,
|
|
|
|
None => w.parent_key_id(),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
None => w.parent_key_id(),
|
|
|
|
};
|
|
|
|
|
|
|
|
let message = match args.message {
|
|
|
|
Some(mut m) => {
|
|
|
|
m.truncate(USER_MESSAGE_MAX_LEN);
|
|
|
|
Some(m)
|
|
|
|
}
|
|
|
|
None => None,
|
|
|
|
};
|
|
|
|
|
|
|
|
let mut slate = tx::new_tx_slate(&mut *w, args.amount, 2, use_test_rng)?;
|
|
|
|
let context = tx::add_output_to_slate(
|
|
|
|
&mut *w,
|
|
|
|
&mut slate,
|
|
|
|
&parent_key_id,
|
|
|
|
1,
|
|
|
|
message,
|
|
|
|
true,
|
|
|
|
use_test_rng,
|
|
|
|
)?;
|
|
|
|
|
|
|
|
// Save the aggsig context in our DB for when we
|
|
|
|
// recieve the transaction back
|
|
|
|
{
|
|
|
|
let mut batch = w.batch()?;
|
2019-05-23 18:27:57 +03:00
|
|
|
batch.save_private_context(slate.id.as_bytes(), 1, &context)?;
|
2019-05-01 22:12:23 +03:00
|
|
|
batch.commit()?;
|
|
|
|
}
|
|
|
|
|
|
|
|
Ok(slate)
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Receive an invoice tx, essentially adding inputs to whatever
|
|
|
|
/// output was specified
|
|
|
|
pub fn process_invoice_tx<T: ?Sized, C, K>(
|
|
|
|
w: &mut T,
|
|
|
|
slate: &Slate,
|
|
|
|
args: InitTxArgs,
|
|
|
|
use_test_rng: bool,
|
|
|
|
) -> Result<Slate, Error>
|
|
|
|
where
|
|
|
|
T: WalletBackend<C, K>,
|
|
|
|
C: NodeClient,
|
|
|
|
K: Keychain,
|
|
|
|
{
|
|
|
|
let mut ret_slate = slate.clone();
|
|
|
|
let parent_key_id = match args.src_acct_name {
|
|
|
|
Some(d) => {
|
|
|
|
let pm = w.get_acct_path(d.to_owned())?;
|
|
|
|
match pm {
|
|
|
|
Some(p) => p.path,
|
|
|
|
None => w.parent_key_id(),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
None => w.parent_key_id(),
|
|
|
|
};
|
|
|
|
// Don't do this multiple times
|
|
|
|
let tx = updater::retrieve_txs(
|
|
|
|
&mut *w,
|
|
|
|
None,
|
|
|
|
Some(ret_slate.id),
|
|
|
|
Some(&parent_key_id),
|
|
|
|
use_test_rng,
|
|
|
|
)?;
|
|
|
|
for t in &tx {
|
|
|
|
if t.tx_type == TxLogEntryType::TxSent {
|
|
|
|
return Err(ErrorKind::TransactionAlreadyReceived(ret_slate.id.to_string()).into());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
let message = match args.message {
|
|
|
|
Some(mut m) => {
|
|
|
|
m.truncate(USER_MESSAGE_MAX_LEN);
|
|
|
|
Some(m)
|
|
|
|
}
|
|
|
|
None => None,
|
|
|
|
};
|
|
|
|
|
2019-05-21 12:00:19 +03:00
|
|
|
// update slate current height
|
|
|
|
ret_slate.height = w.w2n_client().get_chain_height()?;
|
|
|
|
|
2019-05-01 22:12:23 +03:00
|
|
|
let context = tx::add_inputs_to_slate(
|
|
|
|
&mut *w,
|
|
|
|
&mut ret_slate,
|
|
|
|
args.minimum_confirmations,
|
|
|
|
args.max_outputs as usize,
|
|
|
|
args.num_change_outputs as usize,
|
|
|
|
args.selection_strategy_is_use_all,
|
|
|
|
&parent_key_id,
|
|
|
|
0,
|
|
|
|
message,
|
|
|
|
false,
|
|
|
|
use_test_rng,
|
|
|
|
)?;
|
|
|
|
|
|
|
|
// Save the aggsig context in our DB for when we
|
|
|
|
// recieve the transaction back
|
|
|
|
{
|
|
|
|
let mut batch = w.batch()?;
|
2019-05-23 18:27:57 +03:00
|
|
|
batch.save_private_context(slate.id.as_bytes(), 0, &context)?;
|
2019-05-01 22:12:23 +03:00
|
|
|
batch.commit()?;
|
|
|
|
}
|
|
|
|
|
|
|
|
Ok(ret_slate)
|
|
|
|
}
|
|
|
|
|
2019-03-17 22:14:58 +03:00
|
|
|
/// Lock sender outputs
|
2019-05-23 18:27:57 +03:00
|
|
|
pub fn tx_lock_outputs<T: ?Sized, C, K>(
|
|
|
|
w: &mut T,
|
|
|
|
slate: &Slate,
|
|
|
|
participant_id: usize,
|
|
|
|
) -> Result<(), Error>
|
2019-03-17 22:14:58 +03:00
|
|
|
where
|
|
|
|
T: WalletBackend<C, K>,
|
|
|
|
C: NodeClient,
|
|
|
|
K: Keychain,
|
|
|
|
{
|
2019-05-23 18:27:57 +03:00
|
|
|
let context = w.get_private_context(slate.id.as_bytes(), participant_id)?;
|
2019-03-17 22:14:58 +03:00
|
|
|
selection::lock_tx_context(&mut *w, slate, &context)
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Finalize slate
|
2019-03-22 15:03:25 +03:00
|
|
|
pub fn finalize_tx<T: ?Sized, C, K>(w: &mut T, slate: &Slate) -> Result<Slate, Error>
|
2019-03-17 22:14:58 +03:00
|
|
|
where
|
|
|
|
T: WalletBackend<C, K>,
|
|
|
|
C: NodeClient,
|
|
|
|
K: Keychain,
|
|
|
|
{
|
2019-03-22 15:03:25 +03:00
|
|
|
let mut sl = slate.clone();
|
2019-05-23 18:27:57 +03:00
|
|
|
let context = w.get_private_context(sl.id.as_bytes(), 0)?;
|
2019-03-22 15:03:25 +03:00
|
|
|
tx::complete_tx(&mut *w, &mut sl, 0, &context)?;
|
2019-05-01 22:12:23 +03:00
|
|
|
tx::update_stored_tx(&mut *w, &mut sl, false)?;
|
2019-03-22 15:03:25 +03:00
|
|
|
tx::update_message(&mut *w, &mut sl)?;
|
2019-03-17 22:14:58 +03:00
|
|
|
{
|
|
|
|
let mut batch = w.batch()?;
|
2019-05-23 18:27:57 +03:00
|
|
|
batch.delete_private_context(sl.id.as_bytes(), 0)?;
|
2019-03-17 22:14:58 +03:00
|
|
|
batch.commit()?;
|
|
|
|
}
|
2019-03-22 15:03:25 +03:00
|
|
|
Ok(sl)
|
2019-03-17 22:14:58 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/// cancel tx
|
|
|
|
pub fn cancel_tx<T: ?Sized, C, K>(
|
|
|
|
w: &mut T,
|
|
|
|
tx_id: Option<u32>,
|
|
|
|
tx_slate_id: Option<Uuid>,
|
|
|
|
) -> Result<(), Error>
|
|
|
|
where
|
|
|
|
T: WalletBackend<C, K>,
|
|
|
|
C: NodeClient,
|
|
|
|
K: Keychain,
|
|
|
|
{
|
|
|
|
let parent_key_id = w.parent_key_id();
|
|
|
|
if !update_outputs(w, false) {
|
|
|
|
return Err(ErrorKind::TransactionCancellationError(
|
|
|
|
"Can't contact running Grin node. Not Cancelling.",
|
|
|
|
))?;
|
|
|
|
}
|
|
|
|
tx::cancel_tx(&mut *w, &parent_key_id, tx_id, tx_slate_id)
|
|
|
|
}
|
|
|
|
|
|
|
|
/// get stored tx
|
|
|
|
pub fn get_stored_tx<T: ?Sized, C, K>(
|
|
|
|
w: &T,
|
|
|
|
entry: &TxLogEntry,
|
|
|
|
) -> Result<Option<Transaction>, Error>
|
|
|
|
where
|
|
|
|
T: WalletBackend<C, K>,
|
|
|
|
C: NodeClient,
|
|
|
|
K: Keychain,
|
|
|
|
{
|
|
|
|
w.get_stored_tx(entry)
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Posts a transaction to the chain
|
|
|
|
/// take a client impl instead of wallet so as not to have to lock the wallet
|
|
|
|
pub fn post_tx<C>(client: &C, tx: &Transaction, fluff: bool) -> Result<(), Error>
|
|
|
|
where
|
|
|
|
C: NodeClient,
|
|
|
|
{
|
2019-03-26 19:02:31 +03:00
|
|
|
let tx_hex = grin_util::to_hex(ser::ser_vec(tx).unwrap());
|
2019-03-17 22:14:58 +03:00
|
|
|
let res = client.post_tx(&TxWrapper { tx_hex: tx_hex }, fluff);
|
|
|
|
if let Err(e) = res {
|
|
|
|
error!("api: post_tx: failed with error: {}", e);
|
|
|
|
Err(e)
|
|
|
|
} else {
|
|
|
|
debug!(
|
|
|
|
"api: post_tx: successfully posted tx: {}, fluff? {}",
|
|
|
|
tx.hash(),
|
|
|
|
fluff
|
|
|
|
);
|
|
|
|
Ok(())
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/// verify slate messages
|
|
|
|
pub fn verify_slate_messages(slate: &Slate) -> Result<(), Error> {
|
|
|
|
slate.verify_messages()
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Attempt to restore contents of wallet
|
|
|
|
pub fn restore<T: ?Sized, C, K>(w: &mut T) -> Result<(), Error>
|
|
|
|
where
|
|
|
|
T: WalletBackend<C, K>,
|
|
|
|
C: NodeClient,
|
|
|
|
K: Keychain,
|
|
|
|
{
|
|
|
|
w.restore()
|
|
|
|
}
|
|
|
|
|
|
|
|
/// check repair
|
|
|
|
pub fn check_repair<T: ?Sized, C, K>(w: &mut T, delete_unconfirmed: bool) -> Result<(), Error>
|
|
|
|
where
|
|
|
|
T: WalletBackend<C, K>,
|
|
|
|
C: NodeClient,
|
|
|
|
K: Keychain,
|
|
|
|
{
|
|
|
|
update_outputs(w, true);
|
|
|
|
w.check_repair(delete_unconfirmed)
|
|
|
|
}
|
|
|
|
|
|
|
|
/// node height
|
2019-03-29 19:00:02 +03:00
|
|
|
pub fn node_height<T: ?Sized, C, K>(w: &mut T) -> Result<NodeHeightResult, Error>
|
2019-03-17 22:14:58 +03:00
|
|
|
where
|
|
|
|
T: WalletBackend<C, K>,
|
|
|
|
C: NodeClient,
|
|
|
|
K: Keychain,
|
|
|
|
{
|
|
|
|
let res = w.w2n_client().get_chain_height();
|
|
|
|
match res {
|
2019-03-29 19:00:02 +03:00
|
|
|
Ok(height) => Ok(NodeHeightResult {
|
|
|
|
height,
|
|
|
|
updated_from_node: true,
|
|
|
|
}),
|
2019-03-17 22:14:58 +03:00
|
|
|
Err(_) => {
|
|
|
|
let outputs = retrieve_outputs(w, true, false, None)?;
|
2019-03-22 15:03:25 +03:00
|
|
|
let height = match outputs.1.iter().map(|m| m.output.height).max() {
|
2019-03-17 22:14:58 +03:00
|
|
|
Some(height) => height,
|
|
|
|
None => 0,
|
|
|
|
};
|
2019-03-29 19:00:02 +03:00
|
|
|
Ok(NodeHeightResult {
|
|
|
|
height,
|
|
|
|
updated_from_node: false,
|
|
|
|
})
|
2019-03-17 22:14:58 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Attempt to update outputs in wallet, return whether it was successful
|
|
|
|
fn update_outputs<T: ?Sized, C, K>(w: &mut T, update_all: bool) -> bool
|
|
|
|
where
|
|
|
|
T: WalletBackend<C, K>,
|
|
|
|
C: NodeClient,
|
|
|
|
K: Keychain,
|
|
|
|
{
|
|
|
|
let parent_key_id = w.parent_key_id();
|
|
|
|
match updater::refresh_outputs(&mut *w, &parent_key_id, update_all) {
|
|
|
|
Ok(_) => true,
|
|
|
|
Err(_) => false,
|
|
|
|
}
|
|
|
|
}
|