Class: Bitcoin::Wallet::UtxoHandler
- Inherits:
-
Concurrent::Actor::Context
- Object
- Concurrent::Actor::Context
- Bitcoin::Wallet::UtxoHandler
- Defined in:
- lib/bitcoin/wallet/utxo_handler.rb
Instance Attribute Summary collapse
-
#pendings ⇒ Object
readonly
Returns the value of attribute pendings.
-
#publisher ⇒ Object
readonly
Returns the value of attribute publisher.
-
#spv ⇒ Object
readonly
Returns the value of attribute spv.
-
#utxo_db ⇒ Object
readonly
Returns the value of attribute utxo_db.
-
#watchings ⇒ Object
readonly
Returns the value of attribute watchings.
Instance Method Summary collapse
-
#initialize(spv, publisher) ⇒ UtxoHandler
constructor
A new instance of UtxoHandler.
- #on_message(message) ⇒ Object
- #update(event, data) ⇒ Object
Constructor Details
#initialize(spv, publisher) ⇒ UtxoHandler
Returns a new instance of UtxoHandler.
6 7 8 9 10 11 12 13 14 |
# File 'lib/bitcoin/wallet/utxo_handler.rb', line 6 def initialize(spv, publisher) @watchings = [] @pendings = [] @spv = spv @spv.add_observer(self) @utxo_db = spv.wallet.utxo_db @publisher = publisher end |
Instance Attribute Details
#pendings ⇒ Object (readonly)
Returns the value of attribute pendings.
4 5 6 |
# File 'lib/bitcoin/wallet/utxo_handler.rb', line 4 def pendings @pendings end |
#publisher ⇒ Object (readonly)
Returns the value of attribute publisher.
4 5 6 |
# File 'lib/bitcoin/wallet/utxo_handler.rb', line 4 def publisher @publisher end |
#spv ⇒ Object (readonly)
Returns the value of attribute spv.
4 5 6 |
# File 'lib/bitcoin/wallet/utxo_handler.rb', line 4 def spv @spv end |
#utxo_db ⇒ Object (readonly)
Returns the value of attribute utxo_db.
4 5 6 |
# File 'lib/bitcoin/wallet/utxo_handler.rb', line 4 def utxo_db @utxo_db end |
#watchings ⇒ Object (readonly)
Returns the value of attribute watchings.
4 5 6 |
# File 'lib/bitcoin/wallet/utxo_handler.rb', line 4 def watchings @watchings end |
Instance Method Details
#on_message(message) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/bitcoin/wallet/utxo_handler.rb', line 20 def () case when Bitcoin::Grpc::WatchTxConfirmedRequest spv.filter_add(.tx_hash) watchings << when Bitcoin::Grpc::WatchUtxoSpentRequest outpoint = Bitcoin::OutPoint.new(.tx_hash, .output_index) spv.filter_add(outpoint.to_payload.bth) watchings << when :watchings watchings end end |
#update(event, data) ⇒ Object
16 17 18 |
# File 'lib/bitcoin/wallet/utxo_handler.rb', line 16 def update(event, data) send(event, data) end |