Class: BSV::Wallet::Postgres::Action
- Inherits:
-
Sequel::Model
- Object
- Sequel::Model
- BSV::Wallet::Postgres::Action
- Includes:
- Fetchable, DisplayTxid
- Defined in:
- lib/bsv/wallet/postgres/action.rb
Instance Method Summary collapse
-
#derived_status ⇒ Symbol
Derive BRC-100 status from structural state.
- #fetch_args ⇒ Object
-
#fetch_command ⇒ Object
– Fetchable contract –.
- #needs_fetch? ⇒ Boolean
-
#write!(response) ⇒ Object
Create a TxProof from the network response when proof data is present.
Methods included from DisplayTxid
Instance Method Details
#derived_status ⇒ Symbol
Derive BRC-100 status from structural state. No status column — the database structure IS the state.
24 25 26 27 28 29 30 31 32 |
# File 'lib/bsv/wallet/postgres/action.rb', line 24 def derived_status return :unsigned if wtxid.nil? return :completed if tx_proof_id return :nosend if values[:broadcast] == 'none' return :unproven unless outputs_dataset.empty? return :failed if broadcast_entry&.tx_status == 'REJECTED' return :sending if broadcast_entry :unprocessed end |
#fetch_args ⇒ Object
40 41 42 |
# File 'lib/bsv/wallet/postgres/action.rb', line 40 def fetch_args { txid: dtxid } end |
#fetch_command ⇒ Object
– Fetchable contract –
36 37 38 |
# File 'lib/bsv/wallet/postgres/action.rb', line 36 def fetch_command :get_tx_status end |
#needs_fetch? ⇒ Boolean
44 45 46 |
# File 'lib/bsv/wallet/postgres/action.rb', line 44 def needs_fetch? outgoing && !wtxid.nil? && tx_proof_id.nil? end |
#write!(response) ⇒ Object
Create a TxProof from the network response when proof data is present. No-op when the transaction is not yet mined (no merkle_path/block_height).
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/bsv/wallet/postgres/action.rb', line 52 def write!(response) data = response.data return unless data.is_a?(Hash) && data[:merkle_path] && data[:block_height] proof_store = ProofStore.new proof_id = proof_store.save_proof( wtxid: wtxid, proof: { height: data[:block_height], block_hash: decode_hex(data[:block_hash]), merkle_path: decode_hex(data[:merkle_path]), raw_tx: raw_tx } ) update(tx_proof_id: proof_id) end |