crate::ix!();
pub enum DBErrors
{
LOAD_OK,
CORRUPT,
NONCRITICAL_ERROR,
TOO_NEW,
LOAD_FAIL,
NEED_REWRITE,
NEED_RESCAN
}
pub type WalletOrderForm = Vec<(String,String)>;
pub type WalletValueMap = HashMap<String,String>;
pub type CoinsList = HashMap<TxDestination,Vec<(OutPoint,WalletTxOut)>>;
pub type MapValue = HashMap<String,String>;
pub struct WalletTxInfo
{
tx: TransactionRef,
txin_is_mine: Vec<IsMineType>,
txout_is_mine: Vec<IsMineType>,
txout_address: Vec<TxDestination>,
txout_address_is_mine: Vec<IsMineType>,
credit: Amount,
debit: Amount,
change: Amount,
time: i64,
value_map: HashMap<String,String>,
is_coinbase: bool,
}
pub struct WalletTxStatus
{
block_height: i32,
blocks_to_maturity: i32,
depth_in_main_chain: i32,
time_received: u32,
lock_time: u32,
is_final: bool,
is_trusted: bool,
is_abandoned: bool,
is_coinbase: bool,
is_in_main_chain: bool,
}
pub struct WalletTxOut
{
txout: TxOut,
time: i64,
depth_in_main_chain: i32, is_spent: bool, }
#[no_copy]
pub struct WalletTx {
map_value: MapValue,
order_form: Vec<(String,String)>,
time_received_is_tx_time: u32,
n_time_received: u32,
n_time_smart: u32,
from_me: bool,
n_order_pos: i64,
it_wtx_ordered: Box<dyn Iterator<Item = (i64, *mut WalletTx)>>,
amounts: [RefCell<CachableAmount>; WalletTxAmountType::AMOUNTTYPE_ENUM_ELEMENTS as usize],
is_cache_empty: RefCell<bool>,
change_cached: RefCell<bool>,
in_mempool: RefCell<bool>,
n_change_cached: RefCell<Amount>,
tx: TransactionRef,
confirm: WalletTxConfirmation,
}
pub const WALLET_TX_ABANDON_HASH: u256 = u256::ONE;
pub enum WalletTxAmountType {
DEBIT,
CREDIT,
IMMATURE_CREDIT,
AVAILABLE_CREDIT,
AMOUNTTYPE_ENUM_ELEMENTS
}
pub enum WalletTxStatusCode {
UNCONFIRMED,
CONFIRMED,
CONFLICTED,
ABANDONED
}
pub struct WalletTxConfirmation {
status: WalletTxStatus,
block_height: i32,
hash_block: u256,
n_index: i32,
}
impl WalletTxConfirmation {
pub fn new(
status: Option<WalletTxStatusCode>,
block_height: Option<i32>,
block_hash: Option<u256>,
block_index: Option<i32>) -> Self {
let status: WalletTxStatusCode = status.unwrap_or(WalletTxStatusCode::UNCONFIRMED);
let block_height: i32 = block_height.unwrap_or(0);
let block_hash: u256 = block_hash.unwrap_or(u256::ZERO);
let block_index: i32 = block_index.unwrap_or(0);
todo!();
}
}
impl WalletTx {
pub fn new(arg: TransactionRef) -> Self {
todo!();
}
pub fn init(&mut self) {
todo!();
}
pub fn serialize<Stream>(&self, s: &mut Stream) {
todo!();
}
pub fn unserialize<Stream>(&mut self, s: &mut Stream) {
todo!();
}
pub fn set_tx(&mut self, arg: TransactionRef) {
todo!();
}
pub fn mark_dirty(&mut self) {
todo!();
}
pub fn is_abandoned(&self) -> bool {
todo!();
}
pub fn set_abandoned(&mut self) {
todo!();
}
pub fn is_conflicted(&self) -> bool {
todo!();
}
pub fn set_conflicted(&mut self) {
todo!();
}
pub fn is_unconfirmed(&self) -> bool {
todo!();
}
pub fn set_unconfirmed(&mut self) {
todo!();
}
pub fn is_confirmed(&self) -> bool {
todo!();
}
pub fn set_confirmed(&mut self) {
todo!();
}
pub fn get_hash(&self) -> &u256 {
todo!();
}
pub fn is_coinbase(&self) -> bool {
todo!();
}
pub fn is_equivalent_to(&self, tx: &WalletTx) -> bool {
todo!();
}
pub fn in_mempool(&self) -> bool {
todo!();
}
pub fn get_tx_time(&self) -> i64 {
todo!();
}
}
pub trait WalletInterface:
EncryptWallet
+ IsCrypted
+ Lock
+ Unlock
+ IsLocked
+ ChangeWalletPassphrase
+ AbortRescan
+ BackupWallet
+ GetWalletName
+ WalletGetNewDestination
+ GetPubKeyWithScriptAndAddress
+ SignMessage
+ IsSpendable
+ HaveWatchOnly
+ SetAddressBook
+ DelAddressBook
+ GetAddress
+ GetAddresses
+ GetAddressReceiveRequests
+ SetAddressReceiveRequest
+ DisplayAddress
+ LockCoin
+ UnlockCoin
+ IsLockedCoin
+ ListLockedCoins
+ CreateTransaction
+ CommitTransaction
+ TransactionCanBeAbandoned
+ AbandonTransaction
+ TransactionCanBeBumped
+ CreateBumpTransaction
+ SignBumpTransaction
+ CommitBumpTransaction
+ GetTx
+ GetWalletTx
+ GetWalletTxs
+ TryGetTxStatus
+ GetWalletTxDetails
+ WalletFillPSBT
+ GetBalances
+ TryGetBalances
+ GetBalance
+ GetAvailableBalance
+ TxinIsMine
+ TxoutIsMine
+ GetDebit
+ GetCredit
+ ListCoins
+ GetCoins
+ GetRequiredFee
+ GetMinimumFee
+ GetConfirmTarget
+ HdEnabled
+ CanGetAddresses
+ PrivateKeysDisabled
+ HasExternalSigner
+ GetDefaultAddressType
+ GetDefaultMaxTxFee
+ Remove
+ IsLegacy
+ HandleUnload
+ HandleShowProgress<Callback = WalletShowProgressFn>
+ HandleStatusChanged
+ HandleAddressBookChanged
+ HandleTransactionChanged
+ HandleWatchOnlyChanged
+ HandleCanGetAddressesChanged
+ GetWallet { }
pub trait EncryptWallet {
fn encrypt_wallet(&mut self, wallet_passphrase: &SecureString) -> bool;
}
pub trait IsCrypted {
fn is_crypted(&self) -> bool;
}
pub trait Lock {
fn lock(&mut self) -> bool;
}
pub trait Unlock {
fn unlock(&mut self,
wallet_passphrase: &SecureString,
accept_no_keys: Option<bool>) -> bool;
}
pub trait IsLocked {
fn is_locked(&self) -> bool;
}
pub trait ChangeWalletPassphrase {
fn change_wallet_passphrase(&mut self,
old_wallet_passphrase: &SecureString,
new_wallet_passphrase: &SecureString) -> bool;
}
pub trait AbortRescan {
fn abort_rescan(&mut self);
}
pub trait BackupWallet {
fn backup_wallet(&self, filename: &String) -> bool;
}
pub trait GetWalletName {
fn get_wallet_name(&mut self) -> String;
}
pub trait WalletGetNewDestination {
fn get_new_destination(&mut self,
ty: OutputType,
label: String,
dest: &mut TxDestination,
error: &mut BilingualStr) -> bool;
}
pub trait GetPubKeyWithScriptAndAddress {
fn get_pub_key_with_script_and_address(&mut self,
script: &Script,
address: &KeyID,
pub_key: &mut PubKey) -> bool;
}
pub trait SignMessage {
fn sign_message(&self,
message: &String,
pkhash: &PKHash,
str_sig: &mut String) -> SigningResult;
}
pub trait IsSpendable {
fn is_spendable(&mut self, dest: &TxDestination) -> bool;
}
pub trait HaveWatchOnly {
fn have_watch_only(&mut self) -> bool;
}
pub trait SetAddressBook {
fn set_address_book(&mut self,
dest: &TxDestination,
name: &String,
purpose: &String) -> bool;
}
pub trait DelAddressBook {
fn del_address_book(&mut self, address: &TxDestination) -> bool;
}
pub trait GetAddress {
fn get_address(&mut self,
dest: &TxDestination,
name: *mut String,
is_mine: *mut IsMineType,
purpose: *mut String) -> bool;
}
pub trait GetAddresses {
fn get_addresses(&mut self) -> Vec<WalletAddress>;
}
pub trait GetAddressReceiveRequests {
fn get_address_receive_requests(&self) -> Vec<String>;
}
pub trait SetAddressReceiveRequest {
fn set_address_receive_request(&mut self,
dest: &TxDestination,
id: &String,
value: &String) -> bool;
}
pub trait DisplayAddress {
fn display_address(&mut self, dest: &TxDestination) -> bool;
}
pub trait LockCoin {
fn lock_coin(&mut self,
output: &OutPoint,
write_to_db: bool) -> bool {
false
}
fn lock_coin_with_batch(&mut self,
output: &OutPoint,
batch: Option<*mut WalletBatch>) -> bool {
false
}
}
pub trait UnlockCoin {
fn unlock_coin(&mut self, output: &OutPoint) -> bool;
}
pub trait IsLockedCoin {
fn is_locked_coin(&mut self, output: &OutPoint) -> bool;
}
pub trait ListLockedCoins {
fn list_locked_coins(&self, outpts: &mut Vec<OutPoint>);
}
pub trait CreateTransaction {
fn create_transaction(&mut self,
recipients: &Vec<Recipient>,
coin_control: &CoinControl,
sign: bool,
change_pos: &mut i32,
fee: &mut Amount,
fail_reason: &mut BilingualStr) -> TransactionRef;
}
pub trait CommitTransaction {
fn commit_transaction(&mut self,
tx: TransactionRef,
value_map: WalletValueMap,
order_form: WalletOrderForm);
}
pub trait TransactionCanBeAbandoned {
fn transaction_can_be_abandoned(&self, txid: &u256) -> bool;
}
pub trait AbandonTransaction {
fn abandon_transaction(&mut self, hash_tx: &u256) -> bool;
}
pub trait TransactionCanBeBumped {
fn transaction_can_be_bumped(&self, txid: &u256) -> bool;
}
pub trait CreateBumpTransaction {
fn create_bump_transaction(&mut self,
txid: &u256,
coin_control: &CoinControl,
errors: &mut Vec<BilingualStr>,
old_fee: &mut Amount,
new_fee: &mut Amount,
mtx: &mut MutableTransaction) -> bool;
}
pub trait SignBumpTransaction {
fn sign_bump_transaction(&mut self, mtx: &mut MutableTransaction) -> bool;
}
pub trait CommitBumpTransaction {
fn commit_bump_transaction(&mut self,
txid: &u256,
mtx: MutableTransaction,
errors: &mut Vec<BilingualStr>,
bumped_txid: &mut u256) -> bool;
}
pub trait GetTx {
fn get_tx(&mut self, txid: &u256) -> TransactionRef;
}
pub trait GetWalletTx {
fn get_wallet_tx(&self, txid: &u256) -> WalletTx;
}
pub trait GetWalletTxs {
fn get_wallet_txs(&mut self) -> Vec<WalletTx>;
}
pub trait TryGetTxStatus {
fn try_get_tx_status(&mut self,
txid: &u256,
tx_status: &mut WalletTxStatus,
num_blocks: &mut i32,
block_time: &mut i64) -> bool;
}
pub trait GetWalletTxDetails {
fn get_wallet_tx_details(&mut self,
txid: &u256,
tx_status: &mut WalletTxStatus,
order_form: &mut WalletOrderForm,
in_mempool: &mut bool,
num_blocks: &mut i32) -> WalletTx;
}
pub trait WalletFillPSBT {
fn fill_psbt(&mut self,
sighash_type: i32,
sign: bool,
bip_32derivs: bool,
n_signed: *mut usize,
psbtx: &mut PartiallySignedTransaction,
complete: &mut bool) -> TransactionError;
}
pub trait GetBalances {
fn get_balances(&mut self) -> WalletBalances;
}
pub trait TryGetBalances {
fn try_get_balances(&mut self,
balances: &mut WalletBalances,
block_hash: &mut u256) -> bool;
}
pub trait GetBalance {
fn get_balance(&mut self) -> Amount;
}
pub trait GetAvailableBalance {
fn get_available_balance(&mut self, coin_control: &CoinControl) -> Amount;
}
pub trait TxinIsMine {
fn txin_is_mine(&mut self, txin: &TxIn) -> IsMineType;
}
pub trait TxoutIsMine {
fn txout_is_mine(&mut self, txout: &TxOut) -> IsMineType;
}
pub trait GetDebit {
fn get_debit(&mut self,
txin: &TxIn,
filter: IsMineFilter) -> Amount;
}
pub trait GetCredit {
fn get_credit(&mut self,
txout: &TxOut,
filter: IsMineFilter) -> Amount;
}
pub trait ListCoins {
fn list_coins(&mut self) -> CoinsList;
}
pub trait GetCoins {
fn get_coins(&mut self, outputs: &Vec<OutPoint>) -> Vec<WalletTxOut>;
}
pub trait GetRequiredFee {
fn get_required_fee(&mut self, tx_bytes: u32) -> Amount;
}
pub trait GetMinimumFee {
fn get_minimum_fee(&mut self,
tx_bytes: u32,
coin_control: &CoinControl,
returned_target: *mut i32,
reason: *mut FeeReason) -> Amount;
}
pub trait GetConfirmTarget {
fn get_confirm_target(&mut self) -> u32;
}
pub trait HdEnabled {
fn hd_enabled(&mut self) -> bool;
}
pub trait CanGetAddresses {
fn can_get_addresses(&self, internal: Option<bool>) -> bool;
}
pub trait PrivateKeysDisabled {
fn private_keys_disabled(&mut self) -> bool;
}
pub trait HasExternalSigner {
fn has_external_signer(&mut self) -> bool;
}
pub trait GetDefaultAddressType {
fn get_default_address_type(&mut self) -> OutputType;
}
pub trait GetDefaultMaxTxFee {
fn get_default_max_tx_fee(&mut self) -> Amount;
}
pub trait Remove {
fn remove(&mut self);
}
pub trait IsLegacy {
fn is_legacy(&self) -> bool;
}
pub trait HandleUnload {
fn handle_unload(&mut self, fn_: WalletUnloadFn) -> Box<dyn Handler>;
}
pub trait HandleShowProgress {
type Callback;
fn handle_show_progress(&mut self, fn_: Self::Callback) -> Box<dyn Handler>;
}
pub trait HandleStatusChanged {
fn handle_status_changed(&mut self, fn_: WalletStatusChangedFn) -> Box<dyn Handler>;
}
pub trait HandleAddressBookChanged {
fn handle_address_book_changed(&mut self, fn_: WalletAddressBookChangedFn) -> Box<dyn Handler>;
}
pub trait HandleTransactionChanged {
fn handle_transaction_changed(&mut self, fn_: WalletTransactionChangedFn) -> Box<dyn Handler>;
}
pub trait HandleWatchOnlyChanged {
fn handle_watch_only_changed(&mut self, fn_: WalletWatchOnlyChangedFn) -> Box<dyn Handler>;
}
pub trait HandleCanGetAddressesChanged {
fn handle_can_get_addresses_changed(&mut self, fn_: WalletCanGetAddressesChangedFn) -> Box<dyn Handler>;
}
pub trait GetWallet {
fn wallet(&mut self) -> Rc<RefCell<dyn WalletInterface>> {
todo!();
}
}
pub enum ChangeType {
CT_NEW,
CT_UPDATED,
CT_DELETED
}
impl Default for ChangeType {
fn default() -> Self {
ChangeType::CT_NEW
}
}
pub struct WalletBatch {
batch: Box<DatabaseBatch>,
database: Rc<RefCell<WalletDatabase>>,
}
impl WalletBatch {
pub fn writeic<K, T>(&mut self,
key: &K,
value: &T,
overwrite: Option<bool>) -> bool {
let overwrite: bool = overwrite.unwrap_or(true);
todo!();
}
pub fn eraseic<K>(&mut self, key: &K) -> bool {
todo!();
}
pub fn new(
database: &mut WalletDatabase,
flush_on_close: Option<bool>) -> Self {
let flush_on_close: bool = flush_on_close.unwrap_or(true);
todo!();
}
pub fn write_name(&mut self,
str_address: &str,
str_name: &str) -> bool {
todo!();
}
pub fn erase_name(&mut self, str_address: &String) -> bool {
todo!();
}
pub fn write_purpose(&mut self,
str_address: &String,
str_purpose: &String) -> bool {
todo!();
}
pub fn erase_purpose(&mut self, str_address: &String) -> bool {
todo!();
}
pub fn write_tx(&mut self, wtx: &WalletTx) -> bool {
todo!();
}
pub fn erase_tx(&mut self, hash: u256) -> bool {
todo!();
}
pub fn write_key_metadata(&mut self,
meta: &KeyMetadata,
pubkey: &PubKey,
overwrite: bool) -> bool {
todo!();
}
pub fn write_key(&mut self,
vch_pub_key: &PubKey,
vch_priv_key: &PrivKey,
key_meta: &KeyMetadata) -> bool {
todo!();
}
pub fn write_crypted_key(&mut self,
vch_pub_key: &PubKey,
vch_crypted_secret: &Vec<u8>,
key_meta: &KeyMetadata) -> bool {
todo!();
}
pub fn write_master_key(&mut self,
nid: u32,
k_master_key: &MasterKey) -> bool {
todo!();
}
pub fn write_cscript(&mut self,
hash: &u160,
redeem_script: &Script) -> bool {
todo!();
}
pub fn write_watch_only(&mut self,
dest: &Script,
key_meta: &KeyMetadata) -> bool {
todo!();
}
pub fn erase_watch_only(&mut self, dest: &Script) -> bool {
todo!();
}
pub fn write_best_block(&mut self, locator: &BlockLocator) -> bool {
todo!();
}
pub fn read_best_block(&mut self, locator: &mut BlockLocator) -> bool {
todo!();
}
pub fn write_order_pos_next(&mut self, n_order_pos_next: i64) -> bool {
todo!();
}
pub fn read_pool(&mut self,
n_pool: i64,
keypool: &mut KeyPool) -> bool {
todo!();
}
pub fn write_pool(&mut self,
n_pool: i64,
keypool: &KeyPool) -> bool {
todo!();
}
pub fn erase_pool(&mut self, n_pool: i64) -> bool {
todo!();
}
pub fn write_min_version(&mut self, n_version: i32) -> bool {
todo!();
}
pub fn write_active_script_pub_key_man(&mut self,
ty: u8,
id: &u256,
internal: bool) -> bool {
todo!();
}
pub fn erase_active_script_pub_key_man(&mut self,
ty: u8,
internal: bool) -> bool {
todo!();
}
pub fn write_descriptor_key(&mut self,
desc_id: &u256,
pubkey: &PubKey,
privkey: &PrivKey) -> bool {
todo!();
}
pub fn write_crypted_descriptor_key(&mut self,
desc_id: &u256,
pubkey: &PubKey,
secret: &Vec<u8>) -> bool {
todo!();
}
pub fn write_descriptor(&mut self,
desc_id: &u256,
descriptor: &WalletDescriptor) -> bool {
todo!();
}
pub fn write_descriptor_derived_cache(&mut self,
xpub: &ExtPubKey,
desc_id: &u256,
key_exp_index: u32,
der_index: u32) -> bool {
todo!();
}
pub fn write_descriptor_parent_cache(&mut self,
xpub: &ExtPubKey,
desc_id: &u256,
key_exp_index: u32) -> bool {
todo!();
}
pub fn write_descriptor_last_hardened_cache(&mut self,
xpub: &ExtPubKey,
desc_id: &u256,
key_exp_index: u32) -> bool {
todo!();
}
pub fn write_descriptor_cache_items(&mut self,
desc_id: &u256,
cache: &DescriptorCache) -> bool {
todo!();
}
pub fn write_lockedutxo(&mut self, output: &OutPoint) -> bool {
todo!();
}
pub fn erase_lockedutxo(&mut self, output: &OutPoint) -> bool {
todo!();
}
pub fn is_key_type(&mut self, str_type: &String) -> bool {
todo!();
}
pub fn load_wallet(&mut self, pwallet: &mut dyn WalletInterface) -> DBErrors {
todo!();
}
pub fn find_wallet_tx(&mut self,
tx_hash: &mut Vec<u256>,
wtx: &mut LinkedList<WalletTx>) -> DBErrors {
todo!();
}
pub fn zap_select_tx(&mut self,
tx_hash_in: &mut Vec<u256>,
tx_hash_out: &mut Vec<u256>) -> DBErrors {
todo!();
}
pub fn write_dest_data(&mut self,
address: &String,
key: &String,
value: &String) -> bool {
todo!();
}
pub fn erase_dest_data(&mut self,
address: &String,
key: &String) -> bool {
todo!();
}
pub fn write_hd_chain(&mut self, chain: &HDChain) -> bool {
todo!();
}
pub fn write_wallet_flags(&mut self, flags: u64) -> bool {
todo!();
}
pub fn txn_begin(&mut self) -> bool {
todo!();
}
pub fn txn_commit(&mut self) -> bool {
todo!();
}
pub fn txn_abort(&mut self) -> bool {
todo!();
}
}
pub struct CoinControl {
dest_change: TxDestination,
change_type: Option<OutputType>,
add_inputs: bool,
include_unsafe_inputs: bool,
allow_other_inputs: bool,
allow_watch_only: bool,
override_fee_rate: bool,
feerate: Option<FeeRate>,
confirm_target: Option<u32>,
signal_bip125_rbf: Option<bool>,
avoid_partial_spends: bool,
avoid_address_reuse: bool,
fee_mode: FeeEstimateMode,
min_depth: i32,
max_depth: i32,
external_provider: FlatSigningProvider,
set_selected: HashSet<OutPoint>,
external_txouts: HashMap<OutPoint,TxOut>,
}
impl CoinControl {
pub fn has_selected(&self) -> bool {
todo!();
}
pub fn is_selected(&self, output: &OutPoint) -> bool {
todo!();
}
pub fn is_external_selected(&self, output: &OutPoint) -> bool {
todo!();
}
pub fn get_external_output(&self,
outpoint: &OutPoint,
txout: &mut TxOut) -> bool {
todo!();
}
pub fn select(&mut self, output: &OutPoint) {
todo!();
}
pub fn select_external(&mut self,
outpoint: &OutPoint,
txout: &TxOut) {
todo!();
}
pub fn un_select(&mut self, output: &OutPoint) {
todo!();
}
pub fn un_select_all(&mut self) {
todo!();
}
pub fn list_selected(&self, outpoints: &mut Vec<OutPoint>) {
todo!();
}
pub fn new() -> Self {
todo!();
}
}
#[Q_METATYPE]
pub struct WalletBalances {
balance: Amount, unconfirmed_balance: Amount, immature_balance: Amount, have_watch_only: bool, watch_only_balance: Amount, unconfirmed_watch_only_balance: Amount, immature_watch_only_balance: Amount, }
impl WalletBalances {
pub fn balance_changed(&self, prev: &WalletBalances) -> bool {
todo!();
}
}
pub struct DatabaseBatch {
}
pub trait DatabaseBatchInterface:
ReadKey
+ WriteKey
+ EraseKey
+ HasKey
+ Flush
+ Close
+ StartCursor
+ ReadAtCursor
+ CloseCursor
+ TxnBegin
+ TxnCommit
+ TxnAbort
{}
pub trait ReadKey {
fn read_key(&mut self,
key: DataStream,
value: &mut DataStream) -> bool;
}
pub trait WriteKey {
fn write_key(&mut self,
key: DataStream,
value: DataStream,
overwrite: bool) -> bool;
}
pub trait ReadAtCursor {
fn read_at_cursor(&mut self,
ss_key: &mut DataStream,
ss_value: &mut DataStream,
complete: &mut bool) -> bool;
}
pub trait EraseKey {
fn erase_key(&mut self, key: DataStream) -> bool;
}
pub trait HasKey {
fn has_key(&mut self, key: DataStream) -> bool;
}
pub trait StartCursor {
fn start_cursor(&mut self) -> bool;
}
pub trait CloseCursor {
fn close_cursor(&mut self);
}
pub trait TxnBegin {
fn txn_begin(&mut self) -> bool;
}
pub trait TxnCommit {
fn txn_commit(&mut self) -> bool;
}
pub trait TxnAbort {
fn txn_abort(&mut self) -> bool;
}
pub trait Open {
fn open(&mut self);
}
pub trait AddRef {
fn add_ref(&mut self);
}
pub trait RemoveRef {
fn remove_ref(&mut self);
}
pub trait Rewrite {
fn rewrite(&mut self, psz_skip: *const u8) -> bool;
}
pub trait Backup {
fn backup(&self, str_dest: &String) -> bool;
}
pub trait Close {
fn close(&mut self);
}
pub trait PeriodicFlush {
fn periodic_flush(&mut self) -> bool;
}
pub trait IncrementUpdateCounter {
fn increment_update_counter(&mut self);
}
pub trait ReloadDbEnv {
fn reload_db_env(&mut self);
}
pub trait Filename {
fn filename(&mut self) -> String;
}
pub trait Format {
fn format(&mut self) -> String;
}
pub trait MakeBatch {
fn make_batch(&mut self, flush_on_close: bool) -> Box<DatabaseBatch>;
}
impl DatabaseBatch {
pub fn read<K, T>(&mut self,
key: &K,
value: &mut T) -> bool {
todo!();
}
pub fn write<K, T>(&mut self,
key: &K,
value: &T,
overwrite: Option<bool>) -> bool {
let overwrite: bool = overwrite.unwrap_or(true);
todo!();
}
pub fn erase<K>(&mut self, key: &K) -> bool {
todo!();
}
pub fn exists<K>(&mut self, key: &K) -> bool {
todo!();
}
}
pub struct WalletDatabase {
refcount: Atomic<i32>,
n_update_counter: Atomic<u32>,
n_last_seen: u32,
n_last_flushed: u32,
n_last_wallet_update: i64,
}
pub trait WalletDatabaseInterface:
Open
+ AddRef
+ RemoveRef
+ Rewrite
+ Backup
+ Flush
+ Close
+ PeriodicFlush
+ IncrementUpdateCounter
+ ReloadDbEnv
+ Filename
+ Format
+ MakeBatch {}
impl Default for WalletDatabase {
fn default() -> Self {
todo!();
}
}
pub trait WalletStorage:
GetDisplayName
+ GetDatabase
+ IsWalletFlagSet
+ UnsetBlankWalletFlag
+ CanSupportFeature
+ SetMinVersion
+ GetEncryptionKey
+ HasEncryptionKeys
+ IsLocked { }
pub trait GetDisplayName {
fn get_display_name(&self) -> String;
}
pub trait GetDatabase {
fn get_database(&self) -> &mut WalletDatabase;
}
pub trait IsWalletFlagSet {
fn is_wallet_flag_set(&self, _0: u64) -> bool;
}
pub trait UnsetBlankWalletFlag {
fn unset_blank_wallet_flag(&mut self, _0: &mut WalletBatch);
}
pub trait CanSupportFeature {
fn can_support_feature(&self, _0: WalletFeature) -> bool;
}
pub trait SetMinVersion {
fn set_min_version(&mut self,
_0: WalletFeature,
_1: Option<*mut WalletBatch>);
}
pub trait GetEncryptionKey {
fn get_encryption_key(&self) -> &KeyingMaterial;
}
pub trait HasEncryptionKeys {
fn has_encryption_keys(&self) -> bool;
}
pub trait GetNewDestination {
fn get_new_destination(&mut self,
ty: OutputType,
dest: &mut TxDestination,
error: &mut BilingualStr) -> bool;
}
pub trait IsMine {
fn is_mine(&self, script: &Script) -> IsMineType;
}
pub trait CheckDecryptionKey {
fn check_decryption_key(&mut self,
master_key: &KeyingMaterial,
accept_no_keys: Option<bool>) -> bool;
}
pub trait Encrypt {
fn encrypt(&mut self,
master_key: &KeyingMaterial,
batch: *mut WalletBatch) -> bool;
}
pub trait GetReservedDestination {
fn get_reserved_destination(&mut self,
ty: OutputType,
internal: bool,
address: &mut TxDestination,
index: &mut i64,
keypool: &mut KeyPool,
error: &mut BilingualStr) -> bool;
}
pub trait KeepDestination {
fn keep_destination(&mut self,
index: i64,
ty: &OutputType);
}
pub trait ReturnDestination {
fn return_destination(&mut self,
index: i64,
internal: bool,
addr: &TxDestination);
}
pub trait TopUp {
fn top_up(&mut self, size: Option<u32>) -> bool;
}
pub trait MarkUnusedAddresses {
fn mark_unused_addresses(&mut self, script: &Script);
}
pub trait SetupGeneration {
fn setup_generation(&mut self, force: Option<bool>) -> bool;
}
pub trait IsHDEnabled {
fn is_hd_enabled(&self) -> bool;
}
pub trait Upgrade {
fn upgrade(&mut self,
prev_version: i32,
new_version: i32,
error: &mut BilingualStr) -> bool;
}
pub trait HavePrivateKeys {
fn have_private_keys(&self) -> bool;
}
pub trait RewriteDB {
fn rewritedb(&mut self);
}
pub trait GetOldestKeyPoolTime {
fn get_oldest_key_pool_time(&self) -> i64;
}
pub trait GetKeyPoolSize {
fn get_key_pool_size(&self) -> u32;
}
pub trait GetTimeFirstKey {
fn get_time_first_key(&self) -> i64;
}
pub trait GetMetadata {
fn get_metadata(&self,
dest: &TxDestination) -> Box<KeyMetadata>;
}
pub trait GetSolvingProvider {
fn get_solving_provider(&self,
script: &Script) -> Box<SigningProvider>;
}
pub trait CanProvide {
fn can_provide(&mut self,
script: &Script,
sigdata: &mut SignatureData) -> bool;
}
pub trait SignTransaction {
fn sign_transaction(&self,
tx: &mut MutableTransaction,
coins: &HashMap<OutPoint,Coin>,
sighash: i32,
input_errors: &mut HashMap<i32,BilingualStr>) -> bool;
}
pub trait FillPSBT {
fn fill_psbt(&self,
psbt: &mut PartiallySignedTransaction,
txdata: &PrecomputedTransactionData,
sighash_type: Option<i32>,
sign: Option<bool>,
bip_32derivs: Option<bool>,
n_signed: Option<*mut i32>) -> TransactionError;
}
pub trait GetID {
fn getid(&self) -> u256;
}
pub trait AddToSpendsWithOutpoint {
fn add_to_spends_with_outpoint(&mut self,
outpoint: &OutPoint,
wtxid: &u256,
batch: Option<*mut WalletBatch>);
}
pub trait AddToSpends {
fn add_to_spends(&mut self,
wtxid: &u256,
batch: Option<*mut WalletBatch>);
}
pub trait AddToWalletIfInvolvingMe {
fn add_to_wallet_if_involving_me(&mut self,
tx: &TransactionRef,
confirm: WalletTxConfirmation,
update: bool,
rescanning_old_block: bool) -> bool;
}
pub trait MarkConflicted {
fn mark_conflicted(&mut self,
hash_block: &u256,
conflicting_height: i32,
hash_tx: &u256);
}
pub trait MarkInputsDirty {
fn mark_inputs_dirty(&mut self, tx: &TransactionRef);
}
pub trait SyncMetaData {
fn sync_meta_data(&mut self, _0: (WalletTxSpendsIterator,WalletTxSpendsIterator));
}
pub trait SyncTransaction {
fn sync_transaction(&mut self,
tx: &TransactionRef,
confirm: WalletTxConfirmation,
update_tx: Option<bool>,
rescanning_old_block: Option<bool>);
}
pub trait SetAddressBookWithDB {
fn set_address_book_withdb(&mut self,
batch: &mut WalletBatch,
address: &TxDestination,
str_name: &str,
str_purpose: &str) -> bool;
}
pub trait UnsetWalletFlagWithDB {
fn unset_wallet_flag_withdb(&mut self,
batch: &mut WalletBatch,
flag: u64);
}
pub trait HaveChain {
fn have_chain(&self) -> bool;
}
pub trait GetTxConflicts {
fn get_tx_conflicts(&self, wtx: &WalletTx) -> HashSet<u256>;
}
pub trait GetTxDepthInMainChain {
fn get_tx_depth_in_main_chain(&self, wtx: &WalletTx) -> i32;
}
pub trait IsTxInMainChain {
fn is_tx_in_main_chain(&self, wtx: &WalletTx) -> bool;
}
pub trait GetTxBlocksToMaturity {
fn get_tx_blocks_to_maturity(&self, wtx: &WalletTx) -> i32;
}
pub trait IsTxImmatureCoinBase {
fn is_tx_immature_coin_base(&self, wtx: &WalletTx) -> bool;
}
pub trait IsSpent {
fn is_spent(&self,
hash: &u256,
n: u32) -> bool;
}
pub trait IsSpentKey {
fn is_spent_key(&self,
hash: &u256,
n: u32) -> bool;
}
pub trait SetSpentKeyState {
fn set_spent_key_state(&mut self,
batch: &mut WalletBatch,
hash: &u256,
n: u32,
used: bool,
tx_destinations: &mut HashSet<TxDestination>);
}
pub trait UnlockAllCoins {
fn unlock_all_coins(&mut self) -> bool;
}
pub trait IsAbortingRescan {
fn is_aborting_rescan(&self) -> bool;
}
pub trait IsScanning {
fn is_scanning(&self) -> bool;
}
pub trait ScanningDuration {
fn scanning_duration(&self) -> i64;
}
pub trait ScanningProgress {
fn scanning_progress(&self) -> f64;
}
pub trait UpgradeKeyMetadata {
fn upgrade_key_metadata(&mut self);
}
pub trait UpgradeDescriptorCache {
fn upgrade_descriptor_cache(&mut self);
}
pub trait LoadMinVersion {
fn load_min_version(&mut self, n_version: i32) -> bool;
}
pub trait LoadDestData {
fn load_dest_data(&mut self,
dest: &TxDestination,
key: &String,
value: &String);
}
pub trait GetKeyBirthTimes {
fn get_key_birth_times(&self, map_key_birth: &mut HashMap<KeyID,i64>);
}
pub trait ComputeTimeSmart {
fn compute_time_smart(&self,
wtx: &WalletTx,
rescanning_old_block: bool) -> u32;
}
pub trait IncOrderPosNext {
fn inc_order_pos_next(&mut self,
batch: Option<*mut WalletBatch>) -> i64;
}
pub trait ReorderTransactions {
fn reorder_transactions(&mut self) -> DBErrors;
}
pub trait MarkDirty {
fn mark_dirty(&mut self);
}
pub trait AddToWallet {
fn add_to_wallet(&mut self,
tx: TransactionRef,
confirm: &WalletTxConfirmation,
update_wtx: Option<&WalletUpdateWalletTxFn>,
flush_on_close: Option<bool>,
rescanning_old_block: Option<bool>) -> *mut WalletTx;
}
pub trait LoadToWallet {
fn load_to_wallet(&mut self,
hash: &u256,
fill_wtx: &WalletUpdateWalletTxFn) -> bool;
}
pub trait RescanFromTime {
fn rescan_from_time(&mut self,
start_time: i64,
reserver: &WalletRescanReserver,
update: bool) -> i64;
}
pub trait ScanForWalletTransactions {
fn scan_for_wallet_transactions(&mut self,
start_block: &u256,
start_height: i32,
max_height: Option<i32>,
reserver: &WalletRescanReserver,
update: bool) -> WalletScanResult;
}
pub trait ReacceptWalletTransactions {
fn reaccept_wallet_transactions(&mut self);
}
pub trait ResendWalletTransactions {
fn resend_wallet_transactions(&mut self);
}
pub trait TransactionChangeType {
fn transaction_change_type(&self,
change_type: &Option<OutputType>,
vec_send: &Vec<Recipient>) -> OutputType;
}
pub trait WalletSignTransaction {
fn sign_transaction(&self, tx: &mut MutableTransaction) -> bool;
}
pub trait SignTransactionGivenInputCoinsAndSighash {
fn sign_transaction_given_input_coins_and_sighash(&self,
tx: &mut MutableTransaction,
coins: &HashMap<OutPoint,Coin>,
sighash: i32,
input_errors: &mut HashMap<i32,BilingualStr>) -> bool;
}
pub trait SubmitTxMemoryPoolAndRelay {
fn submit_tx_memory_pool_and_relay(&self,
wtx: &WalletTx,
err_string: &mut String,
relay: bool) -> bool;
}
pub trait DummySignTx {
fn dummy_sign_tx(&self,
tx_new: &mut MutableTransaction,
txouts: &HashSet<TxOut>,
coin_control: Option<*const CoinControl>) -> bool;
}
pub trait ImportScripts {
fn import_scripts(&mut self,
scripts: HashSet<Script>,
timestamp: i64) -> bool;
}
pub trait ImportPrivKeys {
fn import_priv_keys(&mut self,
privkey_map: &HashMap<KeyID,Key>,
timestamp: i64) -> bool;
}
pub trait ImportPubKeys {
fn import_pub_keys(&mut self,
ordered_pubkeys: &Vec<KeyID>,
pubkey_map: &HashMap<KeyID,PubKey>,
key_origins: &HashMap<KeyID,(PubKey,KeyOriginInfo)>,
add_keypool: bool,
internal: bool,
timestamp: i64) -> bool;
}
pub trait ImportScriptPubKeys {
fn import_script_pub_keys(&mut self,
label: &String,
script_pub_keys: &HashSet<Script>,
have_solving_data: bool,
apply_label: bool,
timestamp: i64) -> bool;
}
pub trait KeypoolCountExternalKeys {
fn keypool_count_external_keys(&self) -> usize;
}
pub trait TopUpKeyPool {
fn top_up_key_pool(&mut self, kp_size: Option<u32>) -> bool;
}
pub trait GetLabelAddresses {
fn get_label_addresses(&self, label: &String) -> HashSet<TxDestination>;
}
pub trait MarkDestinationsDirty {
fn mark_destinations_dirty(&mut self, destinations: &HashSet<TxDestination>);
}
pub trait GetNewChangeDestination {
fn get_new_change_destination(&mut self,
ty: OutputType,
dest: &mut TxDestination,
error: &mut BilingualStr) -> bool;
}
pub trait IsMineWithTxDest {
fn is_mine_with_tx_dest(&self, dest: &TxDestination) -> IsMineType;
}
pub trait IsMineWithScript {
fn is_mine_with_script(&self, script: &Script) -> IsMineType;
}
pub trait GetDebitWithTxinAndFilter {
fn get_debit_with_txin_and_filter(&self,
txin: &TxIn,
filter: &IsMineFilter) -> Amount;
}
pub trait IsMineWithTxout {
fn is_mine_with_txout(&self, txout: &TxOut) -> IsMineType;
}
pub trait IsMineWithTx {
fn is_mine_with_tx(&self, tx: &Transaction) -> bool;
}
pub trait IsFromMe {
fn is_from_me(&self, tx: &Transaction) -> bool;
}
pub trait GetDebitWithTxAndFilter {
fn get_debit_with_tx_and_filter(&self,
tx: &Transaction,
filter: &IsMineFilter) -> Amount;
}
pub trait LoadWallet {
fn load_wallet(&mut self) -> DBErrors;
}
pub trait ZapSelectTx {
fn zap_select_tx(&mut self,
hash_in: &mut Vec<u256>,
hash_out: &mut Vec<u256>) -> DBErrors;
}
pub trait IsAddressUsed {
fn is_address_used(&self, dest: &TxDestination) -> bool;
}
pub trait SetAddressUsed {
fn set_address_used(&mut self,
batch: &mut WalletBatch,
dest: &TxDestination,
used: bool) -> bool;
}
pub trait GetVersion {
fn get_version(&self) -> i32;
}
pub trait GetConflicts {
fn get_conflicts(&self, txid: &u256) -> HashSet<u256>;
}
pub trait HasWalletSpend {
fn has_wallet_spend(&self, txid: &u256) -> bool;
}
pub trait GetBroadcastTransactions {
fn get_broadcast_transactions(&self) -> bool;
}
pub trait SetBroadcastTransactions {
fn set_broadcast_transactions(&mut self, broadcast: bool);
}
pub trait MarkReplaced {
fn mark_replaced(&mut self,
original_hash: &u256,
new_hash: &u256) -> bool;
}
pub trait PostInitProcess {
fn post_init_process(&mut self);
}
pub trait BlockUntilSyncedToCurrentChain {
fn block_until_synced_to_current_chain(&self);
}
pub trait SetWalletFlag {
fn set_wallet_flag(&mut self, flags: u64);
}
pub trait UnsetWalletFlag {
fn unset_wallet_flag(&mut self, flag: u64);
}
pub trait AddWalletFlags {
fn add_wallet_flags(&mut self, flags: u64) -> bool;
}
pub trait LoadWalletFlags {
fn load_wallet_flags(&mut self, flags: u64) -> bool;
}
pub trait WalletLogPrintf {
fn wallet_log_printf<Params>(&self,
fmt: String,
parameters: Params);
}
pub trait UpgradeWallet {
fn upgrade_wallet(&mut self,
version: i32,
error: &mut BilingualStr) -> bool;
}
pub trait GetSolvingProviderWithSigdata {
fn get_solving_provider_with_sigdata(&self,
script: &Script,
sigdata: &mut SignatureData) -> Box<SigningProvider>;
}
pub trait GetLastBlockHeight {
fn get_last_block_height(&self) -> i32;
}
pub trait GetLastBlockHash {
fn get_last_block_hash(&self) -> u256;
}
pub trait SetLastBlockProcessed {
fn set_last_block_processed(&mut self,
block_height: i32,
block_hash: u256);
}
pub trait SetAddressReceiveRequestWithBatch {
fn set_address_receive_request_with_batch(
&mut self,
batch: &mut WalletBatch,
dest: &TxDestination,
id: &String,
value: &String) -> bool;
}
pub trait UnlockCoinWithBatch {
fn unlock_coin_with_batch(&mut self,
output: &OutPoint,
batch: Option<*mut WalletBatch>) -> bool;
}
pub trait CheckIsLockedCoinWithHash {
fn check_is_locked_coin_with_hash(&self,
hash: u256,
n: u32) -> bool;
}
pub trait GetWalletTxPtr {
fn get_wallet_tx_ptr(&self, hash: &u256) -> *const WalletTx;
}
pub trait WalletCanGetAddresses {
fn can_get_addresses(&mut self) -> bool;
}
pub type WalletTxSpends = MultiMap<OutPoint,u256>;
pub type WalletTxSpendsIterator = (Rc<OutPoint>,Rc<u256>);
pub type WalletMasterKeyMap = HashMap<u32,MasterKey>;
pub type WalletTxItems = MultiMap<i64,*mut WalletTx>;
pub type WalletUpdateWalletTxFn = fn(wtx: &mut WalletTx, new_tx: bool) -> bool;
pub enum WalletScanResultStatus { SUCCESS, FAILURE, USER_ABORT }
pub struct WalletRescanReserver {
wallet: Rc<RefCell<dyn WalletInterface>>,
could_reserve: bool,
}
impl Drop for WalletRescanReserver {
fn drop(&mut self) {
todo!();
}
}
impl From<&mut dyn WalletInterface> for WalletRescanReserver {
fn from(w: &mut dyn WalletInterface) -> Self {
todo!();
}
}
impl WalletRescanReserver {
pub fn reserve(&mut self) -> bool {
todo!();
}
pub fn is_reserved(&self) -> bool {
todo!();
}
}
pub struct WalletScanResult {
status: WalletScanResultStatus,
last_scanned_block: u256,
last_scanned_height: Option<i32>,
last_failed_block: u256,
}
pub type LoadWalletFn = fn(wallet: Box<dyn WalletInterface>) -> ();