Skip to content

Commit

Permalink
Fix create allocation for owner to get ownerSigningPublicKey
Browse files Browse the repository at this point in the history
  • Loading branch information
Jayashsatolia403 committed Feb 21, 2025
1 parent 671e93e commit 5e21b4d
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions zboxcore/sdk/blobber_operations.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ import (
//
// returns the hash of the transaction, the nonce of the transaction, the transaction object and an error if any.
func CreateAllocationForOwner(
owner, ownerpublickey string,
datashards, parityshards int, size int64,
owner, ownerPublicKey, ownerSigningPublicKey string,
dataShards, parityShards int, size int64,
readPrice, writePrice PriceRange,
lock uint64, preferredBlobberIds, blobberAuthTickets []string, thirdPartyExtendable, IsEnterprise, force bool, fileOptionsParams *FileOptionsParameters, authRoundExpiry int64,
) (hash string, nonce int64, txn *transaction.Transaction, err error) {
Expand All @@ -41,12 +41,12 @@ func CreateAllocationForOwner(
return "", 0, nil, errors.New("invalid_lock", "int64 overflow on lock value")
}

if datashards < 1 || parityshards < 1 {
if dataShards < 1 || parityShards < 1 {
return "", 0, nil, errors.New("allocation_validation_failed", "atleast 1 data and 1 parity shards are required")
}

allocationRequest, err := getNewAllocationBlobbers(
StorageV2, datashards, parityshards, size, readPrice, writePrice, preferredBlobberIds, blobberAuthTickets, force)
StorageV2, dataShards, parityShards, size, readPrice, writePrice, preferredBlobberIds, blobberAuthTickets, force)
if err != nil {
return "", 0, nil, errors.New("failed_get_allocation_blobbers", "failed to get blobbers for allocation: "+err.Error())
}
Expand All @@ -55,18 +55,20 @@ func CreateAllocationForOwner(
return "", 0, nil, sdkNotInitialized
}

if client.PublicKey() == ownerpublickey {
privateSigningKey, err := generateOwnerSigningKey(ownerpublickey, owner)
if client.PublicKey() == ownerPublicKey {
privateSigningKey, err := generateOwnerSigningKey(ownerPublicKey, owner)
if err != nil {
return "", 0, nil, errors.New("failed_generate_owner_signing_key", "failed to generate owner signing key: "+err.Error())
}
pub := privateSigningKey.Public().(ed25519.PublicKey)
pk := hex.EncodeToString(pub)
allocationRequest["owner_signing_public_key"] = pk
} else {
allocationRequest["owner_signing_public_key"] = ownerSigningPublicKey
}

allocationRequest["owner_id"] = owner
allocationRequest["owner_public_key"] = ownerpublickey
allocationRequest["owner_public_key"] = ownerPublicKey
allocationRequest["third_party_extendable"] = thirdPartyExtendable
allocationRequest["file_options_changed"], allocationRequest["file_options"] = calculateAllocationFileOptions(63 /*0011 1111*/, fileOptionsParams)
allocationRequest["is_enterprise"] = IsEnterprise
Expand Down

0 comments on commit 5e21b4d

Please sign in to comment.