Class: Glueby::Internal::Wallet::AR::Wallet

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
lib/glueby/internal/wallet/active_record/wallet.rb

Instance Method Summary collapse

Instance Method Details

#sign(tx, prevtxs = [], sighashtype: ) ⇒ Object

Parameters:

  • tx (Tapyrus::Tx)
  • prevtxs (Array) (defaults to: [])

    array of outputs

  • sighashtype (Integer) (defaults to: )


17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/glueby/internal/wallet/active_record/wallet.rb', line 17

def sign(tx, prevtxs = [], sighashtype: Tapyrus::SIGHASH_TYPE[:all])
  validate_sighashtype!(sighashtype)

  tx.inputs.each.with_index do |input, index|
    script_pubkey = script_for_input(input, prevtxs)
    next unless script_pubkey
    key = keys.key_for_script(script_pubkey)
    next unless key
    sign_tx_for_p2pkh(tx, index, key, script_pubkey, sighashtype)
  end
  tx
end

#utxosObject



30
31
32
# File 'lib/glueby/internal/wallet/active_record/wallet.rb', line 30

def utxos
  Glueby::Internal::Wallet::AR::Utxo.where(key: keys)
end