@@ -31,8 +31,8 @@ import (
3131//
3232// returns the hash of the transaction, the nonce of the transaction, the transaction object and an error if any.
3333func CreateAllocationForOwner (
34- owner , ownerpublickey string ,
35- datashards , parityshards int , size int64 ,
34+ owner , ownerPublicKey , ownerSigningPublicKey string ,
35+ dataShards , parityShards int , size int64 ,
3636 readPrice , writePrice PriceRange ,
3737 lock uint64 , preferredBlobberIds , blobberAuthTickets []string , thirdPartyExtendable , IsEnterprise , force bool , fileOptionsParams * FileOptionsParameters , authRoundExpiry int64 ,
3838) (hash string , nonce int64 , txn * transaction.Transaction , err error ) {
@@ -41,12 +41,12 @@ func CreateAllocationForOwner(
4141 return "" , 0 , nil , errors .New ("invalid_lock" , "int64 overflow on lock value" )
4242 }
4343
44- if datashards < 1 || parityshards < 1 {
44+ if dataShards < 1 || parityShards < 1 {
4545 return "" , 0 , nil , errors .New ("allocation_validation_failed" , "atleast 1 data and 1 parity shards are required" )
4646 }
4747
4848 allocationRequest , err := getNewAllocationBlobbers (
49- StorageV2 , datashards , parityshards , size , readPrice , writePrice , preferredBlobberIds , blobberAuthTickets , force )
49+ StorageV2 , dataShards , parityShards , size , readPrice , writePrice , preferredBlobberIds , blobberAuthTickets , force )
5050 if err != nil {
5151 return "" , 0 , nil , errors .New ("failed_get_allocation_blobbers" , "failed to get blobbers for allocation: " + err .Error ())
5252 }
@@ -55,18 +55,20 @@ func CreateAllocationForOwner(
5555 return "" , 0 , nil , sdkNotInitialized
5656 }
5757
58- if client .PublicKey () == ownerpublickey {
59- privateSigningKey , err := generateOwnerSigningKey ( ownerpublickey , owner )
58+ if client .PublicKey () == ownerPublicKey {
59+ privateSigningKey , err := GenerateOwnerSigningKey ( ownerPublicKey , owner )
6060 if err != nil {
6161 return "" , 0 , nil , errors .New ("failed_generate_owner_signing_key" , "failed to generate owner signing key: " + err .Error ())
6262 }
6363 pub := privateSigningKey .Public ().(ed25519.PublicKey )
6464 pk := hex .EncodeToString (pub )
6565 allocationRequest ["owner_signing_public_key" ] = pk
66+ } else {
67+ allocationRequest ["owner_signing_public_key" ] = ownerSigningPublicKey
6668 }
6769
6870 allocationRequest ["owner_id" ] = owner
69- allocationRequest ["owner_public_key" ] = ownerpublickey
71+ allocationRequest ["owner_public_key" ] = ownerPublicKey
7072 allocationRequest ["third_party_extendable" ] = thirdPartyExtendable
7173 allocationRequest ["file_options_changed" ], allocationRequest ["file_options" ] = calculateAllocationFileOptions (63 /*0011 1111*/ , fileOptionsParams )
7274 allocationRequest ["is_enterprise" ] = IsEnterprise
@@ -359,7 +361,7 @@ func WritePoolUnlock(allocID string, fee uint64) (hash string, nonce int64, err
359361 return
360362}
361363
362- func generateOwnerSigningKey (ownerPublicKey , ownerID string ) (ed25519.PrivateKey , error ) {
364+ func GenerateOwnerSigningKey (ownerPublicKey , ownerID string ) (ed25519.PrivateKey , error ) {
363365 if ownerPublicKey == "" {
364366 return nil , errors .New ("owner_public_key_required" , "owner public key is required" )
365367 }
@@ -374,3 +376,13 @@ func generateOwnerSigningKey(ownerPublicKey, ownerID string) (ed25519.PrivateKey
374376 privateSigningKey := ed25519 .NewKeyFromSeed (decodedSig [:32 ])
375377 return privateSigningKey , nil
376378}
379+
380+ func GenerateOwnerSigningPublicKey () (string , error ) {
381+ privateSigningKey , err := GenerateOwnerSigningKey (client .PublicKey (), client .Id ())
382+ if err != nil {
383+ return "" , err
384+ }
385+
386+ pubKey := privateSigningKey .Public ().(ed25519.PublicKey )
387+ return hex .EncodeToString (pubKey ), nil
388+ }
0 commit comments