Bitcoin RPC v0.1.0 BitcoinRpc.Transactions View Source

BitcoinRpc.Transactions allows you to stay connected to an bitcoin wallet and be notified of incomming or outgoing transactions that affect that wallet.

Examples

Connect to the bitcoin node using the configured BitcoinRpc connection and listen for new transactions that affect the wallet since the “last_block” and check for new transactions every 60 seconds. The list of transactions will include all transactions with a number of confirmations lower or equal to the given confirmation number. This will cause some transactions to be received multiple times until the last_block is updated and the number of confirmations is above the threashold. See ListSinceBlock RPC method for more details.

iex> BitcoinRpc.Transactions.start_link([timeout: 60, last_block: "", confirmations: 1, callback: {MyModule, :handle_transaction}])
{:ok, pid}

MyModule looks something like this:

defmodule MyModule do

  def handle_transaction(transactions, last_block) do
    # do something with the transaction
    IO.inspect last_block
    IO.inspect transactions
  end

end

Link to this section Summary

Functions

Returns a specification to start this module under a supervisor

Handle ticker event and check for new transactions since the last scanned block

Initiate the scheduler and configure the initial state of the listener

Start listening for incomming transactions that can affect the current wallet

Link to this section Functions

Returns a specification to start this module under a supervisor.

See Supervisor.

Handle ticker event and check for new transactions since the last scanned block

Initiate the scheduler and configure the initial state of the listener

Link to this function start_link(opts \\ [timeout: 60, last_block: "", confirmations: 1]) View Source

Start listening for incomming transactions that can affect the current wallet

iex> BitcoinRpc.Transactions.start_link([timeout: 60, last_block: "", confirmations: 1, callback: {MyModule, :handle_transaction}])
{:ok, pid}