algorand / go-algorand-sdk Goto Github PK
View Code? Open in Web Editor NEWAlgorand Golang SDK
Home Page: https://pkg.go.dev/github.com/algorand/go-algorand-sdk/v2
License: MIT License
Algorand Golang SDK
Home Page: https://pkg.go.dev/github.com/algorand/go-algorand-sdk/v2
License: MIT License
After installing the sdk...
go get -u github.com/algorand/go-algorand-sdk/...
I am getting this failure when trying to use goal
-bash: goal: command not found
Use CloseRemainderTo. The funds are locked in the HTLC contract account, so we can set the amount to 0 and deposit the entirety of the HTLC account with CloseRemainderTo.
Verify the preimage. We have the preImage, image and hashFn, so we are able to verify that the hashFn(preImage) == image
: https://github.com/algorand/py-algorand-sdk/pull/71/files#diff-b0993c0c0cb44ddeecba70c5d36d57d9R211
for example, ImportMultisig() takes in a public key which forces you to decode an address
go-algorand-sdk/client/kmd/wrappers.go
Line 212 in bc0af1a
python works nicely where it takes in an msig object to import a multisig account into a kmd wallet
https://github.com/algorand/py-algorand-sdk/blob/b079db660ae92d0dbf24dc04f28eb722711e426f/algosdk/kmd.py#L353
per discussion with @JasonWeathersby
N.B. this ticket scope does not include integration tests, just unit tests.
pzbitskiy@mbr: .../go-algorand-sdk (pavel/logicsig)$ make
golint `go list ./... | grep -v /vendor/`
algorand/go-algorand-sdk/transaction/transaction.go:462:1: comment on exported function MakeAssetAcceptanceTxn should be of the form "MakeAssetAcceptanceTxn ..."
algorand/go-algorand-sdk/transaction/transaction.go:479:1: comment on exported function MakeAssetRevocationTxn should be of the form "MakeAssetRevocationTxn ..."
algorand/go-algorand-sdk/transaction/transaction.go:683:1: comment on exported function MakeAssetAcceptanceTxnWithFlatFee should be of the form "MakeAssetAcceptanceTxnWithFlatFee ..."
algorand/go-algorand-sdk/transaction/transaction.go:699:1: comment on exported function MakeAssetRevocationTxnWithFlatFee should be of the form "MakeAssetRevocationTxnWithFlatFee ..."
found by pzbitskiy
related thought - maybe we could have the SDKs present a reminder to golint
to PR-ing users, like go-algorand
PRs
Currently, branch tests are a requirement for merging, but they don't run when the pull request is from a fork.
Hello!
When I import a wallet with 12 mnemonics
, the prompt must be 25 digits.
Does it support 12 mnemonics? ๐ค
per discussion with @JasonWeathersby
Relates to algorand/java-algorand-sdk#71
More context: the algod
node potentially reports the following information (go-algorand/daemon/algod/api/spec/v1/model.go
) - and of the below, go only supports PaymentTransactionType
// This is a list of all supported transactions.
// To add another one, create a struct with XXXTransactionType and embed it here.
// To prevent extraneous fields, all must have the "omitempty" tag.
// Payment contains the additional fields for a payment transaction.
//
// required: false
Payment *PaymentTransactionType `json:"payment,omitempty"`
// Keyreg contains the additional fields for a keyreg transaction.
//
// required: false
Keyreg *KeyregTransactionType `json:"keyreg,omitempty"`
// AssetConfig contains the additional fields for an asset config transaction.
//
// required: false
AssetConfig *AssetConfigTransactionType `json:"curcfg,omitempty"`
// AssetTransfer contains the additional fields for an asset transfer transaction.
//
// required: false
AssetTransfer *AssetTransferTransactionType `json:"curxfer,omitempty"`
// AssetFreeze contains the additional fields for an asset freeze transaction.
//
// required: false
AssetFreeze *AssetFreezeTransactionType `json:"curfrz,omitempty"`
$ goal asset send --amount 0 --creator CBIH... -t PDUR... --assetid 1 --from PDUR...
Couldn't broadcast tx with algod: HTTP 400 Bad Request: TransactionPool.Remember: transaction S63U...: account PDUR... balance 199000 below min 100000 (1 assets)
$ goal account list
[online] CBIH... CBIH... 5001430048935245 microAlgos [created assets: 1 (10 )]
10 (creator CBIH..., ID 1, name )
[offline] exampleAccount PDUR... 200000 microAlgos *Default
$ goal report
4295016318
1.0.49022.dev [shant/readme_changes] (commit #445b9b6d+)
Darwin Admins-MacBook-Pro.local 18.7.0 Darwin Kernel Version 18.7.0: Tue Aug 20 16:57:14 PDT 2019; root:xnu-4903.271.2~2/RELEASE_X86_64 x86_64
Genesis ID from genesis.json: privateFuture-v1
Last committed block: 11446
Time since last block: 1.6s
Sync Time: 0.0s
Last consensus protocol: future
...
DynamicFee: Fix bug where the grouped transactions were presented to the contract in the wrong order. Fix incorrect lsig/txn building.
Split: Remove precise
flag and change corresponding error. Fix rounding error in amount calculation. Fix bug where ratn
and ratd
were inversed. GetSendFundsTransaction
becomes static-like GetSplitFundsTransaction
, which accepts a complete contract.
PeriodicPayment: Fix bug where the maximum fee passed to the contract was then used as the payment transaction's fee-per-byte.
LimitOrder: Fix bug where the transactions were being presented to the contract in the wrong order.
HTLC: Add getter for HTLC-unlocking txn.
Update all unit tests.
Java SDK model.Transaction, used for fetching Transaction details, class is missing the Lease property. This may be an issue for the other SDKs.
Algos can be fractional, so uint64 doesn't make sense.
See PR algorand/go-algorand#490
When i use the algodClient in the go sdk to retrieve the Account information it only returns the following json:
(NCTCJR6YAZDPGJ66EIHAUNCTLGOXFVIOWPJUSCUKB7V3YX5UXNHK5UZPCU as example)
{
"address": "NCTCJR6YAZDPGJ66EIHAUNCTLGOXFVIOWPJUSCUKB7V3YX5UXNHK5UZPCU",
"amount": 0,
"status": "Offline"
}
When i use the same rest server but query it directly without using the sdk i get the following json as response:
{
"round": 99109,
"address": "NCTCJR6YAZDPGJ66EIHAUNCTLGOXFVIOWPJUSCUKB7V3YX5UXNHK5UZPCU",
"amount": 100000000,
"pendingrewards": 0,
"amountwithoutpendingrewards": 100000000,
"rewards": 0,
"status": "Offline"
}
Code to reproduce:
package main
import (
"fmt"
"encoding/json"
"github.com/algorand/go-algorand-sdk/client/algod"
)
const algodAddress = "<>"
const algodToken = "<>"
func main() {
// Create an algod client
algodClient, err := algod.MakeClient(algodAddress, algodToken)
if err != nil {
return
}
// Account Info
AccountInfo, err := algodClient.AccountInformation("NCTCJR6YAZDPGJ66EIHAUNCTLGOXFVIOWPJUSCUKB7V3YX5UXNHK5UZPCU")
if err != nil {
fmt.Printf("error getting algod status: %s\n", err)
return
}
// Print the account info as json
fmt.Printf("\n-----------------Account Information-------------------\n")
accountJSON, err := json.MarshalIndent(AccountInfo, "", "\t")
if err != nil {
fmt.Printf("Error: %s\n", err)
}
fmt.Printf("%s\n", accountJSON)
}
All requests created by SDK have either no extra header key value pairs or hard code 'X-Algo-API-Token' into the request. SDK should support additional headers or alternates to the current header to support more use cases.
An example of how this could be done is in PR #33.
related to #39
From Jason trying to build out contract template examples:
The second payment in GetSwapAssetsTransaction, which transfers assets from the buyer's account to the owner, sets assetCloseRemainderTo=owner
, but other SDKs do not.
Additionally, the comment says the first payment, which transfers algos from the contract, will close the remainder back to the owner; but the function sets algoCloseRemainderTo=""
, i.e. none.
MakePaymentTxn takes the genesis hash as bytes, and MakeKeyRegTxn takes a base64 string.
hey,
running macOS Mojave Version 10.14.3 (18D109)
I am using the Go SDK and following the tutorial on the github readme to create a wallet. When I try to run my app, go modules tries to download the package files, and eventually returns an error
go: github.com/algorand/go-codec/[email protected]: parsing go.mod: unexpected module path "github.com/ugorji/go/codec"
go: error loading module requirements
Summary: Right now, only goal can generate participation keys and this significantly limits what our custody providers and other staking service developers can do at this time. I think this is a reasonable thing to add in general but this is the use case that warrants a high priority.
In other words, there needs to be a way fo developers to do the goal addpartkey/goal changeonlinestatus flow without using goal, because goal is not meant to be a developer tool.
Add the following components to the go-algorand-sdk
- [ ] add ability to generate participation key pairs
- [ ] add ability to generate keyreg txns that we can submit later
UPDATE 06/28/2019
For now, the go-sdk does not need to know about .partkey
files. The flow is now for spending key providers to receive (through some mechanism) the VRF public key, and root participation public key, and then to sign a keyreg transaction, and then sending this txn to a node host. The node operator can use goal
and algokey
to manipulate .partkey
files. The go-sdk only needs to create key reg transactions.
This functionality already exists. This issue now refers to making this functionality a little nicer to use (add a sdk-level function for creating keyreg transactions).
There is another conversation about allowing the (java?) sdk to create and manipulate .partkey
files. Because this is significantly more effort consider that deferred.
I'm trying out the Algorand go sdk and get this when I try to create a new wallet on a private network:
./goal wallet new testwallet -d private/
Please choose a password for wallet 'testwallet':
Please confirm the password:
Creating wallet...
Created wallet 'testwallet'
Your new wallet has a backup phrase that can be used for recovery.
Keeping this backup phrase safe is extremely important.
Would you like to see it now? (Y/n): Y
Your backup phrase is printed below.
Keep this information safe -- never share it with anyone!
parrot rifle bean into elephant poet rough erosion turn prevent file capital twelve cabin dizzy leaf mercy agree tag quantum clock paddle bright able taste
ERRO[0008] [Stack] goroutine 1 [running]:
runtime/debug.Stack(0xc0000c82d0, 0xc000010490, 0xc0003361e0)
/Users/travis/.gimme/versions/go1.12.darwin.amd64/src/runtime/debug/stack.go:24 +0x9d
github.com/algorand/go-algorand/logging.logger.Error(0xc0000c82d0, 0xc000010490, 0xc000330240, 0x1, 0x1)
/Users/travis/gopath/src/github.com/algorand/go-algorand/logging/log.go:216 +0x48
main.(*AccountsList).dumpList(0xc0002565c0)
/Users/travis/gopath/src/github.com/algorand/go-algorand/cmd/goal/accountsList.go:189 +0x1a6
main.(*AccountsList).setDefaultWalletID(...)
/Users/travis/gopath/src/github.com/algorand/go-algorand/cmd/goal/accountsList.go:82
main.glob..func58(0x572b100, 0xc0002da540, 0x1, 0x3)
/Users/travis/gopath/src/github.com/algorand/go-algorand/cmd/goal/wallet.go:183 +0x7e9
github.com/algorand/go-algorand/vendor/github.com/spf13/cobra.(*Command).execute(0x572b100, 0xc0002da4b0, 0x3, 0x3, 0x572b100, 0xc0002da4b0)
/Users/travis/gopath/src/github.com/algorand/go-algorand/vendor/github.com/spf13/cobra/command.go:766 +0x2ae
github.com/algorand/go-algorand/vendor/github.com/spf13/cobra.(*Command).ExecuteC(0x572eec0, 0x4d107f6, 0x7, 0x4d0c83c)
/Users/travis/gopath/src/github.com/algorand/go-algorand/vendor/github.com/spf13/cobra/command.go:852 +0x2c0
github.com/algorand/go-algorand/vendor/github.com/spf13/cobra.(*Command).Execute(...)
/Users/travis/gopath/src/github.com/algorand/go-algorand/vendor/github.com/spf13/cobra/command.go:800
main.main()
/Users/travis/gopath/src/github.com/algorand/go-algorand/cmd/goal/commands.go:133 +0x97
file=accountsList.go function="main.(*AccountsList).dumpList" line=189
ERRO[0008] open private/private-v38/accountList.json: no such file or directory file=accountsList.go function="main.(*AccountsList).dumpList" line=189
open private/private-v38/accountList.json: no such file or directory
Any reason why?
Verify minTrade
and maxFee
Missing the transactions golden, compare to Java:
String goldenTx1 =
"gqRsc2lngaFsxLcBIAoAAcCWsQICkE4EuWBkHsDEByYBIP68oLsUSlpOp7Q4pG" +
"gayA5soQW8tgf8VlMlyVaV9qITMRYiEjEQIxIQMQEkDhAyBCMSQABVMgQlEjEI" +
"IQQNEDEJMgMSEDMBECEFEhAzAREhBhIQMwEUKBIQMwETMgMSEDMBEiEHHTUCNQ" +
"ExCCEIHTUENQM0ATQDDUAAJDQBNAMSNAI0BA8QQAAWADEJKBIxAiEJDRAxBzID" +
"EhAxCCISEBCjdHhuiaNhbXTNJxCjZmVlzQisomZ2zQTSomdoxCB/g7Flf/H8U7" +
"ktwYFIodZd/C1LH6PWdyhK3dIAEm2QaaNncnDEIKz368WOGpdE/Ww0L8wUu5Ly" +
"2u2bpG3ZSMKCJvcvGApTomx2zQi6o3JjdsQgzUWoS2tM1RvtuQQyGhwdXUqCBy" +
"LFEPBRXHZwnSqBvgajc25kxCBd4Wnq60VaWXeVmuPt0x1XgMQSyP4nUnlh5G2R" +
"hyo+taR0eXBlo3BheQ==";
String goldenTx2 =
"gqNzaWfEQKXv8Z6OUDNmiZ5phpoQJHmfKyBal4gBZLPYsByYnlXCAlXMBeVFG5" +
"CLP1k5L6BPyEG2/XIbjbyM0CGG55CxxAKjdHhuiqRhYW10zQu4pGFyY3bEIP68" +
"oLsUSlpOp7Q4pGgayA5soQW8tgf8VlMlyVaV9qITo2ZlZc0JJKJmds0E0qJnaM" +
"Qgf4OxZX/x/FO5LcGBSKHWXfwtSx+j1ncoSt3SABJtkGmjZ3JwxCCs9+vFjhqX" +
"RP1sNC/MFLuS8trtm6Rt2UjCgib3LxgKU6Jsds0IuqNzbmTEIM1FqEtrTNUb7b" +
"kEMhocHV1KggcixRDwUVx2cJ0qgb4GpHR5cGWlYXhmZXKkeGFpZM0wOQ==";
ByteArrayOutputStream bytes = new ByteArrayOutputStream();
bytes.write(Encoder.decodeFromBase64(goldenTx1));
bytes.write(Encoder.decodeFromBase64(goldenTx2));
assertThat(Encoder.encodeToBase64(transactions)).isEqualTo(Encoder.encodeToBase64(bytes.toByteArray()));
go build
../../../../pkg/mod/github.com/algorand/[email protected]/logic/logic.go:45:28: undefined: langSpecJson
how deal this bug ๏ผ thanks .
The algod /v1/transactions
POST endpoint expects a binary content, but the Content-Type: x-binary
header is not set by the Go SDK when making that request (SendRawTransaction
). Right now the algod node API works without this header, but other APIs might not (e.g. PureStake API).
The Java SDK already does that, so it would be update this SDK to match that behavior.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.