XRPL4J - 签署 NFTokenMint 交易时出错

XRPL4J - Error in signing NFTokenMint transaction

我正在试用 XRPL4J 库的 XLS-20 nft-support 分支。我创建了一个 nft-devnet 水龙头地址并正在尝试一个基本的 NFTokenMint 交易。 我重复使用了一些可用的教程代码来获取某些值,例如序列或分类帐费用。

如果我理解正确的话,我的 tk 对象有问题。但是我想不出具体原因。

WalletFactory walletFactory = DefaultWalletFactory.getInstance();
Wallet testWallet = walletFactory.fromSeed("shhf1NSyjZw1JLj9Y67XdiAeaqDou", true);

// Get the Classic address from testWallet
Address classicAddress = testWallet.classicAddress();

// Connect --------------------------------------------------------------------
HttpUrl rippledUrl = HttpUrl.get("http://xls20-sandbox.rippletest.net:51234");
XrplClient xrplClient = new XrplClient(rippledUrl);

// Prepare transaction --------------------------------------------------------
// Look up your Account Info
AccountInfoRequestParams requestParams = AccountInfoRequestParams.builder()
                .ledgerIndex(LedgerIndex.VALIDATED)
                .account(classicAddress)
                .build();
AccountInfoResult accountInfoResult = xrplClient.accountInfo(requestParams);
        UnsignedInteger sequence = accountInfoResult.accountData().sequence();

// Request current fee information from rippled
FeeResult feeResult = xrplClient.fee();
XrpCurrencyAmount openLedgerFee = feeResult.drops().openLedgerFee();

// Get the latest validated ledger index
LedgerIndex validatedLedger = xrplClient.ledger(
                        LedgerRequestParams.builder()
                                .ledgerIndex(LedgerIndex.VALIDATED)
                                .build()
                )
                .ledgerIndex()
                .orElseThrow(() -> new RuntimeException("LedgerIndex not available."));

// Workaround for https://github.com/XRPLF/xrpl4j/issues/84
UnsignedInteger lastLedgerSequence = UnsignedInteger.valueOf(
                validatedLedger.plus(UnsignedLong.valueOf(4)).unsignedLongValue().intValue()
        );

NfTokenMint tk = NfTokenMint.builder()
                .account(classicAddress)
                .signingPublicKey(publicKey)
                .lastLedgerSequence(lastLedgerSequence)
                .fee(openLedgerFee)
                .flags(Flags.NfTokenMintFlags.builder().tfOnlyXRP(true).tfTransferable(true).build())
                .tokenTaxon(UnsignedLong.ZERO)
                .sequence(sequence)
                .uri("ipfs://bafybeigdyrzt5sfp7udm7hu76uh7y26nf4dfuylqabf3oclgtqy55fbzdi")
                .build();


        // Sign the Minting
SignedTransaction<NfTokenMint> signedMinting = signatureService.sign(KeyMetadata.EMPTY, tk);

在签名行中出现以下错误:

    java.lang.NumberFormatException: NfTokenMint
        at com.google.common.primitives.UnsignedLongs.parseUnsignedLong(UnsignedLongs.java:351) ~[guava-29.0-jre.jar:na]
        at com.google.common.primitives.UnsignedLong.valueOf(UnsignedLong.java:123) ~[guava-29.0-jre.jar:na]
        at com.google.common.primitives.UnsignedLong.valueOf(UnsignedLong.java:110) ~[guava-29.0-jre.jar:na]
        at org.xrpl.xrpl4j.codec.binary.types.UInt16Type.fromJson(UInt16Type.java:28) ~[xrpl4j-binary-codec-nft-support-SNAPSHOT.jar:na]
        at org.xrpl.xrpl4j.codec.binary.types.UInt16Type.fromJson(UInt16Type.java:11) ~[xrpl4j-binary-codec-nft-support-SNAPSHOT.jar:na]
        at org.xrpl.xrpl4j.codec.binary.serdes.BinarySerializer.writeFieldAndValue(BinarySerializer.java:90) ~[xrpl4j-binary-codec-nft-support-SNAPSHOT.jar:na]
        at org.xrpl.xrpl4j.codec.binary.types.STObjectType.lambda$fromJson(STObjectType.java:78) ~[xrpl4j-binary-codec-nft-support-SNAPSHOT.jar:na]
        at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:183) ~[na:na]
        at java.base/java.util.stream.SortedOps$SizedRefSortingSink.end(SortedOps.java:357) ~[na:na]
        at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:510) ~[na:na]
        at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499) ~[na:na]
        at java.base/java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:150) ~[na:na]
        at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:173) ~[na:na]
        at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234) ~[na:na]
        at java.base/java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:596) ~[na:na]
        at org.xrpl.xrpl4j.codec.binary.types.STObjectType.fromJson(STObjectType.java:76) ~[xrpl4j-binary-codec-nft-support-SNAPSHOT.jar:na]
        at org.xrpl.xrpl4j.codec.binary.XrplBinaryCodec.encode(XrplBinaryCodec.java:61) ~[xrpl4j-binary-codec-nft-support-SNAPSHOT.jar:na]
        at org.xrpl.xrpl4j.codec.binary.XrplBinaryCodec.encodeForSigning(XrplBinaryCodec.java:75) ~[xrpl4j-binary-codec-nft-support-SNAPSHOT.jar:na]
        at org.xrpl.xrpl4j.crypto.signing.SignatureUtils.toSignableBytes(SignatureUtils.java:67) ~[xrpl4j-crypto-core-nft-support-SNAPSHOT.jar:na]
        at org.xrpl.xrpl4j.crypto.signing.AbstractSignatureService.signWithBehavior(AbstractSignatureService.java:69) ~[xrpl4j-crypto-core-nft-support-SNAPSHOT.jar:na]
        at org.xrpl.xrpl4j.crypto.signing.AbstractSignatureService.sign(AbstractSignatureService.java:54) ~[xrpl4j-crypto-core-nft-support-SNAPSHOT.jar:na]
        at com.example.demo.controller.nft.NFTController.mintNFT(NFTController.java:105) ~[main/:na]
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:na]
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77) ~[na:na]
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:na]
        at java.base/java.lang.reflect.Method.invoke(Method.java:568) ~[na:na]
        at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:205) ~[spring-web-5.3.15.jar:5.3.15]
        at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:150) ~[spring-web-5.3.15.jar:5.3.15]
        at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:117) ~[spring-webmvc-5.3.15.jar:5.3.15]
        at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:895) ~[spring-webmvc-5.3.15.jar:5.3.15]
        at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:808) ~[spring-webmvc-5.3.15.jar:5.3.15]
        at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87) ~[spring-webmvc-5.3.15.jar:5.3.15]
        at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1067) ~[spring-webmvc-5.3.15.jar:5.3.15]
        at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:963) ~[spring-webmvc-5.3.15.jar:5.3.15]
        at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1006) ~[spring-webmvc-5.3.15.jar:5.3.15]
        at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:909) ~[spring-webmvc-5.3.15.jar:5.3.15]

我的 NFTokenMint 对象如下所示:


NfTokenMint
{
account=rfdbh2jffFip1HerCZijvuj6qcu627uRxT, 
fee=10, 
sequence=571503, 
lastLedgerSequence=1028823, 
memos=[], 
signers=[],
signingPublicKey=aBRfkx8B2f8CZurgtcCphkmBhQC2CbeBSx4YqQdcMEb6QNnLxbbL, 
tokenTaxon=0,
uri=ipfs://bafybeigdyrzt5sfp7udm7hu76uh7y26nf4dfuylqabf3oclgtqy55fbzdi, 
flags=2147483658
}

针对这个问题,xrpl4j 代码库中修复了这个问题。有关详细信息,请参阅 https://github.com/XRPLF/xrpl4j/issues/223