Get Unsigned Data

API Endpoint

http://127.0.0.1:5001/api/v1/storage/upload/getunsigned?

Input Parameters

Argument

Required?

Type

Description

Required?

session-id

Y

string

ID for the storage upload session.

Y

peer-id

N

string

Client that requires the offline signs

N

nonce-timestamp

Y

int64

Timestamp used for nonce. Must be within 1 hour of server time.

N

upload-session-signature

Y

string

Private key-signed string of “::” for this delegated request.

N

session-status

Y

string

The “status” API session status that is received right before calling this API.

N

Usage

async getUnsignedData(event) {
    let input  = {
      SessionId: this.state.added_session_id,
      SessionStatus: this.state.added_session_status,
      Hash: this.state.added_file_hash,
      TimeNonce: this.time,
      PrivKey: config.PrivKey,
      PeerID: config.PeerID
    }
    const unsignedDataResponse = this.btfs.getUnsigned(input, {})
    try {
      for await (const response of unsignedDataResponse) {
        input.Unsigned = response.Unsigned
        input.Opcode = response.Opcode
        input.Price = response.Price
        const unsignedDataResponse = await this.btfs.sign(input, {}, {})
        for await (const response of unsignedDataResponse ){
        }
      }
    } catch (err) {
      console.error(err)
    }
  }
// Usage

unsigned, err := s.StorageUploadGetUnsignedData(sessionId, mhash, uts, storage.Status)


// Go Wrapper

func (s *Shell) StorageUploadGetUnsignedData(sid string, hash string, uts string, sessionStatus string) (*UnsignedData, error) {
    var out UnsignedData
    offlinePeerSessionSignature, err := getSessionSignature()
    if err != nil {
        return nil, err
    }
    rb := s.Request("storage/upload/getunsigned", sid, utils.GetPeerId(), uts, offlinePeerSessionSignature, sessionStatus)
    return &out, rb.Exec(context.Background(), &out)
}
curl -X POST http://127.0.0.1:5001/api/v1/storage/upload/getunsigned?arg=647cae8b-7da1-4e00-b183-e34a1517d15e&arg=16Uiu2HAm5KyUqXm7gZb5ECj4vDWVVjVuzNoj7cNM3Q7Eoz5Vsj2D&arg=1582848820&arg=16Uiu2HAm5KyUqXm7gZb5ECj4vDWVVjVuzNoj7cNM3Q7Eoz5Vsj2D%3AQmQqiYA6LXehPbMw5UtW3zCWstEZ9mY37QNxss41SspAzG%3Atime.Now%28%29.String%28%29&arg=balanceSignReady

Response

{
    “Opcode”: “<string>”
    "Unsigned": “<string>”
    "Price": "<int64>"
}