Skip to content
This repository has been archived by the owner on Nov 4, 2024. It is now read-only.

Commit

Permalink
Fix/xrp account (#2)
Browse files Browse the repository at this point in the history
* feat:处理account为空字符串的问题

* feat:处理go mod

* fix go mod
  • Loading branch information
Excalibur-1 authored Nov 23, 2021
1 parent 08a933b commit 4e9e05a
Show file tree
Hide file tree
Showing 7 changed files with 97 additions and 44 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,4 @@ _testmain.go

.DS_Store
.vscode
.idea
2 changes: 2 additions & 0 deletions crypto/hash.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ func NewRippleHash(s string) (Hash, error) {
return newHashFromString(ACCOUNT_ZERO)
case "1":
return newHashFromString(ACCOUNT_ONE)
case "":
return newHashFromString(NaN)
default:
return newHashFromString(s)
}
Expand Down
86 changes: 47 additions & 39 deletions data/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,20 @@ type TransactionType uint16

const (
// LedgerEntryType values come from rippled's "LedgerFormats.h"
SIGNER_LIST LedgerEntryType = 0x53 // 'S'
TICKET LedgerEntryType = 0x54 // 'T'
ACCOUNT_ROOT LedgerEntryType = 0x61 // 'a'
DIRECTORY LedgerEntryType = 0x64 // 'd'
AMENDMENTS LedgerEntryType = 0x66 // 'f'
LEDGER_HASHES LedgerEntryType = 0x68 // 'h'
OFFER LedgerEntryType = 0x6f // 'o'
RIPPLE_STATE LedgerEntryType = 0x72 // 'r'
FEE_SETTINGS LedgerEntryType = 0x73 // 's'
ESCROW LedgerEntryType = 0x75 // 'u'
PAY_CHANNEL LedgerEntryType = 0x78 // 'x'
CHECK LedgerEntryType = 0x63 // 'C'
DEPOSIT_PRE_AUTH LedgerEntryType = 0x70 // 'p'
SIGNER_LIST LedgerEntryType = 0x53 // 'S'
TICKET LedgerEntryType = 0x54 // 'T'
ACCOUNT_ROOT LedgerEntryType = 0x61 // 'a'
DIRECTORY LedgerEntryType = 0x64 // 'd'
AMENDMENTS LedgerEntryType = 0x66 // 'f'
LEDGER_HASHES LedgerEntryType = 0x68 // 'h'
OFFER LedgerEntryType = 0x6f // 'o'
RIPPLE_STATE LedgerEntryType = 0x72 // 'r'
FEE_SETTINGS LedgerEntryType = 0x73 // 's'
ESCROW LedgerEntryType = 0x75 // 'u'
PAY_CHANNEL LedgerEntryType = 0x78 // 'x'
CHECK LedgerEntryType = 0x63 // 'C'
DEPOSIT_PRE_AUTH LedgerEntryType = 0x70 // 'p'
NEGATIVE_UNL LedgerEntryType = 0x2d31 // -1
UNKNOW_LEDGER_TYPE LedgerEntryType = 0xff

// TransactionType values come from rippled's "TxFormats.h"
Expand All @@ -45,6 +46,7 @@ const (
ACCOUNT_DELETE TransactionType = 21
AMENDMENT TransactionType = 100
SET_FEE TransactionType = 101
UNL_MODIFY TransactionType = 102
UNKNOW_TX_TYPE TransactionType = 999
)

Expand All @@ -53,19 +55,20 @@ var LedgerFactory = [...]func() Hashable{
}

var LedgerEntryFactory = [...]func() LedgerEntry{
ACCOUNT_ROOT: func() LedgerEntry { return &AccountRoot{leBase: leBase{LedgerEntryType: ACCOUNT_ROOT}} },
DIRECTORY: func() LedgerEntry { return &Directory{leBase: leBase{LedgerEntryType: DIRECTORY}} },
AMENDMENTS: func() LedgerEntry { return &Amendments{leBase: leBase{LedgerEntryType: AMENDMENTS}} },
LEDGER_HASHES: func() LedgerEntry { return &LedgerHashes{leBase: leBase{LedgerEntryType: LEDGER_HASHES}} },
OFFER: func() LedgerEntry { return &Offer{leBase: leBase{LedgerEntryType: OFFER}} },
RIPPLE_STATE: func() LedgerEntry { return &RippleState{leBase: leBase{LedgerEntryType: RIPPLE_STATE}} },
FEE_SETTINGS: func() LedgerEntry { return &FeeSettings{leBase: leBase{LedgerEntryType: FEE_SETTINGS}} },
ESCROW: func() LedgerEntry { return &Escrow{leBase: leBase{LedgerEntryType: ESCROW}} },
SIGNER_LIST: func() LedgerEntry { return &SignerList{leBase: leBase{LedgerEntryType: SIGNER_LIST}} },
TICKET: func() LedgerEntry { return &Ticket{leBase: leBase{LedgerEntryType: TICKET}} },
PAY_CHANNEL: func() LedgerEntry { return &PayChannel{leBase: leBase{LedgerEntryType: PAY_CHANNEL}} },
CHECK: func() LedgerEntry { return &Check{leBase: leBase{LedgerEntryType: CHECK}} },
DEPOSIT_PRE_AUTH: func() LedgerEntry { return &DepositPreAuth{leBase: leBase{LedgerEntryType: DEPOSIT_PRE_AUTH}} },
ACCOUNT_ROOT: func() LedgerEntry { return &AccountRoot{leBase: leBase{LedgerEntryType: ACCOUNT_ROOT}} },
DIRECTORY: func() LedgerEntry { return &Directory{leBase: leBase{LedgerEntryType: DIRECTORY}} },
AMENDMENTS: func() LedgerEntry { return &Amendments{leBase: leBase{LedgerEntryType: AMENDMENTS}} },
LEDGER_HASHES: func() LedgerEntry { return &LedgerHashes{leBase: leBase{LedgerEntryType: LEDGER_HASHES}} },
OFFER: func() LedgerEntry { return &Offer{leBase: leBase{LedgerEntryType: OFFER}} },
RIPPLE_STATE: func() LedgerEntry { return &RippleState{leBase: leBase{LedgerEntryType: RIPPLE_STATE}} },
FEE_SETTINGS: func() LedgerEntry { return &FeeSettings{leBase: leBase{LedgerEntryType: FEE_SETTINGS}} },
ESCROW: func() LedgerEntry { return &Escrow{leBase: leBase{LedgerEntryType: ESCROW}} },
SIGNER_LIST: func() LedgerEntry { return &SignerList{leBase: leBase{LedgerEntryType: SIGNER_LIST}} },
TICKET: func() LedgerEntry { return &Ticket{leBase: leBase{LedgerEntryType: TICKET}} },
PAY_CHANNEL: func() LedgerEntry { return &PayChannel{leBase: leBase{LedgerEntryType: PAY_CHANNEL}} },
CHECK: func() LedgerEntry { return &Check{leBase: leBase{LedgerEntryType: CHECK}} },
DEPOSIT_PRE_AUTH: func() LedgerEntry { return &DepositPreAuth{leBase: leBase{LedgerEntryType: DEPOSIT_PRE_AUTH}} },
NEGATIVE_UNL: func() LedgerEntry { return &DepositPreAuth{leBase: leBase{LedgerEntryType: NEGATIVE_UNL}} },
UNKNOW_LEDGER_TYPE: func() LedgerEntry { return &UnknowLedger{leBase: leBase{LedgerEntryType: UNKNOW_LEDGER_TYPE}} },
}

Expand All @@ -89,23 +92,25 @@ var TxFactory = [...]func() Transaction{
CHECK_CREATE: func() Transaction { return &CheckCreate{TxBase: TxBase{TransactionType: CHECK_CREATE}} },
CHECK_CASH: func() Transaction { return &CheckCash{TxBase: TxBase{TransactionType: CHECK_CASH}} },
CHECK_CANCEL: func() Transaction { return &CheckCancel{TxBase: TxBase{TransactionType: CHECK_CANCEL}} },
UNL_MODIFY: func() Transaction { return &CheckCancel{TxBase: TxBase{TransactionType: UNL_MODIFY}} },
UNKNOW_TX_TYPE: func() Transaction { return &UnknowTx{TxBase: TxBase{TransactionType: UNKNOW_TX_TYPE}} },
}

var ledgerEntryNames = [...]string{
ACCOUNT_ROOT: "AccountRoot",
DIRECTORY: "DirectoryNode",
AMENDMENTS: "Amendments",
LEDGER_HASHES: "LedgerHashes",
OFFER: "Offer",
RIPPLE_STATE: "RippleState",
FEE_SETTINGS: "FeeSettings",
ESCROW: "Escrow",
SIGNER_LIST: "SignerList",
TICKET: "Ticket",
PAY_CHANNEL: "PayChannel",
CHECK: "Check",
DEPOSIT_PRE_AUTH: "DepositPreAuth",
ACCOUNT_ROOT: "AccountRoot",
DIRECTORY: "DirectoryNode",
AMENDMENTS: "Amendments",
LEDGER_HASHES: "LedgerHashes",
OFFER: "Offer",
RIPPLE_STATE: "RippleState",
FEE_SETTINGS: "FeeSettings",
ESCROW: "Escrow",
SIGNER_LIST: "SignerList",
TICKET: "Ticket",
PAY_CHANNEL: "PayChannel",
CHECK: "Check",
DEPOSIT_PRE_AUTH: "DepositPreAuth",
NEGATIVE_UNL: "NegativeUNL",
UNKNOW_LEDGER_TYPE: "UnknowLedgerType",
}

Expand All @@ -123,6 +128,7 @@ var ledgerEntryTypes = map[string]LedgerEntryType{
"PayChannel": PAY_CHANNEL,
"Check": CHECK,
"DepositPreAuth": DEPOSIT_PRE_AUTH,
"NegativeUNL": NEGATIVE_UNL,
}

var txNames = [...]string{
Expand All @@ -145,6 +151,7 @@ var txNames = [...]string{
CHECK_CREATE: "CheckCreate",
CHECK_CASH: "CheckCash",
CHECK_CANCEL: "CheckCancel",
UNL_MODIFY: "UNLModify",
UNKNOW_TX_TYPE: "UnknowTxType",
}

Expand All @@ -168,6 +175,7 @@ var txTypes = map[string]TransactionType{
"CheckCreate": CHECK_CREATE,
"CheckCash": CHECK_CASH,
"CheckCancel": CHECK_CANCEL,
"UNLModify": UNL_MODIFY,
}

var HashableTypes []string
Expand Down
3 changes: 2 additions & 1 deletion data/ledgerset.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@ package data

import (
"fmt"
"github.com/willf/bitset"
"sort"
"time"

"github.com/bits-and-blooms/bitset"
)

type LedgerSlice []uint32
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ module github.com/rubblelabs/ripple
go 1.12

require (
github.com/bits-and-blooms/bitset v1.2.1
github.com/btcsuite/btcd v0.20.1-beta
github.com/fatih/color v1.9.0
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b
github.com/gorilla/websocket v1.4.2
github.com/juju/loggo v0.0.0-20190526231331-6e530bcce5d8 // indirect
github.com/juju/testing v0.0.0-20191001232224-ce9dec17d28b
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e // indirect
github.com/willf/bitset v1.1.10
golang.org/x/crypto v0.0.0-20200323165209-0ec3e9974c59
gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f
gopkg.in/mgo.v2 v2.0.0-20190816093944-a6b53ec6cb22 // indirect
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
github.com/aead/siphash v1.0.1/go.mod h1:Nywa3cDsYNNK3gaciGTWPwHt0wlpNV15vwmswBAUSII=
github.com/bits-and-blooms/bitset v1.2.1 h1:M+/hrU9xlMp7t4TyTDQW97d3tRPVuKFC6zBEK16QnXY=
github.com/bits-and-blooms/bitset v1.2.1/go.mod h1:gIdJ4wp64HaoK2YrL1Q5/N7Y16edYb8uY+O0FJTyyDA=
github.com/btcsuite/btcd v0.20.1-beta h1:Ik4hyJqN8Jfyv3S4AGBOmyouMsYE3EdYODkMbQjwPGw=
github.com/btcsuite/btcd v0.20.1-beta/go.mod h1:wVuoA8VJLEcwgqHBwHmzLRazpKxTv13Px/pDuV7OomQ=
github.com/btcsuite/btclog v0.0.0-20170628155309-84c8d2346e9f/go.mod h1:TdznJufoqS23FtqVCzL0ZqgP5MqXbb4fg/WgDys70nA=
Expand Down Expand Up @@ -39,8 +41,6 @@ github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLA
github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
github.com/onsi/ginkgo v1.7.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
github.com/onsi/gomega v1.4.3/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY=
github.com/willf/bitset v1.1.10 h1:NotGKqX0KwQ72NUzqrjZq5ipPNDQex9lo3WpaS8L2sc=
github.com/willf/bitset v1.1.10/go.mod h1:RjeCKbqT1RxIR/KWY6phxZiaY1IyutSBfGjNPySAYV4=
golang.org/x/crypto v0.0.0-20170930174604-9419663f5a44/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20200323165209-0ec3e9974c59 h1:3zb4D3T4G8jdExgVU/95+vQXfpEPiMdCaZgmGVxjNHM=
Expand Down
43 changes: 42 additions & 1 deletion websockets/commands_test.go

Large diffs are not rendered by default.

0 comments on commit 4e9e05a

Please sign in to comment.