CLI - wcgcyx/fcr GitHub Wiki

CLI

FCR CLI has a range of top level functions: Daemon, Wallet, CIDNet, PayNet, Peer, Retrieve, CacheRetrieve, FastRetrieve, System.

Daemon

This command starts a FCR daemon. By default, daemon will load the configuration file from ${HOME}/.fcr/config.yaml.

To specify a configuration file, use -c ${value} or --config ${value}.

Usage:

fcr daemon

Wallet

This command lists all wallet related functions.

Usage:

fcr wallet

Wallet set

This command sets the private key used by the wallet.

Usage:

fcr wallet set [currency id, key type, base64 key string]

Note: currency id right now by default is 1. Key type by default is also 1.

Wallet get

This command gets the public address stored by the wallet.

Usage:

fcr wallet get [currency id]

Wallet list

This command lists all keys stored by the wallet.

To list with details, use -l or --long.

Usage:

fcr wallet list -l

Wallet generate (Hidden)

This command generates a private key to use.

Usage:

fcr wallet generate [currency id]

Wallet retire (Hidden,Danger)

This command retires and removes a private key.

Usage:

fcr wallet retire [currency id]

Note: This is a DANGEROUS command. Your private key is your ID in the FCR network, if you retires a key while having active presense in the FCR network will likely to cause unexpected behaviour. (Loss of funds or reputation scores). You should ONLY use this command if you don't have any piece in serving or any payment channel in serving.

CIDNet

This command lists all CID Network (piece network) related functions.

Usage:

fcr cidnet

CIDNet search

This command is used to search a piece offer for a given root cid.

Usage:

fcr cidnet search [cid, currency id, max number of offers (0 if no maximum)]

After search is done, offer details together with an offer data (base64 encoded) will be output to the terminal. If you are happy about a particular offer, copy the offer data.

CIDNet query

This command is used to query a piece offer from a given peer.

Usage:

fcr cidnet query [cid, currency id, peer wallet addr]

CIDNet piece

This command is used to access piece manager related functions.

Usage:

fcr cidnet piece

CIDNet piece import

This command is used to import a file into the piece manager.

Usage:

fcr cidnet piece import [file path]

CIDNet piece import-car

This command is used to import a .CAR file into the piece manager.

Usage:

fcr cidnet piece import-car [car file path]

CIDNet piece import-sector

This command is used to import a lotus generated unsealed sector copy into the piece manager.

Usage:

fcr cidnet piece import-sector [sector file path, if keep copy]

Note: In addition to the sector file path, you need a boolean to indicate whether to keep a copy in the piece manager. If false is given, piece manager will only store reference to the unsealed copy without creating one additional physical copy for graphs contained in the sector and in this case, do not move the unsealed copy, otherwise piece manager will not be able to load any block from the sector.

CIDNet piece list

This command lists all pieces stored by the piece manager.

To list with details, use -l or --long.

Usage:

fcr cidnet piece list -l

CIDNet piece inspect

This command inspects the details of an imported piece.

Usage:

fcr cidnet piece inspect [cid]

CIDNet piece remove

This command removes a piece from the piece manager.

Usage:

fcr cidnet piece remove [cid]

CIDNet serving

This command is used to access serving manager related functions. This is used to serve any piece that has been imported earlier to the network.

Usage:

fcr cidnet serving

Note: One serving in the system is a [cid, currency id] pair.

CIDNet serving serve

This command is used to start serve a piece to the network.

Usage:

fcr cidnet serving serve [cid, currency id, price per byte]

Note: price per byte is in attoFIL, the smallest unit of Filecoin. (1 FIL = 10^18 attoFIL)

CIDNet serving list

This command is used to lists all pieces that are currently being served.

To list with details, use -l or --long.

Usage:

fcr cidnet serving list -l

CIDNet serving inspect

This command is used to inspect a given piece that is currently being served.

Usage:

fcr cidnet serving inspect [cid, currency id]

CIDNet serving stop

This command is used to stop a serving.

Usage:

fcr cidnet serving stpo [cid, currency id]

CIDNet serving set-miner-proof

This command is used to set linked miner.

Usage:

fcr cidnet serving set-miner-proof [currency id, miner key type, miner address, base64 proof]

CIDNet serving get-miner-proof

This command is used to get the current linked miner and the proof.

Usage:

fcr cidnet serving get-miner-proof [currency id]

PayNet

This command lists all Payment Network related functions.

Usage:

fcr paynet

PayNet query

This command is used to query a payment offer for a given piece offer.

Usage:

fcr paynet query [piece offer data]

Note: the piece offer data refers to the data here. It will return a payment offer along with its encoded data.

PayNet reserve

This command is used to reserve funds to use for a given piece offer or payment offer.

Usage:

fcr paynet reserve [piece offer/pay offer]

Note: when using payment offer, add tag --payoffer or --po to indicate a payment offer is supplied. If a piece offer is given, FCR will try to reserve using a direct payment channel while if a payment offer is given, FCR will try to reserve using proxy payment. It will return a reservation id in the form of {chAddr-resID}.

PayNet paych

This command is used to access payment channel related functions.

Usage:

fcr paynet paych

PayNet paych query

This command is used to query a payment channel offer from a node.

Usage:

fcr paynet paych query [currency id, peer addr]

Note: upon success, it will return a payment channel offer and its offer data.

PayNet paych create

This command is used to create a payment channel to a given recipient.

Usage:

fcr paynet paych create [paych offer data, amount]

Note: The amount is in unit of attoFIL. (1 FIL = 10^18 attoFIL)

PayNet paych renew

This command is used to renew an active outbound payment channel.

Usage:

fcr paynet paych renew [currency id, peer addr, paych addr]

PayNet paych topup

This command is used to topup an active outbound payment channel.

Usage:

fcr paynet paych topup [currency id, peer addr, paych addr, amount]

Note: The amount is in unit of attoFIL. (1 FIL = 10^18 attoFIL)

PayNet paych update

This command is used to update the on-chain payment channel state for a payment channel using the latest voucher.

Usage:

fcr paynet paych update [currency id, peer addr, paych addr]

PayNet paych settle

This command is used to settle an inactive payment channel.

Usage:

fcr paynet paych settle [currency id, peer addr, paych addr]

PayNet paych collect

This command is used to collect an inactive payment channel that has been settled.

Usage:

fcr paynet paych collect [currency id, peer addr, paych addr]

Note: Upon collection, the payment channel will be removed from the channel store.

PayNet paych active-out/active-in/inactive-out/inactive-in

This command is used to access channel storage related functions. (The following will be using active outbound payment channel as the example).

Usage:

fcr paynet paych active-out

PayNet paych active-out get

This command is used to get the channel state.

Usage:

fcr paynet paych active-out get [currency id, peer addr, paych addr]

PayNet paych active-out list

This command is used to list all payment channels.

To list with details, use -l or --long.

Usage:

fcr paynet paych active-out list -l

PayNet paych active-out bear

This command is used to bear the network loss of an active outbound payment channel.

Usage:

fcr paynet paych active-out bear [currency id, peer addr, paych addr]

Note: Network loss will present very rarely. If there is a payment channel has constant network loss, consider block the peer. The bear function is exlusive to active outbound payment channel.

PayNet serving

This command is used to access serving manager related functions. This is used to serve any payment channel that has been created earlier.

Usage:

fcr paynet serving

PayNet serving serve

This command is used to serve a payment channel to the network at a given surcharge.

Usage:

fcr paynet serving serve [currency id, peer addr, paych addr, payment per period, period]

Note: payment per period and period are in attoFIL. (1 FIL = 10^18 attoFIL)

PayNet serving list

This command is used to lists all channels that are currently being served.

To list with details, use -l or --long.

Usage:

fcr paynet serving list -l

PayNet serving inspect

This command is used to inspect a serving.

Usage:

fcr paynet serving inspect [currency id, peer addr, paych addr]

PayNet serving stop

This command is used to stop serving a payment channel.

Usage:

fcr paynet serving stop [currency id, peer addr, paych addr]

PayNet policy

This command is used to access policy around payment network.

Usage:

fcr paynet policy

PayNet policy settle

This command is used to access the settlement policy manager.

Usage:

fcr paynet policy settle 

PayNet policy settle set

This command is used to set settlement policy.

Usage:

fcr paynet policy settle set [currency id, peer addr (or default), duration]

Example:

  1. To set 720 hour minimum settlement policy for everyone with currency id 1:
fcr paynet policy settle set 1 default 720h
  1. To set 720 hour minimum settlement policy for everyone except peer1 with currency id 1:
fcr paynet policy settle set 1 default 720h
fcr paynet policy settle set 1 peer1 0
  1. To set 720 hour minimum settlement policy just for peer1:
fcr paynet policy settle set 1 default 0
fcr paynet policy settle set 1 peer1 720h

PayNet policy settle get

This command is used to get the settlmeent policy.

Usage:

fcr paynet policy settle get [currency id, peer addr (or default)]

PayNet policy settle remove

This command is used to remove the settlement policy.

Usage:

fcr paynet policy settle remove  [currency id, peer addr (or default)]

PayNet policy settle list

This command is used to list the settlement policy.

To list with details, use -l or --long.

Usage:

fcr paynet policy settle list -l

PayNet policy renew

This command is used to access the renew policy manager.

Usage:

fcr paynet policy renew

PayNet policy renew set

This command is used to set renew policy.

Usage:

fcr paynet policy renew set [currency id, peer addr (or default), duration]
-OR-
fcr paynet policy renew set [currency id, peer addr, paych addr, duration]

Example:

  1. To set 720 hour renew policy for everyone with currency id 1:
fcr paynet policy renew set 1 default 720h
  1. To set 720 hour renew policy for everyone except peer1 with currency id 1:
fcr paynet policy renew set 1 default 720h
fcr paynet policy renew set 1 peer1 0
  1. To set 720 hour renew policy just for peer1:
fcr paynet policy renew set 1 default 0
fcr paynet policy renew set 1 peer1 720h
  1. To set 720 hour renew policy just for a paych1 for peer1:
fcr paynet policy renew set 1 default 0
fcr paynet policy renew set 1 peer1 0
fcr paynet policy renew set 1 peer1 paych1 720h

PayNet policy renew get

This command is used to get renew policy.

Usage:

fcr paynet policy renew get [currency id, peer addr (or default)]
-OR-
fcr paynet policy renew get [currency id, peer addr, paych addr]

PayNet policy renew remove

This command is used to remove a renew policy.

Usage:

fcr paynet policy renew remove [currency id, peer addr (or default)]
-OR-
fcr paynet policy renew remove [currency id, peer addr, paych addr]

PayNet policy renew list

This command is used to list the renew policy.

To list with details, use -l or --long.

Usage:

fcr paynet policy renew list -l

PayNet policy reserve

This command is used to access the reservation policy manager.

Usage:

fcr paynet policy reserve

PayNet policy reserve set

This command is used to set the reservation policy.

Usage:

fcr paynet policy reserve set [currency id, paych addr (or default), max amount (-1 if unlimited)]
-OR-
fcr paynet policy reserve set [currency id, paych addr, peer addr, max (-1 if unlimited)]

PayNet policy reserve get

This command is used to get the current reservation policy.

Usage:

fcr paynet policy reserve get [currency id, paych addr (or default)]
-OR-
fcr paynet policy reserve get [currency id, paych addr, peer addr]

PayNet policy reserve remove

This command is used to remove the current reservation policy.

Usage:

fcr paynet policy reserve remove [currency id, paych addr (or default)]
-OR-
fcr paynet policy reserve remove [currency id, paych addr, peer addr]

PayNet policy reserve list

This command is used to list the reservation policy.

To list with details, use -l or --long.

Usage:

fcr paynet policy reserve list -l

Peer

This command is used to access peer manager related functions.

Usage:

fcr peer

Peer add

This command is used to add a peer to the peer manager.

Usage:

fcr peer add [currency id, peer addr, peer network p2p addr]

Peer list

This command is used to list all peers in the peer manager.

To list with details, use -l or --long.

Usage:

fcr peer list -l

Peer inspect

This command is used to inspect the details of a given peer.

Usage:

fcr peer inspect [currency id, peer addr]

Peer remove

This command is used to remove a given peer from the peer manager along with its history.

Usage:

fcr peer remove [currency id, peer addr]

Peer block

This command is used to block a given peer.

Usage:

fcr peer block [currency id, peer addr]

Peer unblock

This command is used to unblock a given peer.

Usage:

fcr peer unblock [currency id, peer addr]

Peer list-history

This command is used to list the history of a peer.

Usage:

fcr peer list-history [currency id, peer addr]

Note: The most recent history will be listed from the top.

Peer remove-record

This command is used to remove a record from the history of a peer.

Usage:

fcr peer remove-record [currency id, peer addr, record id]

Peer set-recid

This command is used to set the record id of a peer.

Usage:

fcr peer set-recid [currency id, peer addr, record id]

Note: This command is used to truncate the history. For example, setting record id to 1 makes next record to overwrite the existing record with id 1.

Retrieve

This command is used to retrieve a piece from given piece offer and payment offer.

Usage:

fcr retrieve [piece offer data, reservation id (0-0 if free), outpath, pay offer data (optional)]

Note: the piece offer can be obtained from here, reservation id can be obtained from here. If the piece offer is free, then use reservation id 0-0. Payment offer is optional, if the retrieval requires a proxy payment, you would have already obtained a payment offer from here.

Cache-retrieve

This command is used to attempt retrieve a piece from local cache store.

Usage:

fcr cache-retrieve [cid, outpath]

Fast-retrieve

This command is used to do a fast retrieve of given cid with given maximum payment.

Usage:

fcr fast-retrieve [cid, outpath, currency id, max amount]

Note: Fast-retrieve uses a pre-set strategy: It first tries to retrieve from cache store. If piece does not exist in cache store, it will try to retrieve without proxy payment. If retrieve without proxy payment failed, it will try to retrieve with proxy payment.

System

This command is used to access the system functions.

Usage:

fcr system

System addr

This command is used to get the network address of this node.

Usage:

fcr system addr

System connect

This command is used to connect to an FCR node for bootstrapping.

Usage:

fcr system connect [peer network p2p address]

System publish

This command forces FCR to publish its existence to the network.

Usage:

fcr system publish

System cache-size

This command is used to get the size of the retrieval cache size.

Usage:

fcr system cache-size

System cache-prune

This command is used to prune the retrieval cache.

Usage:

fcr system cache-prune

System clean

This command forces FCR to perform a retrieval process clean.

Usage:

fcr system clean

System gc

This command is used to force FCR to perform a golang garbage collection.

Usage:

fcr system gc

Note: If process takes too much memory, try run this command.