Handkit.Wallet.pay
You're seeing just the function
pay
, go back to Handkit.Wallet module for more information.
Specs
pay(Handkit.Connect.t(), map()) :: {:ok, map()} | {:error, any()}
Constructs and executes a transaction on behalf of the connected user.
Payment parameters
The payment parameters are a map containing the following keys:
:app_action
- string used for transaction labeling and notification grouping:description
- max 25 character note describing the transaction:payments
- list of payment recipients:attachment
- parameters for a single data attachment output
Each payment recipient is a map containing the following keys:
:to
- recipient Handcash handle, paymail address or P2PKH Bitcoin address:currency_code
- recipient payment currency code:amount
- value of the payment measured in units of the specified currency code
If provided, the attachment parameters is a map containing the following keys:
:format
- format of the data from"base64"
,"hex"
,"hexArray"
or"json"
:value
- data value of the attachment in the specified format
Example
iex> payment_params = %{
...> app_action: "test",
...> attachment: %{
...> format: "json",
...> value: %{foo: "testing"}
...> },
...> description: "testing testing...",
...> payments: [%{
...> amount: 5,
...> currency_code: "DUR",
...> to: "Libs"
...> }]
...> }
iex> Handkit.Wallet.pay(client, payment_params)
{:ok, %{
"app_action" => "test",
"attachments" => [%{"format" => "json", "value" => %{"foo" => "testing"}}],
"fiat_currency_code" => "GBP",
"fiat_exchange_rate" => 115.93006376003423,
"note" => "testing testing...",
"participants" => [
%{
"alias" => "Libs",
"amount" => 2500,
"display_name" => "Libitx",
"profile_picture_url" => "https://www.gravatar.com/avatar/8c69771156957d453f9b74f9d57a523c?d=identicon",
"response_note" => "",
"type" => "user"
}
],
"raw_transaction_hex" => "0100000001b7acb150dc848a72e84c11d07b51d3b2fdb547fd98e1835b72a804b390c8c14c020000006a47304402204a4e5eb8da880821df2facc4f32d31481d5ceecbe714bb0de3d46c8ad9079f6a02203ab09fcab3bf235876c43c321bba9d3c916263fa93aab1ebab9ad5ddfbe2bc0b412102da3c986fc05050da02a2f5bd0143ab000467134e3c00460eb87977c7ada75bc6ffffffff03c4090000000000001976a91436795507d273218a19471fd863646a83525c67d188ac000000000000000014006a117b22666f6f223a2274657374696e67227db3080000000000001976a91420c908009397169108738ebe35cf53f70162501f88ac00000000",
"satoshi_amount" => 2500,
"satoshi_fees" => 128,
"time" => 1624025595,
"transaction_id" => "5a139f3f475f48001d733c8c767fa7124bb2835d927e01dd2782effd22f7081b",
"type" => "send"
}}