everfinance / goar Goto Github PK
View Code? Open in Web Editor NEWArweave http client and wallet implemented in go, Arweave SDK
License: Apache License 2.0
Arweave http client and wallet implemented in go, Arweave SDK
License: Apache License 2.0
I am using goar as well as arsyncer. Arsyncer has always worked just fine both locally and in my hosted environment, and goar has been working fine locally just fine as well.
Starting sometime in the past few days I'm suddenly getting an error:
pNode.GetBlockHashList() module=syncer err="get block hash list failed"
I'm getting this when running Arsyncer, or Goar, and both locally and in cloud. I created fresh new Ubuntu 22.04 instances to test it on also and tried that with versions of go 1.15 through 1.20.
I'm opening this ticket to find out if this is somehow just isolated to my code or if something has changed with the way blocks are pulled from peers.
I wish I could use this library but because it does not support go's context.Context
I can't reliably use it. This library obviously performs operations over a network and it is common practice to use a context so that network operations can be cancelled by the context, either by manual cancellation or deadline. The go http
package supports contexts with functions like http.NewRequestWithContext
.
Even if I use contexts and goroutines to disregard the response of a *goar.Client when a context times out for example, there is no way to stop the execution of a function. If I were to be downloading content from arweave, it would continue downloading despite the context cancelling, and the program continuing running.
The only workaround I can see is manually setting a timeout on the http client, but this is bad practice and not predictable.
Is it possible to create arweave wallet account ?. Below is the scenario.
User can provide seed phrase if exists or create a new seed phrase to create new arweave wallet account.
Dear author,
Thank you for this great work! I'm wondering if you could indicate the license under which the code in this repository is distributed. This will greatly improve the possibilities of using your work. Thanks a lot!
go get 的时候提示找不到 base58 这个包,请问如何处理?
$ go get github.com/everFinance/goar
github.com/everFinance/goar imports
github.com/everFinance/goar/utils imports
github.com/btcsuite/btcutil/base58: cannot find module providing package github.com/btcsuite/btcutil/base58
sample 1), data is less than one chunk, will success
func TestWallet_SendDataSpeedUp01(t *testing.T) {
// arNode := "https://arweave.net"
// w, err := NewWalletFromPath("./example/testKey.json", arNode) // your wallet private key
// assert.NoError(t, err)
//data := []byte("aaa this is a goar test small size file data") // small file
data := make([]byte, 255*1024)
for i := 0; i < len(data); i++ {
data[i] = byte('b' + i)
}
tags := []types.Tag{
{Name: "GOAR", Value: "SMDT"},
}
id, err := testWallet.SendDataSpeedUp(data, tags, 50)
assert.NoError(t, err)
t.Logf("tx hash: %s", id)
}
==========================
sample 2) data size 10 chunks. return with the following error:
Unable to upload Transaction: 400, , Transaction verification failed.
func TestWallet_SendDataSpeedUp01(t *testing.T) {
// arNode := "https://arweave.net"
// w, err := NewWalletFromPath("./example/testKey.json", arNode) // your wallet private key
// assert.NoError(t, err)
//data := []byte("aaa this is a goar test small size file data") // small file
data := make([]byte, 255*1024*10)
for i := 0; i < len(data); i++ {
data[i] = byte('b' + i)
}
tags := []types.Tag{
{Name: "GOAR", Value: "SMDT"},
}
id, err := testWallet.SendDataSpeedUp(data, tags, 50)
assert.NoError(t, err)
t.Logf("tx hash: %s", id)
}
Hello, trying to upload a file and I seem to be hitting this error:
$ go run main.go
Tx data size: 0.004551MB
uplaodTx; body: <!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Error</title>
</head>
<body>
<pre>Bad Request</pre>
</body>
</html>
, status: 400, txId: -lmcTK9yzneKUOt4_xqC3vxEH50DhhaWzYBTDDOFpCM
0.000000% completes, 0/1
2021/10/14 17:33:22 -lmcTK9yzneKUOt4_xqC3vxEH50DhhaWzYBTDDOFpCM
Code:
package main
import (
"fmt"
"io/ioutil"
"log"
"github.com/everFinance/goar"
"github.com/everFinance/goar/types"
"github.com/everFinance/goar/utils"
)
const ARWEAVE_NODE = "https://arweave.net"
func main () {
data, err := ioutil.ReadFile("./test.png")
if err != nil {
panic(err)
}
tx, err := UploadToArweave("./arweave-key.json",data)
if err != nil {
panic(err)
}
log.Println(tx)
}
func UploadToArweave(walletPath string, data []byte) (string, error) {
// Load wallet
w, err := goar.NewWalletFromPath(walletPath, ARWEAVE_NODE)
if err != nil {
return "", err
}
log.Println(w.Address)
// Get anchor
anchor, err := w.Client.GetTransactionAnchor()
if err != nil {
return "", err
}
// Get reward
reward, err := w.Client.GetTransactionPrice(data, nil)
if err != nil {
return "", err
}
// Craft tx
speedFactor := int64(50)
tx := &types.Transaction{
Format: 2,
Target: "",
Quantity: "0",
Tags: utils.TagsEncode([]types.Tag{
types.Tag{
Name: "Content-Type",
Value: "image/png",
},
}),
Data: utils.Base64Encode(data),
DataSize: fmt.Sprintf("%d", len(data)),
Reward: fmt.Sprintf("%d", reward*(100+speedFactor)/100),
LastTx: anchor,
}
if err = utils.SignTransaction(tx, w.PrvKey); err != nil {
return "", err
}
// Upload
uploader, err := goar.CreateUploader(w.Client, tx, nil)
if err != nil {
return "", err
}
err = uploader.Once()
if err != nil {
return "", err
}
return tx.ID, nil
}
What could be wrong here?
Current API only support uploading bytes([]byte). It is obviously not good for upload big files(e.g., video files) at same time.
Shall we consider arweave API like S3?
PutObject(reader io.Reader, objectSize int64, opt PubObjectOption) (PutObjectResult, err error)
Thanks a lot
Hello, I am trying to use the bundler to upload files but every time I attempt to submit a bundle I receive this error:
send to bundler request failed; http code: 402
this is my flow for finalizing:
_, err := bm.Wallet.Client.BatchSendItemToBundler(bm.BundleItems)
if err != nil {
return err
}
bd, err := utils.NewBundle(bm.BundleItems...)
if err != nil {
return err
}
_, err = bm.Wallet.SendBundleTx(bd.BundleBinary, nil)
if err != nil {
return err
}
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.