Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 22 additions & 6 deletions cmd/sptool/toolbox_deal_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,11 @@ var dealFlags = []cli.Flag{
},
&cli.StringFlag{
Name: "wallet",
Usage: "wallet address to be used to initiate the deal",
Usage: "wallet address to be used to sign the deal",
},
&cli.StringFlag{
Name: "client-address",
Usage: "address to be used to initiate the deal; if empty, the signing wallet will be used",
},
&cli.BoolFlag{
Name: "skip-ipni-announce",
Expand Down Expand Up @@ -356,6 +360,16 @@ func dealCmdAction(cctx *cli.Context, isOnline bool) error {

log.Debugw("selected wallet", "wallet", walletAddr)

var clientAddr address.Address
if cctx.IsSet("client-address") {
clientAddr, err = address.NewFromString(cctx.String("client-address"))
if err != nil {
return err
}
} else {
clientAddr = walletAddr
}

httpDeal := cctx.Bool("http")

maddr, err := address.NewFromString(cctx.String("provider"))
Expand Down Expand Up @@ -510,7 +524,7 @@ func dealCmdAction(cctx *cli.Context, isOnline bool) error {
}

// Create a deal proposal to storage provider using deal protocol v1.2.0 format
dealProposal, err := dealProposal(ctx, n, walletAddr, rootCid, abi.PaddedPieceSize(pieceSize), pieceCid, maddr, startEpoch, cctx.Int("duration"), cctx.Bool("verified"), providerCollateral, abi.NewTokenAmount(cctx.Int64("storage-price")))
dealProposal, err := dealProposal(ctx, n, walletAddr, clientAddr, rootCid, abi.PaddedPieceSize(pieceSize), pieceCid, maddr, startEpoch, cctx.Int("duration"), cctx.Bool("verified"), providerCollateral, abi.NewTokenAmount(cctx.Int64("storage-price")))
if err != nil {
return xerrors.Errorf("failed to create a deal proposal: %w", err)
}
Expand Down Expand Up @@ -555,7 +569,8 @@ func dealCmdAction(cctx *cli.Context, isOnline bool) error {
out := map[string]interface{}{
"dealUuid": dealUuid.String(),
"provider": maddr.String(),
"clientWallet": walletAddr.String(),
"clientWallet": clientAddr.String(),
"signingWallet": walletAddr.String(),
"payloadCid": rootCid.String(),
"commp": dealProposal.Proposal.PieceCID.String(),
"startEpoch": dealProposal.Proposal.StartEpoch.String(),
Expand All @@ -575,7 +590,8 @@ func dealCmdAction(cctx *cli.Context, isOnline bool) error {
msg += "\n"
msg += fmt.Sprintf(" deal uuid: %s\n", dealUuid)
msg += fmt.Sprintf(" storage provider: %s\n", maddr)
msg += fmt.Sprintf(" client wallet: %s\n", walletAddr)
msg += fmt.Sprintf(" client wallet: %s\n", clientAddr)
msg += fmt.Sprintf(" signing wallet: %s\n", walletAddr)
msg += fmt.Sprintf(" payload cid: %s\n", rootCid)
if isOnline {
msg += fmt.Sprintf(" url: %s\n", cctx.String("http-url"))
Expand All @@ -589,7 +605,7 @@ func dealCmdAction(cctx *cli.Context, isOnline bool) error {
return nil
}

func dealProposal(ctx context.Context, n *Node, clientAddr address.Address, rootCid cid.Cid, pieceSize abi.PaddedPieceSize, pieceCid cid.Cid, minerAddr address.Address, startEpoch abi.ChainEpoch, duration int, verified bool, providerCollateral abi.TokenAmount, storagePrice abi.TokenAmount) (*market.ClientDealProposal, error) {
func dealProposal(ctx context.Context, n *Node, signingAddr address.Address, clientAddr address.Address, rootCid cid.Cid, pieceSize abi.PaddedPieceSize, pieceCid cid.Cid, minerAddr address.Address, startEpoch abi.ChainEpoch, duration int, verified bool, providerCollateral abi.TokenAmount, storagePrice abi.TokenAmount) (*market.ClientDealProposal, error) {
endEpoch := startEpoch + abi.ChainEpoch(duration)
// deal proposal expects total storage price for deal per epoch, therefore we
// multiply pieceSize * storagePrice (which is set per epoch per GiB) and divide by 2^30
Expand All @@ -616,7 +632,7 @@ func dealProposal(ctx context.Context, n *Node, clientAddr address.Address, root
return nil, err
}

sig, err := n.Wallet.WalletSign(ctx, clientAddr, buf, lapi.MsgMeta{Type: lapi.MTDealProposal})
sig, err := n.Wallet.WalletSign(ctx, signingAddr, buf, lapi.MsgMeta{Type: lapi.MTDealProposal})
if err != nil {
return nil, xerrors.Errorf("wallet sign failed: %w", err)
}
Expand Down
6 changes: 4 additions & 2 deletions documentation/en/curio-cli/sptool.md
Original file line number Diff line number Diff line change
Expand Up @@ -601,7 +601,8 @@ OPTIONS:
--storage-price value storage price in attoFIL per epoch per GiB (default: 1)
--verified whether the deal funds should come from verified client data-cap (default: false)
--remove-unsealed-copy indicates that an unsealed copy of the sector in not required for fast retrieval (default: false)
--wallet value wallet address to be used to initiate the deal
--wallet value wallet address to be used to sign the deal
--client-address value address to be used to initiate the deal; if empty, the signing wallet will be used
--skip-ipni-announce indicates that deal index should not be announced to the IPNI(Network Indexer) (default: false)
--http make the deal over HTTP instead of libp2p (default: false)
--help, -h show help
Expand Down Expand Up @@ -643,7 +644,8 @@ OPTIONS:
--storage-price value storage price in attoFIL per epoch per GiB (default: 1)
--verified whether the deal funds should come from verified client data-cap (default: false)
--remove-unsealed-copy indicates that an unsealed copy of the sector in not required for fast retrieval (default: false)
--wallet value wallet address to be used to initiate the deal
--wallet value wallet address to be used to sign the deal
--client-address value address to be used to initiate the deal; if empty, the signing wallet will be used
--skip-ipni-announce indicates that deal index should not be announced to the IPNI(Network Indexer) (default: false)
--http make the deal over HTTP instead of libp2p (default: false)
--help, -h show help
Expand Down