Skip to content

Latest commit

 

History

History
30 lines (23 loc) · 1.17 KB

readme.md

File metadata and controls

30 lines (23 loc) · 1.17 KB

go-nitro Node

Our integration tests give the best idea of how to use the API. Another useful resource is the godoc description of the go-nitro.Node API.

Broadly, consumers will construct a go-nitro Node, possibly using injected dependencies. Then, they can create channels and send payments:

 import nc "github.com/statechannels/go-nitro/node"

 nitroNode := nc.New(
                    messageservice,
                    chain,
                    storeA,
                    logDestination,
                    nil,
                    nil
                )
response := nitroNode.CreateLedgerChannel(hub.Address, 0, someOutcome)
nitroNode.WaitForCompletedObjective(response.objectiveId)

response = nitroNode.CreateVirtualPaymentChannel([hub.Address],bob.Address, defaultChallengeDuration, someOtherOutcome)
nitroNode.WaitForCompletedObjective(response.objectiveId)

for i := 0; i < len(10); i++ {
    nitroNode.Pay(response.ChannelId, big.NewInt(int64(5)))
}

response = nitroNode.CloseVirtualChannel(response.ChannelId)
nitroNode.WaitForCompletedObjective(response.objectiveId)