-
Notifications
You must be signed in to change notification settings - Fork 6
Get Lock secret info
Yevhen edited this page Jun 22, 2021
·
5 revisions
Returns []*SecretLockInfo
of an account. For getting use Lock.GetSecretLockInfosByAccount()
Following parameters required:
- PublicAccount - PublicAccount of some account
package main
import (
"context"
"fmt"
"github.com/proximax-storage/go-xpx-chain-sdk/sdk"
)
const (
// Catapult-api-rest server
baseUrl = "http://localhost:3000"
// Private key of some exist account. Change it
privateKey = "809CD6699B7F38063E28F606BD3A8AECA6E13B1E688FE8E733D13DB843BC14B7"
)
func main() {
conf, err := sdk.NewConfig(context.Background(), []string{baseUrl})
if err != nil {
fmt.Printf("NewConfig returned error: %s", err)
return
}
// Use the default http client
client := sdk.NewClient(nil, conf)
// Get some account
account, err := client.NewAccountFromPrivateKey(privateKey)
if err != nil {
fmt.Printf("NewAccountFromPrivateKey returned error: %s", err)
return
}
// Get secretLockInfos by account
infosByAccount, err := client.Lock.GetSecretLockInfosByAccount(context.Background(), account.PublicAccount)
for _, v := range infosByAccount {
fmt.Println(v.CompositeHash)
}
}
Returns []*SecretLockInfo
of an account. For getting use Lock.GetSecretLockInfosBySecret()
Following parameters required:
- Secret - hash of some secret
package main
import (
"context"
"fmt"
"math/rand"
"github.com/proximax-storage/go-xpx-chain-sdk/sdk"
)
const (
// Sirius api rest server
baseUrl = "http://localhost:3000"
)
func main() {
conf, err := sdk.NewConfig(context.Background(), []string{baseUrl})
if err != nil {
fmt.Printf("NewConfig returned error: %s", err)
return
}
// Use the default http client
client := sdk.NewClient(nil, conf)
//create some proof
proofB := make([]byte, 8)
_, err = rand.Read(proofB)
if err != nil {
fmt.Printf("rand.Read returned error: %s", err)
return
}
//New proof
proof := sdk.NewProofFromBytes(proofB)
//New secret from proof
secret, _ := proof.Secret(sdk.SHA3_256)
//Get info by secret
infosBySecret, err := client.Lock.GetSecretLockInfosBySecret(context.Background(), &secret.Hash)
for _, v := range infosBySecret {
fmt.Println(v)
}
}
Returns *SecretLockInfo
of an account. For getting use Lock.GetSecretLockInfo()
Following parameters required:
- Hash - some compositeHash
package main
import (
"context"
"encoding/hex"
"fmt"
"github.com/proximax-storage/go-xpx-chain-sdk/sdk"
)
const (
// Sirius api rest server
baseUrl = "http://localhost:3000"
)
func main() {
conf, err := sdk.NewConfig(context.Background(), []string{baseUrl})
if err != nil {
fmt.Printf("NewConfig returned error: %s", err)
return
}
// Use the default http client
client := sdk.NewClient(nil, conf)
//Some hex compositeHash
bytes, err := hex.DecodeString("11a4cc303e91ae150c6c487ec048a2a07298042427094f2ea6701c25aa565b6c")
compositeHash := &sdk.Hash{}
copy(compositeHash[:], bytes)
//Get secret lock info
infosByCompositeHash, err := client.Lock.GetSecretLockInfo(context.Background(), compositeHash)
fmt.Println(infosByCompositeHash)
}
- Home
- Installation
-
Examples
- Basic functions
- Get Accounts info
- Get Transactions info
- Get Mosaic info
- Get Mosaic Levy info
- Get Namespace info
- Get BlockChain info
- Get Network info
- Get Metadata info
- Get Nem Metadata info
- Get Account Properties info
- Get Exchange info
- Get SDA-SDA Exchange info
- Get Secret lock info
- Get Storage info
- Announces a transaction
- Websocket