class Arweave::Wallet

Attributes

address[R]
api[R]
jwk[R]
owner[R]

Public Class Methods

new(jwk) click to toggle source
# File lib/arweave/wallet.rb, line 10
def initialize(jwk)
  @api = Api.instance
  @jwk = jwk.transform_keys!(&:to_sym)
end

Public Instance Methods

balance() click to toggle source
# File lib/arweave/wallet.rb, line 34
def balance
  balance_in_winstons = BigDecimal(api.get_wallet_balance(address).body)

  OpenStruct.new(
    ar: balance_in_winstons / 1e12,
    winston: balance_in_winstons
  )
end
last_transaction_id() click to toggle source
# File lib/arweave/wallet.rb, line 43
def last_transaction_id
  api.get_last_transaction_id(address).body
end
sign(message) click to toggle source
# File lib/arweave/wallet.rb, line 26
def sign(message)
  private_key.sign_pss(
    'SHA256',
    message,
    salt_length: 0, mgf1_hash: 'SHA256'
  )
end

Private Instance Methods

private_key() click to toggle source
# File lib/arweave/wallet.rb, line 51
def private_key
  JSON::JWK.new(jwk).to_key
end