Class: Glueby::Internal::Wallet::MySQLWalletAdapter

Inherits:
ActiveRecordWalletAdapter show all
Defined in:
lib/glueby/internal/wallet/mysql_wallet_adapter.rb

Instance Method Summary collapse

Methods inherited from ActiveRecordWalletAdapter

#balance, #broadcast, #change_address, #create_pay_to_contract_address, #create_pubkey, #create_wallet, #delete_wallet, #get_addresses, #get_addresses_info, #has_address?, #list_unspent, #list_unspent_with_count, #load_wallet, #pay_to_contract_key, #receive_address, #sign_to_pay_to_contract_address, #sign_tx, #unload_wallet, #wallets

Methods inherited from AbstractWalletAdapter

#balance, #broadcast, #change_address, #create_pay_to_contract_address, #create_pubkey, #create_wallet, #delete_wallet, #get_addresses, #get_addresses_info, #has_address?, #list_unspent, #list_unspent_with_count, #load_wallet, #pay_to_contract_key, #receive_address, #sign_to_pay_to_contract_address, #sign_tx, #unload_wallet, #wallets

Instance Method Details

#lock_unspent(wallet_id, utxo) ⇒ Object



7
8
9
10
11
12
13
# File 'lib/glueby/internal/wallet/mysql_wallet_adapter.rb', line 7

def lock_unspent(wallet_id, utxo)
  ActiveRecord::Base.transaction(joinable: false, requires_new: true) do
    record = AR::Utxo.lock("FOR UPDATE SKIP LOCKED").find_by(txid: utxo[:txid], index: utxo[:vout], locked_at: nil)
    record&.update!(locked_at: Time.now)
    record
  end
end