Module: BSV::Wallet::Client::Network

Included in:
BSV::Wallet::Client
Defined in:
lib/bsv/wallet/client/brc100/network.rb

Overview

Blockchain and network data methods for BSV::Wallet::Client.

Instance Method Summary collapse

Instance Method Details

#get_header_for_height(args, originator: nil) ⇒ Hash

Returns the block header at the given height.

Requires a substrate — raises UnsupportedActionError locally.

Parameters:

  • args (Hash)

Options Hash (args):

  • :height (Integer)

    block height

Returns:

  • (Hash)

    { header: String } 80-byte hex-encoded block header

Raises:



26
27
28
29
30
# File 'lib/bsv/wallet/client/brc100/network.rb', line 26

def get_header_for_height(args, originator: nil)
  return @substrate.get_header_for_height(args, originator: originator) if @substrate

  raise UnsupportedActionError, 'get_header_for_height requires a remote substrate'
end

#get_height(args = {}, originator: nil) ⇒ Hash

Returns the current blockchain height.

Requires a substrate — raises UnsupportedActionError locally.

Returns:

  • (Hash)

    { height: Integer }

Raises:



13
14
15
16
17
# File 'lib/bsv/wallet/client/brc100/network.rb', line 13

def get_height(args = {}, originator: nil)
  return @substrate.get_height(args, originator: originator) if @substrate

  raise UnsupportedActionError, 'get_height requires a remote substrate'
end

#get_network(args = {}, originator: nil) ⇒ Hash

Returns the network this wallet is configured for.

Returns:

  • (Hash)

    { network: String } ‘mainnet’ or ‘testnet’



35
36
37
38
39
# File 'lib/bsv/wallet/client/brc100/network.rb', line 35

def get_network(args = {}, originator: nil)
  return @substrate.get_network(args, originator: originator) if @substrate

  { network: @network }
end

#get_version(args = {}, originator: nil) ⇒ Hash

Returns the wallet version string.

Returns:

  • (Hash)

    { version: String } in vendor-major.minor.patch format



44
45
46
47
48
# File 'lib/bsv/wallet/client/brc100/network.rb', line 44

def get_version(args = {}, originator: nil)
  return @substrate.get_version(args, originator: originator) if @substrate

  { version: "bsv-wallet-#{BSV::Wallet::VERSION}" }
end